Let's say I was lexing a ruby method definition:
def print_greeting(greeting = "hi")
end
Is it the lexer's job to maintain state and emit relevant tokens, or should it be relatively dumb? Notice in the above example the greeting
param has a default value of "hi"
. In a different context, greeting = "hi"
is variable assignment which sets greeting
to "hi"
. Should the lexer emit generic tokens such as IDENTIFIER EQUALS STRING
, or should it be context-aware and emit something like PARAM_NAME EQUALS STRING
?