@@ -9,10 +9,7 @@ use std::{
99} ;
1010
1111use derive_more:: Add ;
12- use gll:: {
13- forest:: { MoreThanOne , GrammarReflector } ,
14- parse_node:: ParseNodeShape ,
15- } ;
12+ use gll:: grammer:: forest:: { GrammarReflector , MoreThanOne , NodeShape } ;
1613use rayon:: prelude:: * ;
1714use rust_grammar:: parse;
1815use serde:: { Deserialize , Serialize } ;
@@ -72,26 +69,29 @@ enum Command {
7269 } ,
7370}
7471
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 > > ;
7676
7777type ModuleContentsHandle = parse:: OwnedHandle <
7878 proc_macro2:: TokenStream ,
7979 parse:: ModuleContents < ' static , ' static , proc_macro2:: TokenStream > ,
8080> ;
8181
82- enum Error < A > {
82+ enum Error < A , Pat > {
8383 Lex ( proc_macro2:: LexError ) ,
84- Parse ( gll:: parser:: ParseError < A > ) ,
84+ Parse ( gll:: grammer :: parser:: ParseError < A , Pat > ) ,
8585}
8686
87- impl < A > From < proc_macro2:: LexError > for Error < A > {
87+ impl < A , Pat > From < proc_macro2:: LexError > for Error < A , Pat > {
8888 fn from ( error : proc_macro2:: LexError ) -> Self {
8989 Error :: Lex ( error)
9090 }
9191}
9292
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 {
9595 Error :: Parse ( error)
9696 }
9797}
@@ -139,15 +139,9 @@ fn report_file_result(
139139 "(missing location information; \
140140 set `RUSTFLAGS='--cfg procmacro2_semver_exempt'`)"
141141 ) ;
142-
143142 }
144143
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) ;
151145 }
152146 ( Err ( Error :: Lex ( e) ) , _) => eprintln ! ( "FAIL ({:?})" , e) ,
153147 }
@@ -169,16 +163,16 @@ fn ambiguity_check(handle: &ModuleContentsHandle) -> Result<(), MoreThanOne> {
169163 }
170164 }
171165 } ;
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 ( _) => {
176170 if let Some ( child) = forest. unpack_opt ( source) {
177171 add_children ( & [ child] ) ;
178172 }
179173 }
180- ParseNodeShape :: Choice => add_children ( & [ forest. one_choice ( source) ?] ) ,
181- ParseNodeShape :: Split ( ..) => {
174+ NodeShape :: Choice => add_children ( & [ forest. one_choice ( source) ?] ) ,
175+ NodeShape :: Split ( ..) => {
182176 let ( left, right) = forest. one_split ( source) ?;
183177 add_children ( & [ left, right] )
184178 }
0 commit comments