Skip to content

Commit 7669305

Browse files
authored
Merge pull request #500 from ratmice/grmtools_section_y_files
Add grmtools section to `.y` files
2 parents 83e9225 + 90d493f commit 7669305

File tree

15 files changed

+18
-31
lines changed

15 files changed

+18
-31
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ grammar and lexing definitions). First we need to create a file `build.rs` in
1414
the root of our project with the following content:
1515

1616
```rust
17-
use cfgrammar::yacc::YaccKind;
1817
use lrlex::CTLexerBuilder;
1918

2019
fn main() {
2120
CTLexerBuilder::new()
2221
.lrpar_config(|ctp| {
23-
ctp.yacckind(YaccKind::Grmtools)
24-
.grammar_in_src_dir("calc.y")
22+
ctp.grammar_in_src_dir("calc.y")
2523
.unwrap()
2624
})
2725
.lexer_in_src_dir("calc.l")
@@ -48,6 +46,7 @@ lexer can be found in `src/calc.l`:
4846
and where the definitions for the parser can be found in `src/calc.y`:
4947

5048
```rust
49+
%grmtools{yacckind Grmtools}
5150
%start Expr
5251
%avoid_insert "INT"
5352
%%

doc/src/errorrecovery.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ make use of error recovery.
4949
A simple calculator grammar looks as follows:
5050

5151
```rust,noplaypen
52+
%grmtools{yacckind Grmtools}
5253
%start Expr
5354
%%
5455
Expr -> u64:
@@ -181,6 +182,7 @@ We thus change the grammar so that inserted integers prevent evaluation from
181182
occurring:
182183

183184
```rust,noplaypen
185+
%grmtools{yacckind Grmtools}
184186
%start Expr
185187
%%
186188
Expr -> Result<u64, ()>:
@@ -539,8 +541,7 @@ the first parsing error, with the `recoverer` method in `CTParserBuilder` or
539541
```rust,noplaypen
540542
CTLexerBuilder::new()
541543
.lrpar_config(|ctp| {
542-
ctp.yacckind(YaccKind::Grmtools)
543-
.recoverer(lrpar::RecoveryKind::None)
544+
ctp.recoverer(lrpar::RecoveryKind::None)
544545
.grammar_in_src_dir("calc.y")
545546
.unwrap()
546547
})

doc/src/manuallexer.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ Putting these together is then relatively easy. First a `build.rs` file for a
3838
hand-written lexer will look roughly as follows:
3939

4040
```rust
41-
use cfgrammar::yacc::YaccKind;
4241
use lrlex::{ct_token_map, DefaultLexerTypes};
4342
use lrpar::CTParserBuilder;
4443

4544
fn main() {
4645
let ctp = CTParserBuilder::<DefaultLexerTypes<u8>>::new()
47-
.yacckind(YaccKind::Grmtools)
4846
.grammar_in_src_dir("grammar.y")
4947
.unwrap()
5048
.build()

doc/src/quickstart.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,12 @@ file inside the root of our project which can process the lexer and grammar.
4848
Our `build.rs` file thus looks as follows:
4949

5050
```rust,noplaypen
51-
use cfgrammar::yacc::YaccKind;
5251
use lrlex::CTLexerBuilder;
5352
5453
fn main() {
5554
CTLexerBuilder::new()
5655
.lrpar_config(|ctp| {
57-
ctp.yacckind(YaccKind::Grmtools)
58-
.grammar_in_src_dir("calc.y")
56+
ctp.grammar_in_src_dir("calc.y")
5957
.unwrap()
6058
})
6159
.lexer_in_src_dir("calc.l")
@@ -103,6 +101,7 @@ is lexed, but no lexemes are created from it.
103101

104102
Our initial version of calc.y looks as follows:
105103
```rust,noplaypen
104+
%grmtools{yacckind Grmtools}
106105
%start Expr
107106
%%
108107
Expr -> Result<u64, ()>:

lrlex/examples/calc_manual_lex/build.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use cfgrammar::yacc::YaccKind;
21
use lrlex::{ct_token_map, DefaultLexerTypes};
32
use lrpar::CTParserBuilder;
43

@@ -13,7 +12,6 @@ const TOKENS_MAP: &[(&str, &str)] = &[
1312

1413
fn main() {
1514
let ctp = CTParserBuilder::<DefaultLexerTypes<u8>>::new()
16-
.yacckind(YaccKind::Grmtools)
1715
.grammar_in_src_dir("calc.y")
1816
.unwrap()
1917
.build()

lrlex/examples/calc_manual_lex/src/calc.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
%grmtools{yacckind Grmtools}
12
%start Expr
23
%avoid_insert "INT"
34
%expect-unused Unmatched "UNMATCHED"

lrpar/examples/calc_actions/build.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(rust_2018_idioms)]
2-
use cfgrammar::yacc::YaccKind;
32
use lrlex::CTLexerBuilder;
43

54
fn main() {
@@ -8,8 +7,7 @@ fn main() {
87
CTLexerBuilder::new()
98
.rust_edition(lrlex::RustEdition::Rust2021)
109
.lrpar_config(|ctp| {
11-
ctp.yacckind(YaccKind::Grmtools)
12-
.rust_edition(lrpar::RustEdition::Rust2021)
10+
ctp.rust_edition(lrpar::RustEdition::Rust2021)
1311
.grammar_in_src_dir("calc.y")
1412
.unwrap()
1513
})

lrpar/examples/calc_actions/src/calc.y

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
%grmtools {
2-
yacckind Grmtools
3-
}
1+
%grmtools {yacckind Grmtools}
42
%start Expr
53
%avoid_insert "INT"
64
%%

lrpar/examples/calc_ast/build.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(rust_2018_idioms)]
2-
use cfgrammar::yacc::YaccKind;
32
use lrlex::CTLexerBuilder;
43

54
fn main() {
@@ -8,8 +7,7 @@ fn main() {
87
CTLexerBuilder::new()
98
.rust_edition(lrlex::RustEdition::Rust2021)
109
.lrpar_config(|ctp| {
11-
ctp.yacckind(YaccKind::Grmtools)
12-
.rust_edition(lrpar::RustEdition::Rust2021)
10+
ctp.rust_edition(lrpar::RustEdition::Rust2021)
1311
.grammar_in_src_dir("calc.y")
1412
.unwrap()
1513
})

lrpar/examples/calc_ast/src/calc.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
%grmtools {yacckind Grmtools}
12
%start Expr
23
%avoid_insert "INT"
34
%expect-unused Unmatched "UNMATCHED"

0 commit comments

Comments
 (0)