How can a lexer decide a token to be "get", "IdentifierName" or "Identifier" ?

Brendan Eich brendan at mozilla.com
Mon Feb 4 13:43:43 PST 2013


Michael Dyck wrote:
> There's no way only if you're talking about an LR(0) parser. But an 
> LR(1) parser would have 1 token of lookahead to resolve the conflict:
>  -- if the next token is ":", reduce IdentifierName to PropertyName;
>  -- if the next token is an IdentifierName, shift that.
>  -- if the next token is anything else, syntax error.

Don't forget method definition shorthand syntax, if the next token is 
"(". Then the method is named "get", of course.

/be


More information about the es-discuss mailing list