grammar: introduce n_op and operator in AAssignOp
authorJean Privat <jean@pryen.org>
Wed, 15 Apr 2015 04:49:59 +0000 (11:49 +0700)
committerJean Privat <jean@pryen.org>
Wed, 15 Apr 2015 05:43:57 +0000 (12:43 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

src/parser/nit.sablecc3xx
src/parser/parser_nodes.nit

index 0e17804..50fc1cf 100644 (file)
@@ -935,8 +935,8 @@ exprs
        | {bra} obra [exprs]:expr* cbra
        ;
 assign_op
-       = {plus} pluseq
-       | {minus} minuseq
+       = {plus} [op]:pluseq
+       | {minus}[op]:minuseq
        ;
 
 module_name = quad? [path]:id* id;
index 508c739..5fa19ce 100644 (file)
@@ -2551,22 +2551,26 @@ end
 # A complex assignment operator. (`+=` and `-=`)
 abstract class AAssignOp
        super Prod
+
+       # The combined assignment operator
+       var n_op: Token is writable, noinit
+
+       # The name of the operator without the `=` (eg '+')
+       fun operator: String is abstract
 end
 
 # The `+=` assignment operation
 class APlusAssignOp
        super AAssignOp
 
-       # The `+=` operator
-       var n_pluseq: TPluseq is writable, noinit
+       redef fun operator do return "+"
 end
 
 # The `-=` assignment operator
 class AMinusAssignOp
        super AAssignOp
 
-       # The `-=` operator
-       var n_minuseq: TMinuseq is writable, noinit
+       redef fun operator do return "-"
 end
 
 # A possibly fully-qualified module identifier