more documentation updated [skip ci]

This commit is contained in:
Camilo Roca 2020-02-07 14:13:52 +01:00
parent d8435e13c3
commit 07aaf5fc63
1 changed files with 3 additions and 18 deletions

View File

@ -15,7 +15,7 @@ The tests were conducted using Selenium. No issue was found, so you should find
## Is NodeJS supported?
The runtime has also been extensively tested against Node.js 0.12.7. No issue was found.
The runtime has also been extensively tested against Node.js 10 LTS. No issue was found.
## How to create a JavaScript lexer or parser?
@ -55,32 +55,17 @@ You can get [information on webpack here](https://webpack.github.io).
The steps to create your parsing code are the following:
- generate your lexer, parser, listener and visitor using the antlr tool
- write your parse tree handling code by providig your custom listener or visitor, and associated code, using 'require' to load antlr.
- write your parse tree handling code by providing your custom listener or visitor, and associated code, using 'require' to load antlr.
- create an index.js file with the entry point to your parsing code (or several if required).
- test your parsing logic thoroughly using node.js
You are now ready to bundle your parsing code as follows:
- following webpack specs, create a webpack.config file
- in the webpack.config file, exclude node.js only modules using: node: { module: "empty", net: "empty", fs: "empty" }
- in the `webpack.config` file, exclude node.js only modules using: `node: { module: "empty", net: "empty", fs: "empty" }`
- from the cmd line, navigate to the directory containing webpack.config and type: webpack
This will produce a single js file containing all your parsing code. Easy to include in your web pages!
If you can't use webpack, you can use the lib/require.js script which implements the Node.js 'require' function in brwsers.
This script is provided by Torben Haase, and is NOT part of ANTLR JavaScript runtime.
Assuming you have, at the root of your web site, both the 'antlr4' directory and a 'lib' directory with 'require.js' inside it, all you need to put in your HTML header is the following:
```xml
<script src='lib/require.js'>
<script>
var antlr4 = require('antlr4/index');
</script>
```
This will load the runtime asynchronously.
## How do I run the generated lexer and/or parser?
Let's suppose that your grammar is named, as above, "MyGrammar". Let's suppose this parser comprises a rule named "StartRule". The tool will have generated for you the following files: