In syntax_suggest, it lexes the code and counts various keywords. If it encounters a symbol like :module, it looks at state bits to decide if the token really is a keyword or not. ruby/syntax_suggest@10232e4
For the rewrite to native prism I don't want to rely on state at all. But I noticed that prism also lexes in the following way:
pp Prism.lex(":next").value
=> [[SYMBOL_BEGIN(1,0)-(1,1)(":"), 128], [KEYWORD_NEXT(1,1)-(1,5)("next"), 8], [EOF(1,5)-(1,5)(""), 2]]
# And similarly etc.
pp Prism.lex(":@foo").value
=> [[SYMBOL_BEGIN(1,0)-(1,1)(":"), 128], [INSTANCE_VARIABLE(1,1)-(1,5)("@foo"), 8], [EOF(1,5)-(1,5)(""), 2]]
Basically it happens in all the places that handle PM_CASE_KEYWORD (at least). Prism has the context, would it make sense to emit these as IDENTIFIER instead?
In
syntax_suggest, it lexes the code and counts various keywords. If it encounters a symbol like:module, it looks at state bits to decide if the token really is a keyword or not. ruby/syntax_suggest@10232e4For the rewrite to native prism I don't want to rely on state at all. But I noticed that prism also lexes in the following way:
Basically it happens in all the places that handle
PM_CASE_KEYWORD(at least). Prism has the context, would it make sense to emit these asIDENTIFIERinstead?