summaryrefslogtreecommitdiffstats
path: root/third_party/rust/jsparagus/js_parser/README.md
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/jsparagus/js_parser/README.md
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/jsparagus/js_parser/README.md')
-rw-r--r--third_party/rust/jsparagus/js_parser/README.md67
1 files changed, 67 insertions, 0 deletions
diff --git a/third_party/rust/jsparagus/js_parser/README.md b/third_party/rust/jsparagus/js_parser/README.md
new file mode 100644
index 0000000000..a8a814619d
--- /dev/null
+++ b/third_party/rust/jsparagus/js_parser/README.md
@@ -0,0 +1,67 @@
+## jsparagus/js_parser: Generating a parser for JavaScript
+
+In this directory:
+
+* **esgrammar.pgen** A grammar for the mini-language the ECMAScript
+ standard uses to describe ES grammar.
+
+* **es.esgrammar** - The actual grammar for ECMAScript, in emu-grammar
+ format, extracted automatically from the spec.
+
+* **extract_es_grammar.py** - The script that creates *es.esgrammar*.
+
+* **es-simplified.esgrammar** - A hacked version of *es.esgrammar* that
+ jsparagus can actually handle.
+
+* **generate_js_parser_tables.py** - A script to generate a JS parser
+ based on *es-simplified.esgrammar*. Read on for instructions.
+
+
+## How to run it
+
+To generate a parser, follow these steps:
+
+```console
+$ cd ..
+$ make init
+$ make all
+```
+
+**Note:** The last step currently takes about 35 seconds to run on my
+laptop. jsparagus is slow.
+
+Once you're done, to see your parser run, try this:
+
+```console
+$ cd crates/driver
+$ cargo run --release
+```
+
+The build also produces a copy of the JS parser in Python.
+After `make all`, you can use `make jsdemo` to run that.
+
+
+### How simplified is "es-simplified"?
+
+Here are the differences between *es.esgrammar*, the actual ES grammar,
+and *es-simplified.esgrammar*, the simplified version that jsparagus can
+actually handle:
+
+* The four productions with [~Yield] and [~Await] conditions are dropped.
+ This means that `yield` and `await` do not match *IdentifierReference*
+ or *LabelIdentifier*. I think it's better to do that in the lexer.
+
+* Truncated lookahead.
+
+ `ValueError: unsupported: lookahead > 1 token, [['{'], ['function'], ['async', ('no-LineTerminator-here',), 'function'], ['class'], ['let', '[']]`
+
+* Delete a rule that uses `but not` since it's not implemented.
+
+ Identifier :
+ IdentifierName but not ReservedWord
+
+ Making sense of this rule in the context of an LR parser is an
+ interesting task; see issue #28.
+
+* Ban loops of the form `for (async of EXPR) STMT` by adjusting a
+ lookahead assertion. The grammar is not LR(1).