Let's say I used the lexing ruby โโmethod definition:
def print_greeting(greeting = "hi")
end
Is this the lexer's task to maintain state and emit relevant tokens, or should it be relatively dumb? Note that in the above example, the parameter greetinghas a default value "hi". In another context greeting = "hi", it is a variable assignment that sets greetingto "hi". Should the lexer generate common tokens, such as IDENTIFIER EQUALS STRING, or should it be context-sensitive and allocate something like PARAM_NAME EQUALS STRING?
source
share