Add grammar for SDAG 'when' and 'overlap' statements
authorAaron Becker <akbecker@gmail.com>
Mon, 23 Aug 2010 20:26:42 +0000 (15:26 -0500)
committerAaron Becker <akbecker@gmail.com>
Mon, 23 Aug 2010 20:37:34 +0000 (15:37 -0500)
src/langs/charj/src/charj/translator/Charj.g
src/langs/charj/src/charj/translator/CharjASTModifier.g
src/langs/charj/src/charj/translator/CharjASTModifier2.g
src/langs/charj/src/charj/translator/CharjEmitter.g

index bedf56248c1be2143a63c3098f807d284316cfd8..dfab5e090146a2d4448941b2be480bab58f214fd 100644 (file)
@@ -54,6 +54,9 @@ tokens {
     ENUM                    = 'enum'            ;
     READONLY                = 'readonly'        ;
 
+    OVERLAP                 = 'overlap'         ;
+    WHEN                    = 'when'            ;
+
     PRINT                   = 'print'           ;
     PRINTLN                 = 'println'         ;
     EXIT                    = 'exit'            ;
@@ -577,9 +580,17 @@ localVariableDeclaration
 
 statement
     :   nonBlockStatement
+    |   sdagStatement
     |   block
     ;
-        
+
+sdagStatement
+    :   OVERLAP block
+        -> ^(OVERLAP block)
+    |   WHEN IDENT '(' type IDENT ')' (',' '(' type IDENT ')')* block
+        -> ^(WHEN (IDENT type IDENT)+ block)
+    ;
+
 nonBlockStatement
     :   'assert' expr1=expression 
         (   ':' expr2=expression ';'
@@ -629,7 +640,6 @@ nonBlockStatement
         ->  ^(EXIT expression?)
     |   EXITALL '(' ')' ';'
         ->  EXITALL
-
     ;           
         
 
index 9c640adc2db1876c6cdce515debc9e77124c863d..f0cf7e1f566763bc711eb2e29b769a9a423aa367 100644 (file)
@@ -305,9 +305,15 @@ localVariableDeclaration
 
 statement
     :   nonBlockStatement
+    |   sdagStatement
     |   block
     ;
 
+sdagStatement
+    :   ^(OVERLAP block)
+    |   ^(WHEN (IDENT type IDENT)+ block)
+    ;
+
 nonBlockStatement
     :   ^(ASSERT expression expression?)
     |   ^(IF parenthesizedExpression block block?)
index 5b6ae40d408242d9a361c6362c0aa9f8a7d70fd4..1a0f7e0d3492af5b4f38aa5a81462f40d4a5a8dd 100644 (file)
@@ -320,9 +320,15 @@ localVariableDeclaration
 
 statement
     : nonBlockStatement
+    | sdagStatement
     | block
     ;
 
+sdagStatement
+    :   ^(OVERLAP block)
+    |   ^(WHEN (IDENT type IDENT)+ block)
+    ;
+
 nonBlockStatement
     :   ^(ASSERT expression expression?)
     |   ^(IF parenthesizedExpression block block?)
index 2a4c428fad881e7269a8ed05a77dc7e7c4c04779..5104d71417529aef788eee546643295db6eeb395 100644 (file)
@@ -668,10 +668,19 @@ localVariableDeclaration
 statement
     :   nonBlockStatement
         -> {$nonBlockStatement.st}
+    |   sdagStatement
+        -> {$sdagStatement.st}
     |   block
         -> {$block.st}
     ;
 
+sdagStatement
+    :   ^(OVERLAP block)
+        -> template(b={$block.st}) "/* !!overlap not implemented <block> */
+    |   ^(WHEN (IDENT type IDENT)+ block)
+        -> template(b={$block.st}) "/* !!when not implemented <block> */
+    ;
+
 nonBlockStatement
     :   ^(ASSERT cond=expression msg=expression?)
         -> assert(cond={$cond.st}, msg={$msg.st})