This commit enables optional features that are enabled by default in the generated parser.
For now, only some of the helpers and filename are generated based on this new option, but this will change in the future most likely.
Resolves#421
The README.md file in the root of the repository had become too large, and as a result the file became hard to maintain.
This commit extracts all the documentation and moves it to separate but managable files within the docs directory, a new folder also located in the root of the repository.
Calling 'vm.runInContext' is slightly more expensive then calling `eval`, but removing the string template and extracting the variable generator helps abit.
Along with commit 851d8ed, this resolves#431 based on the fact that plugins can overwrite session methods, allowing use cases like multiple or limited errors (and/or warnings) to be an opt-in feature.
This test broke down aftert I intergrated the AST utils directly into the Grammar class, then I had problems importing the PEG.js parser to use the Grammar class, but found a workaround using 'process.cwd()'
* Add some useful debug information to some exceptions
* Add guard for visitor functions preventing from cryptic errors due to incomplete visitors
* Add guard for js generator for preventing from cryptic errors due to incarrect stack manipulations
All comments stored in the `comments` property of the `grammar` node.
Comments extracted only if the `extractComments` options set to `true` when you generate parser.
This property is object with mapping start offset of comment to comment object, that looks like:
```js
{
text: 'text in the comment, just after // or /* and before */',
multiline: true|false,// true for /**/ comments, false for // comments
location: location()
}
```
This commit adds support for '.js' files to be passed to the '-c', '--config' or '--extra-options-file' options on the CLI, allowing the developer to do some extra work before the parser is generated (if they wish), or dynamically set options based on the enviroment.
* Split 'consts' collection by content types into:
- literals: for literal expressions, like `"a"`
- classes: for character class expressions, like `[a]`
- expectations: for constants describing expected values when parse failed
- functions: for constants with function code
* Move any JavaScript code generation from 'generateBytecode' to 'generateJs'.
* Rename opcode 'MATCH_REGEXP' to 'MATCH_CLASS' (name reflects purpose, not implementation).
* Replace 'PUSH' opcode with 'PUSH_EMPTY_STRING' opcode because it is only used with empty strings