diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg @ 7848:698cd036a1ca

Added a ternary operator to simple language to test short circuit specialization.
author Christian Humer <christian.humer@gmail.com>
date Tue, 19 Feb 2013 17:27:02 +0100
parents 442668d41bc2
children b6a87711eca0
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg	Tue Feb 19 17:20:45 2013 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg	Tue Feb 19 17:27:02 2013 +0100
@@ -131,11 +131,19 @@
 |
     NumericLiteral<out result>
 |
+	Ternary<out result>  
+|
     "(" Expression<out result> ")"
-)
+) 
 .
 
-TimeRef<out TypedNode result>
+Ternary<out TypedNode result>					(. TypedNode condition, thenPart, elsePart; .)
+=
+"#" Expression<out condition> "?" Expression<out thenPart> ":" Expression<out elsePart>
+												(. result = factory.createTernary(condition, thenPart, elsePart); .)
+.
+
+TimeRef<out TypedNode result> 
 =
 "time"                                          (. result = factory.createTime(); .)
 .