Skip to content

Commit 89e8b9a

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#34994 - dns2utf8:doc_grammar, r=steveklabnik
Fix grammar verifcation I wanted to improve the [grammar-section](https://doc.rust-lang.org/grammar.html#items-and-attributes) but I can not build it. r? @steveklabnik @brson EDIT: I resolved some of the issues, removed the compiler output from the entry.
2 parents 96e53de + 76026d1 commit 89e8b9a

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

mk/clean.mk

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ clean-all: clean clean-llvm
3535

3636
clean-llvm: $(CLEAN_LLVM_RULES)
3737

38-
clean: clean-misc $(CLEAN_STAGE_RULES)
38+
clean: clean-misc clean-grammar $(CLEAN_STAGE_RULES)
3939

4040
clean-misc:
4141
@$(call E, cleaning)
@@ -47,6 +47,10 @@ clean-misc:
4747
$(Q)rm -Rf dist/*
4848
$(Q)rm -Rf doc
4949

50+
clean-grammar:
51+
@$(call E, cleaning grammar verification)
52+
$(Q)cd src/grammar && rm -Rf verify *.class *.java *.tokens
53+
$(Q)rm -Rf grammar
5054
define CLEAN_GENERIC
5155

5256
clean-generic-$(2)-$(1):

mk/grammar.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $(BG):
3737

3838
$(BG)RustLexer.class: $(BG) $(SG)RustLexer.g4
3939
$(Q)$(CFG_ANTLR4) -o $(BG) $(SG)RustLexer.g4
40-
$(Q)$(CFG_JAVAC) -d $(BG) $(BG)RustLexer.java
40+
$(Q)$(CFG_JAVAC) -d $(BG) -classpath /usr/share/java/antlr-complete.jar $(BG)RustLexer.java
4141

4242
check-build-lexer-verifier: $(BG)verify
4343

mk/tests.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ cleantestlibs:
243243

244244
.PHONY: tidy
245245
tidy: $(HBIN0_H_$(CFG_BUILD))/tidy$(X_$(CFG_BUILD)) \
246-
$(SNAPSHOT_RUSTC_POST_CLEANUP)
246+
$(SNAPSHOT_RUSTC_POST_CLEANUP) \
247+
check-build-lexer-verifier
247248
$(TARGET_RPATH_VAR0_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $< $(S)src
248249

249250
$(HBIN0_H_$(CFG_BUILD))/tidy$(X_$(CFG_BUILD)): \

src/grammar/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Uses [antlr4](http://www.antlr.org/) and a custom Rust tool to compare
44
ASTs/token streams generated. You can use the `check-lexer` make target to
55
run all of the available tests.
66

7-
To use manually:
7+
To use manually, assuming antlr4 ist installed at `/usr/share/java/antlr-complete.jar`:
88

99
```
1010
antlr4 RustLexer.g4
11-
javac *.java
11+
javac -classpath /usr/share/java/antlr-complete.jar *.java
1212
rustc -O verify.rs
1313
for file in ../*/**.rs; do
1414
echo $file;

src/grammar/check.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ skipped=0
2020
check() {
2121
grep --silent "// ignore-lexer-test" "$1";
2222

23-
# if it's *not* found...
23+
# if it is *not* found...
2424
if [ $? -eq 1 ]; then
25-
cd $2 # This `cd` is so java will pick up RustLexer.class. I couldn't
25+
cd $2 # This `cd` is so java will pick up RustLexer.class. I could not
2626
# figure out how to wrangle the CLASSPATH, just adding build/grammar
27-
# didn't seem to have any effect.
27+
# did not seem to have any effect.
2828
if $3 RustLexer tokens -tokens < $1 | $4 $1 $5; then
2929
echo "pass: $1"
3030
passed=`expr $passed + 1`

src/grammar/verify.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![feature(plugin, rustc_private)]
1212

1313
extern crate syntax;
14+
extern crate syntax_pos;
1415
extern crate rustc;
1516

1617
#[macro_use]
@@ -290,9 +291,10 @@ fn main() {
290291

291292
let options = config::basic_options();
292293
let session = session::build_session(options, &DepGraph::new(false), None,
293-
syntax::diagnostics::registry::Registry::new(&[]),
294+
syntax::errors::registry::Registry::new(&[]),
294295
Rc::new(DummyCrateStore));
295-
let filemap = session.parse_sess.codemap().new_filemap(String::from("<n/a>"), code);
296+
let filemap = session.parse_sess.codemap()
297+
.new_filemap("<n/a>".to_string(), None, code);
296298
let mut lexer = lexer::StringReader::new(session.diagnostic(), filemap);
297299
let cm = session.codemap();
298300

0 commit comments

Comments
 (0)