|
| 1 | +# Copyright 2014 The Rust Project Developers. See the COPYRIGHT |
| 2 | +# file at the top-level directory of this distribution and at |
| 3 | +# http://rust-lang.org/COPYRIGHT. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +# option. This file may not be copied, modified, or distributed |
| 9 | +# except according to those terms. |
| 10 | + |
| 11 | +BG = $(CFG_BUILD_DIR)/grammar/ |
| 12 | +SG = $(S)src/grammar/ |
| 13 | +B = $(CFG_BUILD_DIR)/$(CFG_BUILD)/stage2/ |
| 14 | +L = $(B)lib/rustlib/$(CFG_BUILD)/lib |
| 15 | +LD = $(CFG_BUILD)/stage2/lib/rustlib/$(CFG_BUILD)/lib/ |
| 16 | +RUSTC = $(B)bin/rustc |
| 17 | + |
| 18 | +# Run the reference lexer against libsyntax and compare the tokens and spans. |
| 19 | +# If "// ignore-lexer-test" is present in the file, it will be ignored. |
| 20 | +# |
| 21 | +# $(1) is the file to test. |
| 22 | +define LEXER_TEST |
| 23 | +grep "// ignore-lexer-test" $(1) ; \ |
| 24 | + if [ $$? -eq 1 ]; then \ |
| 25 | + CLASSPATH=$(B)grammar $(CFG_GRUN) RustLexer tokens -tokens < $(1) \ |
| 26 | + | $(B)grammar/verify $(1) ; \ |
| 27 | + fi |
| 28 | +endef |
| 29 | + |
| 30 | +$(BG): |
| 31 | + $(Q)mkdir -p $(BG) |
| 32 | + |
| 33 | +$(BG)RustLexer.class: $(SG)RustLexer.g4 |
| 34 | + $(Q)$(CFG_ANTLR4) -o $(B)grammar $(SG)RustLexer.g4 |
| 35 | + $(Q)$(CFG_JAVAC) -d $(BG) $(BG)RustLexer.java |
| 36 | + |
| 37 | +$(BG)verify: $(SG)verify.rs rustc-stage2-H-$(CFG_BUILD) $(LD)stamp.regex_macros $(LD)stamp.rustc |
| 38 | + $(Q)$(RUSTC) -O --out-dir $(BG) -L $(L) $(SG)verify.rs |
| 39 | + |
| 40 | +check-lexer: $(BG) $(BG)RustLexer.class $(BG)verify |
| 41 | + $(info Verifying libsyntax against the reference lexer ...) |
| 42 | + $(Q)find $(S) -iname '*.rs' -exec "$(SG)check.sh" {} "$(BG)" \ |
| 43 | + "$(CFG_GRUN)" "$(BG)verify" "$(BG)RustLexer.tokens" "$(VERBOSE)" \; |
0 commit comments