syntax
syntax copied to clipboard
Expose original source code to user-level
Some tools may need to analyze original source code corresponding to AST nodes (combined with node locations, it is possible to get a substring of a node in the source code).
We need to expose the source code on parser, tokenizer, and in the handlers. This can be just a global (or scoped) yysource variable.
Program : StatementList
{ $$ = {
type: 'Program',
body: $StatementList,
source: yysource,
}
}