This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ pub use crate::{
45
45
input:: Input ,
46
46
lexed_str:: LexedStr ,
47
47
output:: { Output , Step } ,
48
+ parser:: Edition ,
48
49
shortcuts:: StrStep ,
49
50
syntax_kind:: SyntaxKind ,
50
51
} ;
@@ -98,7 +99,7 @@ impl TopEntryPoint {
98
99
TopEntryPoint :: MetaItem => grammar:: entry:: top:: meta_item,
99
100
TopEntryPoint :: MacroEagerInput => grammar:: entry:: top:: eager_macro_input,
100
101
} ;
101
- let mut p = parser:: Parser :: new ( input) ;
102
+ let mut p = parser:: Parser :: new ( input, Edition :: Edition2021 ) ;
102
103
entry_point ( & mut p) ;
103
104
let events = p. finish ( ) ;
104
105
let res = event:: process ( events) ;
@@ -163,7 +164,7 @@ impl PrefixEntryPoint {
163
164
PrefixEntryPoint :: Item => grammar:: entry:: prefix:: item,
164
165
PrefixEntryPoint :: MetaItem => grammar:: entry:: prefix:: meta_item,
165
166
} ;
166
- let mut p = parser:: Parser :: new ( input) ;
167
+ let mut p = parser:: Parser :: new ( input, Edition :: Edition2021 ) ;
167
168
entry_point ( & mut p) ;
168
169
let events = p. finish ( ) ;
169
170
event:: process ( events)
@@ -189,7 +190,7 @@ impl Reparser {
189
190
/// sequence.
190
191
pub fn parse ( self , tokens : & Input ) -> Output {
191
192
let Reparser ( r) = self ;
192
- let mut p = parser:: Parser :: new ( tokens) ;
193
+ let mut p = parser:: Parser :: new ( tokens, Edition :: Edition2021 ) ;
193
194
r ( & mut p) ;
194
195
let events = p. finish ( ) ;
195
196
event:: process ( events)
Original file line number Diff line number Diff line change @@ -26,13 +26,27 @@ pub(crate) struct Parser<'t> {
26
26
pos : usize ,
27
27
events : Vec < Event > ,
28
28
steps : Cell < u32 > ,
29
+ edition : Edition ,
30
+ }
31
+
32
+ #[ non_exhaustive]
33
+ pub enum Edition {
34
+ Edition2015 ,
35
+ Edition2018 ,
36
+ Edition2021 ,
29
37
}
30
38
31
39
static PARSER_STEP_LIMIT : Limit = Limit :: new ( 15_000_000 ) ;
32
40
33
41
impl < ' t > Parser < ' t > {
34
- pub ( super ) fn new ( inp : & ' t Input ) -> Parser < ' t > {
35
- Parser { inp, pos : 0 , events : Vec :: new ( ) , steps : Cell :: new ( 0 ) }
42
+ pub ( super ) fn new ( inp : & ' t Input , edition : Edition ) -> Parser < ' t > {
43
+ Parser {
44
+ inp,
45
+ pos : 0 ,
46
+ events : Vec :: new ( ) ,
47
+ steps : Cell :: new ( 0 ) ,
48
+ edition,
49
+ }
36
50
}
37
51
38
52
pub ( crate ) fn finish ( self ) -> Vec < Event > {
You can’t perform that action at this time.
0 commit comments