3 ms·
why is it that when the input is (excluding all quotation marks) "obj = {};" the last token is ";" but when the input is "obj = {}" the last token is "x;" do
by samanator 7y ago
why is it that when the input is (excluding all quotation marks)
"obj = {};"
the last token is ";"
but when the input is
"obj = {}"
the last token is "x;"
does "x;" mean an implicit ";"?
- austincheney 7y agoI introduce pseudo tokens in place of missing syntax. Using the option correct converts the pseudo tokens into actual tokens. The pseudo tokens always start with x and can be easily ignored or discarded by any consuming application. I include the pseudo tokens for two reasons. The first reason is that they allow the parser to reason about the code more closely to the language specification. For example the specification says statements MUST be terminated by a semicolon and if a semicolon is not provided one will be inserted automatically (ASI). The second reason is that the pseudo tokens are necessary to eliminate certain ambiguity necessary for some advanced features.