diff --git a/grammar.ebnf b/grammar.ebnf index 26d752d..f985ca1 100644 --- a/grammar.ebnf +++ b/grammar.ebnf @@ -15,14 +15,13 @@ Fn = "fn" Identifier Block ; (* TODO: params, return value*) (* # Expressions *) (* expression *) -Expr = Ignore ; +Expr = Assign ; Block = '{' Expr '}' ; Group = '(' Expr? ')' ; Primary = Item | Identifier | Literal | Block | Group | Branch ; (* expression::math *) -Ignore = Assign (IgnoreOp Assign )* ; Assign = Compare (AssignOp Compare)* ; Compare = Range (CompareOp Range )* ; Range = Logic (RangeOp Logic )* ; @@ -34,7 +33,6 @@ Factor = Unary (FactorOp Unary )* ; Unary = (UnaryOp)* Primary ; (* expression::math::operator *) -IgnoreOp = ';' ; AssignOp = '=' | "+=" | "-=" | "*=" | "/=" | "&=" | "|=" | "^=" |"<<=" |">>=" ; CompareOp = '<' | "<=" | "==" | "!=" | ">=" | '>' ; diff --git a/libconlang/src/ast.rs b/libconlang/src/ast.rs index ab894df..61ea729 100644 --- a/libconlang/src/ast.rs +++ b/libconlang/src/ast.rs @@ -270,18 +270,16 @@ pub mod expression { r" | 8 | Assign |", r"`*=`, `/=`, `%=`, `+=`, `-=`, ",//| /* | | |*/ r"`&=`, |=, ", //| /* | | |*/ r"`^=`, `<<=`, `>>=`", r"| Right to Left")] - //! | 9 | Ignore | `;` | //! //! //! //! ## Syntax //! ```ignore //! /* All precedence levels other than Unary fold into Binary */ - //! Ignore := Assign (CompareOp Assign )* - //! Assign := Compare (IgnoreOp Compare)* - //! Compare := Logic (AssignOp Logic )* + //! Assign := Compare (AssignOp Compare)* + //! Compare := Logic (CompareOp Logic )* //! Logic := Bitwise (LogicOp Bitwise)* - //! Bitwise := Shift (BitOp Shift )* + //! Bitwise := Shift (BitwiseOp Shift )* //! Shift := Term (ShiftOp Term )* //! Term := Factor (TermOp Factor )* //! Factor := Unary (FactorOp Unary )* @@ -324,7 +322,7 @@ pub mod expression { r"| 7 |", r"`*=`, `/=`, `%=`, `+=`, `-=`, ",//| /* | |*/ r"`&=`, |=, ", //| /* | |*/ r"`^=`, `<<=`, `>>=`, `=`", r"| Left to Right")] - //! | 8 | `;` | + //! | 8 | `,` | /// Operators which take a single argument /// @@ -430,9 +428,6 @@ pub mod expression { ShlAssign, /// `>>=`: Right Shift In-place Assignment ShrAssign, - // Ignorance operators - /// `;`: Ignore - Ignore, } } } diff --git a/libconlang/src/parser.rs b/libconlang/src/parser.rs index be9b2eb..21e1680 100644 --- a/libconlang/src/parser.rs +++ b/libconlang/src/parser.rs @@ -341,7 +341,7 @@ impl Parser { impl Parser { fn expr(&mut self) -> PResult { use expression::Expr; - Ok(Expr { ignore: self.ignore()? }) + Ok(Expr { ignore: self.assign()? }) } fn block(&mut self) -> PResult { self.delimited(Type::LCurly, |p| p.expr(), Type::RCurly) @@ -408,8 +408,7 @@ macro binary ($($f:ident = $a:ident, $b:ident);*$(;)?) {$( /// # [Arithmetic and Logical Subexpressions](math) impl Parser { binary! { - //name operands operators - ignore = assign, ignore_op; + // name operands operators assign = compare, assign_op; compare = range, compare_op; range = logic, range_op; @@ -491,10 +490,6 @@ impl Parser { Type::LtLtEq => ShlAssign, Type::GtGtEq => ShrAssign, } - ignore_op: { - Type::Semi => Ignore, - } - } /// Parse a [unary operator](operator::Unary) fn unary_op(&mut self) -> PResult { diff --git a/libconlang/src/pretty_printer.rs b/libconlang/src/pretty_printer.rs index 6d9b38d..f420bf3 100644 --- a/libconlang/src/pretty_printer.rs +++ b/libconlang/src/pretty_printer.rs @@ -147,7 +147,6 @@ impl Visitor> for Printer { Binary::BitXorAssign => "^=", Binary::ShlAssign => "<<=", Binary::ShrAssign => ">>=", - Binary::Ignore => ";", }) } fn visit_unary_op(&mut self, op: &operator::Unary) -> IOResult<()> {