Permit error keyword to be used as variable name
@@ -131,6 +131,15 @@ SolIdentifier: Identifier = {
<l:@L> "leave" <r:@R> => Identifier{loc: Loc::File(file_no, l, r), name: "leave".to_string()},
<l:@L> "case" <r:@R> => Identifier{loc: Loc::File(file_no, l, r), name: "case".to_string()},
<l:@L> "default" <r:@R> => Identifier{loc: Loc::File(file_no, l, r), name: "default".to_string()},
+ <l:@L> "error" <r:@R> => Identifier{loc: Loc::File(file_no, l, r), name: "error".to_string()},
+}
+
+SolNoErrorIdentifier: Identifier = {
+ <l:@L> <n:identifier> <r:@R> => Identifier{loc: Loc::File(file_no, l, r), name: n.to_string()},
+ <l:@L> "switch" <r:@R> => Identifier{loc: Loc::File(file_no, l, r), name: "switch".to_string()},
+ <l:@L> "leave" <r:@R> => Identifier{loc: Loc::File(file_no, l, r), name: "leave".to_string()},
+ <l:@L> "case" <r:@R> => Identifier{loc: Loc::File(file_no, l, r), name: "case".to_string()},
+ <l:@L> "default" <r:@R> => Identifier{loc: Loc::File(file_no, l, r), name: "default".to_string()},
}
VariableDeclaration: VariableDeclaration = {
@@ -343,6 +352,7 @@ Precedence2: Expression = {
<a:@L> "--" <b:@R> <e:Precedence2> => Expression::PreDecrement(Loc::File(file_no, a, b), Box::new(e)),
<a:@L> "+" <b:@R> <e:Precedence2> => Expression::UnaryPlus(Loc::File(file_no, a, b), Box::new(e)),
<a:@L> "-" <b:@R> <e:Precedence2> => Expression::UnaryMinus(Loc::File(file_no, a, b), Box::new(e)),
+ <l:@L> "error" <r:@R> => Expression::Variable(Identifier{loc: Loc::File(file_no, l, r), name: "error".to_string()}),
Precedence0,
}
@@ -399,7 +409,7 @@ NoFunctionTyPrecedence0: Expression = {
<a:@L> "[" <v:CommaOne<Expression>> "]" <b:@R> => {
Expression::ArrayLiteral(Loc::File(file_no, a, b), v)
},
- <SolIdentifier> => Expression::Variable(<>),
+ <SolNoErrorIdentifier> => Expression::Variable(<>),
<l:@L> <e:Precedence0> <u:Unit> <r:@R> => Expression::Unit(Loc::File(file_no, l, r), Box::new(e), u),
<l:@L> <n:number> <r:@R> => {
let base: String = n.0.chars().filter(|v| *v != '_').collect();
