grammar: add bitwise operators `|`, `^`, `&`, and `~`
[nit.git] / src / parser / parser_nodes.nit
index 1525f17..1a37332 100644 (file)
@@ -750,6 +750,21 @@ class TStarstareq
        super TokenOperator
 end
 
+# The operator `|=`
+class TPipeeq
+       super TokenOperator
+end
+
+# The operator `^=`
+class TCareteq
+       super TokenOperator
+end
+
+# The operator `&=`
+class TAmpeq
+       super TokenOperator
+end
+
 # The operator `<<=`
 class TLleq
        super TokenOperator
@@ -800,11 +815,31 @@ class TSlash
        super TokenOperator
 end
 
-# The operator `+%
+# The operator `%`
 class TPercent
        super TokenOperator
 end
 
+# The operator `|`
+class TPipe
+       super TokenOperator
+end
+
+# The operator `^`
+class TCaret
+       super TokenOperator
+end
+
+# The operator `&`
+class TAmp
+       super TokenOperator
+end
+
+# The operator `~`
+class TTilde
+       super TokenOperator
+end
+
 # The operator `==`
 class TEq
        super TokenOperator
@@ -1425,116 +1460,106 @@ class AIdMethid
        var n_id: TId is writable, noinit
 end
 
-# A method name `+`
-class APlusMethid
+# A method name for an operator
+class AOperatorMethid
        super AMethid
 
-       # The `+` symbol
-       var n_plus: TPlus is writable, noinit
+       # The associated operator symbol
+       var n_op: Token is writable, noinit
+end
+# A method name `+`
+class APlusMethid
+       super AOperatorMethid
 end
 
 # A method name `-`
 class AMinusMethid
-       super AMethid
-
-       # The `-` symbol
-       var n_minus: TMinus is writable, noinit
+       super AOperatorMethid
 end
 
 # A method name `*`
 class AStarMethid
-       super AMethid
-
-       # The `*` symbol
-       var n_star: TStar is writable, noinit
+       super AOperatorMethid
 end
 
 # A method name `**`
 class AStarstarMethid
-       super AMethid
-
-       # The `**` symbol
-       var n_starstar: TStarstar is writable, noinit
+       super AOperatorMethid
 end
 
 # A method name `/`
 class ASlashMethid
-       super AMethid
-
-       # The `/` symbol
-       var n_slash: TSlash is writable, noinit
+       super AOperatorMethid
 end
 
 # A method name `%`
 class APercentMethid
-       super AMethid
+       super AOperatorMethid
+end
+
+# A method name `|`
+class APipeMethid
+       super AOperatorMethid
+end
 
-       # The `%` symbol
-       var n_percent: TPercent is writable, noinit
+# A method name `^`
+class ACaretMethid
+       super AOperatorMethid
+end
+
+# A method name `&`
+class AAmpMethid
+       super AOperatorMethid
+end
+
+# A method name `~`
+class ATildeMethid
+       super AOperatorMethid
 end
 
 # A method name `==`
 class AEqMethid
-       super AMethid
-
-       # The `==` symbol
-       var n_eq: TEq is writable, noinit
+       super AOperatorMethid
 end
 
 # A method name `!=`
 class ANeMethid
-       super AMethid
-
-       # The `!=` symbol
-       var n_ne: TNe is writable, noinit
+       super AOperatorMethid
 end
 
 # A method name `<=`
 class ALeMethid
-       super AMethid
-
-       # The `<=` symbol
-       var n_le: TLe is writable, noinit
+       super AOperatorMethid
 end
 
 # A method name `>=`
 class AGeMethid
-       super AMethid
-
-       # The `>=` symbol
-       var n_ge: TGe is writable, noinit
+       super AOperatorMethid
 end
 
 # A method name `<`
 class ALtMethid
-       super AMethid
-
-       # The `<` symbol
-       var n_lt: TLt is writable, noinit
+       super AOperatorMethid
 end
 
 # A method name `>`
 class AGtMethid
-       super AMethid
-
-       # The `>` symbol
-       var n_gt: TGt is writable, noinit
+       super AOperatorMethid
 end
 
 # A method name `<<`
 class ALlMethid
-       super AMethid
-
-       # The `<<` symbol
-       var n_ll: TLl is writable, noinit
+       super AOperatorMethid
 end
 
 # A method name `>>`
 class AGgMethid
-       super AMethid
+       super AOperatorMethid
+end
 
-       # The `>>` symbol
-       var n_gg: TGg is writable, noinit
+# A method name `<=>`
+class AStarshipMethid
+       super AOperatorMethid
 end
 
 # A method name `[]`
@@ -1548,14 +1573,6 @@ class ABraMethid
        var n_cbra: TCbra is writable, noinit
 end
 
-# A method name `<=>`
-class AStarshipMethid
-       super AMethid
-
-       # The `<=>` symbol
-       var n_starship: TStarship is writable, noinit
-end
-
 # A setter method name with a simple identifier (with a `=`)
 class AAssignMethid
        super AMethid
@@ -2078,20 +2095,51 @@ class APercentExpr
        redef fun operator do return "%"
 end
 
-# A unary minus expression. eg `-x`
-class AUminusExpr
+# A `|` expression
+class APipeExpr
+       super ABinopExpr
+       redef fun operator do return "|"
+end
+
+# A `^` expression
+class ACaretExpr
+       super ABinopExpr
+       redef fun operator do return "^"
+end
+
+# A `&` expression
+class AAmpExpr
+       super ABinopExpr
+       redef fun operator do return "&"
+end
+
+# A unary operation on a method
+class AUnaryopExpr
        super ASendExpr
 
-       # The `-` symbol
-       var n_minus: TMinus is writable, noinit
+       # The operator
+       var n_op: Token is writable, noinit
+
+       # The name of the operator (eg '+')
+       fun operator: String is abstract
+end
+
+# A unary minus expression. eg `-x`
+class AUminusExpr
+       super AUnaryopExpr
+       redef fun operator do return "-"
 end
 
 # A unary plus expression. eg `+x`
 class AUplusExpr
-       super ASendExpr
+       super AUnaryopExpr
+       redef fun operator do return "+"
+end
 
-       # The `+` symbol
-       var n_plus: TPlus is writable, noinit
+# A unary `~` expression
+class AUtildeExpr
+       super AUnaryopExpr
+       redef fun operator do return "~"
 end
 
 # An explicit instantiation. eg `new T`
@@ -2631,6 +2679,27 @@ class AStarstarAssignOp
        redef fun operator do return "**"
 end
 
+# A `|=` assignment operation
+class APipeAssignOp
+       super AAssignOp
+
+       redef fun operator do return "|"
+end
+
+# A `^=` assignment operation
+class ACaretAssignOp
+       super AAssignOp
+
+       redef fun operator do return "^"
+end
+
+# A `&=` assignment operation
+class AAmpAssignOp
+       super AAssignOp
+
+       redef fun operator do return "&"
+end
+
 # A `<<=` assignment operation
 class ALlAssignOp
        super AAssignOp