Charj : added support for exit and exitAll (exit and CkExit)
authorMinas Charalambides <charala1@illinois.edu>
Wed, 2 Jun 2010 20:11:18 +0000 (15:11 -0500)
committerMinas Charalambides <charala1@illinois.edu>
Wed, 2 Jun 2010 20:11:18 +0000 (15:11 -0500)
src/langs/charj/src/charj/translator/Charj.g
src/langs/charj/src/charj/translator/Charj.stg
src/langs/charj/src/charj/translator/CharjASTModifier.g
src/langs/charj/src/charj/translator/CharjEmitter.g
src/langs/charj/src/charj/translator/CharjSemantics.g

index 2218a1a513c9e24570c13805873c7d922c2bd4a8..536d6190c447738c5519c92a70210a391fe39c93 100644 (file)
@@ -56,6 +56,8 @@ tokens {
 
     PRINT                   = 'print'           ;
     PRINTLN                 = 'println'         ;
+    EXIT                    = 'exit'            ;
+    EXITALL                 = 'exitAll'         ;
 
     FOR                     = 'for'             ;
     WHILE                   = 'while'           ;
@@ -585,6 +587,10 @@ nonBlockStatement
         ->  ^(PRINT expression*)
     |   PRINTLN '(' (expression (',' expression)*)* ')' ';'
         ->  ^(PRINTLN expression*)
+    |   EXIT '(' expression? ')' ';'
+        ->  ^(EXIT expression?)
+    |   EXITALL '(' ')' ';'
+        ->  EXITALL
     ;           
         
 
index 55d88a7d62badc1148ba904839a06f624e5ae2d6..dad56dbe0c4b0ceb4d8d2f2c72b3b34abb46d677 100644 (file)
@@ -485,4 +485,13 @@ println(exprs) ::=
 cout<if(first(exprs))> <exprs : { n | \<\< <n> }><else> <endif>\<\< endl;
 >>
 
+exit(expr) ::=
+<<
+exit(<expr>);
+>>
+
+exitall() ::=
+<<
+CkExit();
+>>
 
index 72b812f1aba8282c6d5f378eeb00ed3a5bd6a792..faa6c93729d37fcf52ceba48b74aa283ff2680f2 100644 (file)
@@ -309,6 +309,8 @@ nonBlockStatement
     |   ';' // Empty statement.
     |   ^(PRINT expression*)
     |   ^(PRINTLN expression*)
+    |   ^(EXIT expression?)
+    |   EXITALL
     ;
         
 switchCaseLabel
index 92d485cedd98915f47c690323b0495c03576a1c8..2fa9d3666f433eb031f5048844500a4e723a5fab 100644 (file)
@@ -591,6 +591,10 @@ nonBlockStatement
         ->  print(exprs = {$exprs})
     |   ^(PRINTLN (exprs += expression)*)
         ->  println(exprs = {$exprs})
+    |   ^(EXIT expression?)
+        ->  exit(expr = {$expression.st})
+    |   EXITALL
+        ->  exitall()
     ;
         
 switchCaseLabel
index 6ac5cb500bc6bbeb13747f5296263ff916a2116c..009c47ced6a6a5eac1aa2ae40b07462616163acb 100644 (file)
@@ -448,6 +448,8 @@ nonBlockStatement
     |   ';' // Empty statement.
     |   ^(PRINT expression*)
     |   ^(PRINTLN expression*)
+    |   ^(EXIT expression?)
+    |   EXITALL
     ;
         
 switchCaseLabel