@@ -13,8 +13,8 @@ pub struct ZZParser;
1313
1414pub static ERRORS_AS_JSON : AtomicBool = AtomicBool :: new ( false ) ;
1515
16- pub fn parse ( n : & Path , features : & HashMap < String , bool > , stage : & Stage ) -> Module {
17- match p ( & n, features , stage) {
16+ pub fn parse ( n : & Path , stage : & Stage ) -> Module {
17+ match p ( & n, stage) {
1818 Err ( e) => {
1919 let e = e. with_path ( & n. to_string_lossy ( ) . to_string ( ) ) ;
2020 if ERRORS_AS_JSON . load ( Ordering :: SeqCst ) {
@@ -49,7 +49,6 @@ pub fn parse(n: &Path, features: &HashMap<String, bool>, stage: &Stage) -> Modul
4949
5050fn p (
5151 n : & Path ,
52- features : & HashMap < String , bool > ,
5352 stage : & Stage ,
5453) -> Result < Module , pest:: error:: Error < Rule > > {
5554 let mut module = Module :: default ( ) ;
@@ -101,7 +100,7 @@ fn p(
101100 }
102101 }
103102 Rule :: block if body. is_none ( ) => {
104- body = Some ( parse_block ( & n, features , stage, part) ) ;
103+ body = Some ( parse_block ( & n, stage, part) ) ;
105104 }
106105 e => panic ! ( "unexpected rule {:?} in macro " , e) ,
107106 }
@@ -205,20 +204,20 @@ fn p(
205204 let part = stm. next ( ) . unwrap ( ) ;
206205 let expr = parse_expr ( n, part) ;
207206 let part = stm. next ( ) . unwrap ( ) ;
208- let body2 = parse_block ( n, features , stage, part) ;
207+ let body2 = parse_block ( n, stage, part) ;
209208 body. branches . push ( ( loc. clone ( ) , Some ( expr) , body2) ) ;
210209 }
211210 Rule :: else_stm => {
212211 let mut stm = branch. into_inner ( ) ;
213212 let part = stm. next ( ) . unwrap ( ) ;
214- let body2 = parse_block ( n, features , stage, part) ;
213+ let body2 = parse_block ( n, stage, part) ;
215214 body. branches . push ( ( loc. clone ( ) , None , body2) ) ;
216215 }
217216 Rule :: block => {
218217 body. branches = vec ! [ (
219218 loc. clone( ) ,
220219 None ,
221- parse_block( n, features , stage, branch) ,
220+ parse_block( n, stage, branch) ,
222221 ) ] ;
223222 }
224223 e => panic ! ( "unexpected rule {:?} in gblock" , e) ,
@@ -657,20 +656,20 @@ fn p(
657656 let part = stm. next ( ) . unwrap ( ) ;
658657 let expr = parse_expr ( n, part) ;
659658 let part = stm. next ( ) . unwrap ( ) ;
660- let body2 = parse_block ( n, features , stage, part) ;
659+ let body2 = parse_block ( n, stage, part) ;
661660 body. branches . push ( ( loc. clone ( ) , Some ( expr) , body2) ) ;
662661 }
663662 Rule :: else_stm => {
664663 let mut stm = branch. into_inner ( ) ;
665664 let part = stm. next ( ) . unwrap ( ) ;
666- let body2 = parse_block ( n, features , stage, part) ;
665+ let body2 = parse_block ( n, stage, part) ;
667666 body. branches . push ( ( loc. clone ( ) , None , body2) ) ;
668667 }
669668 Rule :: block => {
670669 body. branches = vec ! [ (
671670 loc. clone( ) ,
672671 None ,
673- parse_block( n, features , stage, branch) ,
672+ parse_block( n, stage, branch) ,
674673 ) ] ;
675674 }
676675 e => panic ! ( "unexpected rule {:?} in gblock" , e) ,
@@ -1102,7 +1101,6 @@ pub(crate) fn parse_expr_inner(n: &str, expr: pest::iterators::Pair<'static, Rul
11021101
11031102pub ( crate ) fn parse_statement (
11041103 n : & str ,
1105- features : & HashMap < String , bool > ,
11061104 stage : & Stage ,
11071105 stm : pest:: iterators:: Pair < ' static , Rule > ,
11081106 into : & mut Vec < Box < Statement > > ,
@@ -1141,7 +1139,7 @@ pub(crate) fn parse_statement(
11411139 into. push ( Box :: new ( Statement :: Break { loc } ) ) ;
11421140 }
11431141 Rule :: block => into. push ( Box :: new ( Statement :: Block ( Box :: new ( parse_block (
1144- n, features , stage, stm,
1142+ n, stage, stm,
11451143 ) ) ) ) ) ,
11461144 Rule :: return_stm => {
11471145 let mut stm = stm. into_inner ( ) ;
@@ -1174,15 +1172,15 @@ pub(crate) fn parse_statement(
11741172 let part = stm. next ( ) . unwrap ( ) ;
11751173 let expr = parse_expr ( n, part) ;
11761174 let part = stm. next ( ) . unwrap ( ) ;
1177- let body = parse_block ( n, features , stage, part) ;
1175+ let body = parse_block ( n, stage, part) ;
11781176 into. push ( Box :: new ( Statement :: While { expr, body } ) ) ;
11791177 }
11801178 Rule :: if_stm => {
11811179 let mut stm = stm. into_inner ( ) ;
11821180 let part = stm. next ( ) . unwrap ( ) ;
11831181 let expr = parse_expr ( n, part) ;
11841182 let part = stm. next ( ) . unwrap ( ) ;
1185- let body = parse_block ( n, features , stage, part) ;
1183+ let body = parse_block ( n, stage, part) ;
11861184 * current_if_statement = Some ( into. len ( ) ) ;
11871185 into. push ( Box :: new ( Statement :: If {
11881186 branches : vec ! [ ( loc. clone( ) , Some ( expr) , body) ] ,
@@ -1193,7 +1191,7 @@ pub(crate) fn parse_statement(
11931191 let part = stm. next ( ) . unwrap ( ) ;
11941192 let expr = parse_expr ( n, part) ;
11951193 let part = stm. next ( ) . unwrap ( ) ;
1196- let body = parse_block ( n, features , stage, part) ;
1194+ let body = parse_block ( n, stage, part) ;
11971195 match * current_if_statement {
11981196 None => {
11991197 emit_error (
@@ -1215,7 +1213,7 @@ pub(crate) fn parse_statement(
12151213 Rule :: else_stm => {
12161214 let mut stm = stm. into_inner ( ) ;
12171215 let part = stm. next ( ) . unwrap ( ) ;
1218- let body = parse_block ( n, features , stage, part) ;
1216+ let body = parse_block ( n, stage, part) ;
12191217 match * current_if_statement {
12201218 None => {
12211219 emit_error (
@@ -1251,18 +1249,18 @@ pub(crate) fn parse_statement(
12511249 cur += 1 ;
12521250 }
12531251 Rule :: block if cur == 3 && block. is_none ( ) => {
1254- block = Some ( parse_block ( n, features , stage, part) ) ;
1252+ block = Some ( parse_block ( n, stage, part) ) ;
12551253 }
12561254 _ if cur == 1 => {
12571255 let mut cif = None ;
1258- parse_statement ( n, features , stage, part, & mut expr1, & mut cif) ;
1256+ parse_statement ( n, stage, part, & mut expr1, & mut cif) ;
12591257 }
12601258 _ if cur == 2 => {
12611259 expr2 = Some ( parse_expr ( n, part) ) ;
12621260 }
12631261 _ if cur == 3 => {
12641262 let mut cif = None ;
1265- parse_statement ( n, features , stage, part, & mut expr3, & mut cif) ;
1263+ parse_statement ( n, stage, part, & mut expr3, & mut cif) ;
12661264 }
12671265 e => panic ! ( "unexpected rule {:?} in for " , e) ,
12681266 }
@@ -1367,15 +1365,15 @@ pub(crate) fn parse_statement(
13671365 emit_error ( "multiple default cases" , & [ ( loc. clone ( ) , "in this switch" ) ] ) ;
13681366 std:: process:: exit ( 9 ) ;
13691367 } else {
1370- default = Some ( parse_block ( n, features , stage, part. next ( ) . unwrap ( ) ) ) ;
1368+ default = Some ( parse_block ( n, stage, part. next ( ) . unwrap ( ) ) ) ;
13711369 }
13721370 } else {
13731371 let mut case_cond = Vec :: new ( ) ;
13741372 for case in ppart. into_inner ( ) {
13751373 case_cond. push ( parse_expr ( n, case) ) ;
13761374 }
13771375
1378- let block = parse_block ( n, features , stage, part. next ( ) . unwrap ( ) ) ;
1376+ let block = parse_block ( n, stage, part. next ( ) . unwrap ( ) ) ;
13791377 cases. push ( ( case_cond, block) ) ;
13801378 }
13811379 }
@@ -1390,7 +1388,6 @@ pub(crate) fn parse_statement(
13901388 Rule :: unsafe_block => {
13911389 into. push ( Box :: new ( Statement :: Unsafe ( Box :: new ( parse_block (
13921390 n,
1393- features,
13941391 stage,
13951392 stm. into_inner ( ) . next ( ) . unwrap ( ) ,
13961393 ) ) ) ) ) ;
@@ -1423,7 +1420,6 @@ pub(crate) fn parse_statement(
14231420
14241421pub ( crate ) fn parse_block (
14251422 n : & str ,
1426- features : & HashMap < String , bool > ,
14271423 stage : & Stage ,
14281424 decl : pest:: iterators:: Pair < ' static , Rule > ,
14291425) -> Block {
@@ -1445,7 +1441,7 @@ pub(crate) fn parse_block(
14451441 let mut statements = Vec :: new ( ) ;
14461442 let mut cif_state = None ;
14471443 for stm in decl. into_inner ( ) {
1448- parse_statement ( n, features , stage, stm, & mut statements, & mut cif_state)
1444+ parse_statement ( n, stage, stm, & mut statements, & mut cif_state)
14491445 }
14501446 Block {
14511447 statements,
0 commit comments