rust/src/grammar
2017-03-27 08:58:00 +02:00
..
.gitignore Byte/raw binary literal fixes 2014-07-21 10:59:58 -07:00
check.sh Fix grammar verification 2016-11-16 22:42:07 +01:00
lexer.l Adjust src/grammar for the introduced <- op 2015-10-27 23:06:37 +02:00
parser-lalr-main.c Add a LALR grammar for Rust with testing support 2015-01-20 18:47:17 -08:00
parser-lalr.y Fix whitespace alignment 2015-12-24 21:39:38 -05:00
raw-string-literal-ambiguity.md adding proof of context-sensitivy of raw string literals 2014-07-27 02:13:19 -04:00
README.md Fix typo 2017-02-15 15:13:31 +03:00
RustLexer.g4 Adjust src/grammar for the introduced <- op 2015-10-27 23:06:37 +02:00
testparser.py Move compile-fail tests that are rejected by the parser to parse-fail 2015-02-06 22:23:16 +01:00
tokens.h Use consistent terminology for byte string literals 2015-09-03 10:54:53 +03:00
verify.rs Fix various useless derefs and slicings 2017-03-27 08:58:00 +02:00
xidcontinue.g4 Finished unicode support in the model lexer. 2015-04-19 23:05:32 +02:00
xidstart.g4 Finished unicode support in the model lexer. 2015-04-19 23:05:32 +02: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 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:

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