Stefan Schindler 0e1828ab03 Fix grammar verification
* Use `make check-lexer` to verify the grammar.
 * Extend grammar/README
 * Add make clean-grammar rule
 * Add target `check-build-lexer-verifier` to `make tidy`, so it will build the verifier with every build and catch future errors
 * Search for antlr4 with configure and find
2016-11-16 22:42:07 +01:00
..
2016-11-16 22:42:07 +01:00
2015-12-24 21:39:38 -05:00
2016-11-16 22:42:07 +01:00
2016-11-16 22:42:07 +01:00

Reference grammar.

Uses antlr4 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 ist 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:

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