@@ -9,10 +9,7 @@ use std::{
9
9
} ;
10
10
11
11
use derive_more:: Add ;
12
- use gll:: {
13
- forest:: { MoreThanOne , GrammarReflector } ,
14
- parse_node:: ParseNodeShape ,
15
- } ;
12
+ use gll:: grammer:: forest:: { GrammarReflector , MoreThanOne , NodeShape } ;
16
13
use rayon:: prelude:: * ;
17
14
use rust_grammar:: parse;
18
15
use serde:: { Deserialize , Serialize } ;
@@ -72,26 +69,29 @@ enum Command {
72
69
} ,
73
70
}
74
71
75
- type ModuleContentsResult = Result < ModuleContentsHandle , Error < proc_macro2:: Span > > ;
72
+ type ProcMacroPat =
73
+ gll:: grammer:: proc_macro:: Pat < & ' static [ gll:: grammer:: proc_macro:: FlatTokenPat < & ' static str > ] > ;
74
+
75
+ type ModuleContentsResult = Result < ModuleContentsHandle , Error < proc_macro2:: Span , ProcMacroPat > > ;
76
76
77
77
type ModuleContentsHandle = parse:: OwnedHandle <
78
78
proc_macro2:: TokenStream ,
79
79
parse:: ModuleContents < ' static , ' static , proc_macro2:: TokenStream > ,
80
80
> ;
81
81
82
- enum Error < A > {
82
+ enum Error < A , Pat > {
83
83
Lex ( proc_macro2:: LexError ) ,
84
- Parse ( gll:: parser:: ParseError < A > ) ,
84
+ Parse ( gll:: grammer :: parser:: ParseError < A , Pat > ) ,
85
85
}
86
86
87
- impl < A > From < proc_macro2:: LexError > for Error < A > {
87
+ impl < A , Pat > From < proc_macro2:: LexError > for Error < A , Pat > {
88
88
fn from ( error : proc_macro2:: LexError ) -> Self {
89
89
Error :: Lex ( error)
90
90
}
91
91
}
92
92
93
- impl < A > From < gll:: parser:: ParseError < A > > for Error < A > {
94
- fn from ( error : gll:: parser:: ParseError < A > ) -> Self {
93
+ impl < A , Pat > From < gll:: grammer :: parser:: ParseError < A , Pat > > for Error < A , Pat > {
94
+ fn from ( error : gll:: grammer :: parser:: ParseError < A , Pat > ) -> Self {
95
95
Error :: Parse ( error)
96
96
}
97
97
}
@@ -139,15 +139,9 @@ fn report_file_result(
139
139
"(missing location information; \
140
140
set `RUSTFLAGS='--cfg procmacro2_semver_exempt'`)"
141
141
) ;
142
-
143
142
}
144
143
145
- // HACK(eddyb) this is inefficient - `expected` should be already
146
- // sorted for us, so this is a temporary workaround.
147
- let mut expected = error. expected . clone ( ) ;
148
- expected. sort_by_cached_key ( |x| format ! ( "{:?}" , x) ) ;
149
-
150
- eprintln ! ( "Expected: {:?}" , expected) ;
144
+ eprintln ! ( "Expected: {:?}" , error. expected) ;
151
145
}
152
146
( Err ( Error :: Lex ( e) ) , _) => eprintln ! ( "FAIL ({:?})" , e) ,
153
147
}
@@ -169,16 +163,16 @@ fn ambiguity_check(handle: &ModuleContentsHandle) -> Result<(), MoreThanOne> {
169
163
}
170
164
}
171
165
} ;
172
- match forest. grammar . parse_node_shape ( source. kind ) {
173
- ParseNodeShape :: Opaque => { }
174
- ParseNodeShape :: Alias ( _) => add_children ( & [ forest. unpack_alias ( source) ] ) ,
175
- ParseNodeShape :: Opt ( _) => {
166
+ match forest. grammar . node_shape ( source. kind ) {
167
+ NodeShape :: Opaque => { }
168
+ NodeShape :: Alias ( _) => add_children ( & [ forest. unpack_alias ( source) ] ) ,
169
+ NodeShape :: Opt ( _) => {
176
170
if let Some ( child) = forest. unpack_opt ( source) {
177
171
add_children ( & [ child] ) ;
178
172
}
179
173
}
180
- ParseNodeShape :: Choice => add_children ( & [ forest. one_choice ( source) ?] ) ,
181
- ParseNodeShape :: Split ( ..) => {
174
+ NodeShape :: Choice => add_children ( & [ forest. one_choice ( source) ?] ) ,
175
+ NodeShape :: Split ( ..) => {
182
176
let ( left, right) = forest. one_split ( source) ?;
183
177
add_children ( & [ left, right] )
184
178
}
0 commit comments