@@ -325,7 +325,7 @@ def builtins
325325 rule %r/=/ , Operator , :in_assign
326326 rule %r/\b (?:public|protected|private|readonly)(?:\( set\) |\b )/i , Keyword
327327 rule %r/\b readonly\b /i , Keyword
328- rule %r/\? ?#{ id } / , Keyword ::Type , :in_assign
328+ rule %r/\? ?#{ id } / , Keyword ::Type , :in_property
329329 mixin :escape
330330 mixin :whitespace
331331 mixin :variables
@@ -389,7 +389,10 @@ def builtins
389389 rule %r/\b (?:public|protected|private)(?:\( set\) |\b )/i , Keyword
390390 rule %r/\b (?:readonly|static)\b /i , Keyword
391391 rule %r/(?=(abstract|const|function)\b )/i , Keyword , :pop!
392- rule %r/\? ?#{ id } / , Keyword ::Type , :pop!
392+ rule %r/\? ?#{ id } / do
393+ token Keyword ::Type
394+ goto :in_property
395+ end
393396 mixin :escape
394397 mixin :whitespace
395398 mixin :return
@@ -417,6 +420,51 @@ def builtins
417420 end
418421 mixin :php
419422 end
423+
424+ state :in_property do
425+ rule %r/\$ +#{ id } / , Name ::Variable
426+ rule %r/\{ / do
427+ token Punctuation
428+ goto :in_property_hooks
429+ end
430+ rule %r/[;,]/ , Punctuation , :pop!
431+ rule %r/(?==)/ do
432+ pop!
433+ end
434+ rule %r/[|&]/ , Operator
435+ rule %r/\? ?#{ id } / , Keyword ::Type
436+ mixin :escape
437+ mixin :whitespace
438+ mixin :return
439+ end
440+
441+ state :in_property_hooks do
442+ rule %r/\} / , Punctuation , :pop!
443+ rule %r/\b final\b /i , Keyword
444+ rule %r/&(?=get\b )/ , Operator
445+ rule %r/(\b set\b )(\s *)(\( )/ do
446+ groups Keyword , Text , Punctuation
447+ push :in_property_hook_params
448+ end
449+ rule %r/\b (?:get|set)\b / , Keyword
450+ rule %r/\{ / , Punctuation , :in_function_body
451+ rule %r/[;,\( \) \[ \] ]/ , Punctuation
452+ mixin :escape
453+ mixin :whitespace
454+ mixin :variables
455+ mixin :values
456+ mixin :names
457+ mixin :operators
458+ rule %r/[=?]/ , Operator
459+ end
460+
461+ state :in_property_hook_params do
462+ rule %r/\) / , Punctuation , :pop!
463+ rule %r/\? ?#{ id } / , Keyword ::Type
464+ mixin :escape
465+ mixin :whitespace
466+ mixin :variables
467+ end
420468 end
421469 end
422470end
0 commit comments