summary refs log tree commit diff
path: root/src/grammar/README.md
blob: 83808108ff8325900f506e66c67677f8aeea960f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Reference grammar.

Uses [antlr4](http://www.antlr.org/) and a custom Rust tool to compare
ASTs/token streams generated. You can use the `make check-lexer` target to
run all of the available tests.

The build of the rust part is included with `make tidy` and can be run with `make check-build-lexer-verifier`.

# Manual build

To use manually, assuming antlr4 is installed at `/usr/share/java/antlr-complete.jar`:

```
antlr4 RustLexer.g4
javac -classpath /usr/share/java/antlr-complete.jar *.java
rustc -O verify.rs
for file in ../*/**.rs; do
    echo $file;
    grun RustLexer tokens -tokens < "$file" | ./verify "$file" RustLexer.tokens || break
done
```

Note that the `../*/**.rs` glob will match every `*.rs` file in the above
directory and all of its recursive children. This is a Zsh extension.


## Cleanup

To cleanup you can use a command like this:

```bash
rm -f verify *.class *.java *.tokens
```