You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2009/12/10 09:52:09 UTC

svn commit: r889142 - /commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/parser/Parser.jjt

Author: henrib
Date: Thu Dec 10 08:51:55 2009
New Revision: 889142

URL: http://svn.apache.org/viewvc?rev=889142&view=rev
Log:
changed parser so that 'in' is only a keyword in a 'foreach' expression; made (principal) keywords explicit in parser

Modified:
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/parser/Parser.jjt

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/parser/Parser.jjt
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/parser/Parser.jjt?rev=889142&r1=889141&r2=889142&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/parser/Parser.jjt (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/parser/Parser.jjt Thu Dec 10 08:51:55 2009
@@ -101,6 +101,26 @@
 }
 
 
+TOKEN : /* KEYWORDS */
+{
+      < IF : "if" >
+    | < ELSE : "else" >
+    | < FOR : "for" >
+    | < FOREACH : "foreach" > : FOR_EACH_IN
+    | < WHILE : "while" >
+    | < NEW : "new" >
+    | < EMPTY : "empty" >
+    | < SIZE : "size" >
+    | < NULL : "null" >
+    | < TRUE : "true" >
+    | < FALSE : "false" >
+}
+
+<FOR_EACH_IN> TOKEN : /* foreach in */
+{
+    < IN : "in" > : DEFAULT
+}
+
 /***************************************
  *      Statements
  ***************************************/
@@ -136,21 +156,21 @@
 
 void IfStatement() : {}
 {
-    "if" "(" Expression() ")" Statement() ( LOOKAHEAD(1) "else" Statement() )?
+    <IF> "(" Expression() ")" Statement() ( LOOKAHEAD(1) <ELSE> Statement() )?
 }
 
 
 void WhileStatement() : {}
 {
-  "while" "(" Expression() ")" Statement()
+    <WHILE> "(" Expression() ")" Statement()
 }
 
 
 void ForeachStatement() : {}
 {
-    "for" "(" Reference() ":"  Expression() ")" Statement()
+    <FOR> "(" Reference() ":"  Expression() ")" Statement()
 |
-    "foreach" "(" Reference() "in"  Expression() ")" Statement()
+    <FOREACH> "(" Reference() <IN>  Expression() ")" Statement()
 }
 
 
@@ -343,15 +363,15 @@
 
 void NullLiteral() : {}
 {
-    "null"
+    <NULL>
 }
 
 void BooleanLiteral() #void :
 {}
 {
-  "true" #TrueNode
+  <TRUE> #TrueNode
 |
-  "false" #FalseNode
+  <FALSE> #FalseNode
 }
 
 void IntegerLiteral() :
@@ -403,14 +423,14 @@
 
 void EmptyFunction() : {}
 {
-    LOOKAHEAD(3) "empty" "(" Expression() ")"
+    LOOKAHEAD(3) <EMPTY> "(" Expression() ")"
 |
-    "empty" Reference()
+    <EMPTY> Reference()
 }
 
 void SizeFunction() : {}
 {
-    "size" "(" Expression() ")"
+    <SIZE> "(" Expression() ")"
 }
 
 void Function() #FunctionNode: {}
@@ -426,19 +446,19 @@
 
 void AnyMethod() #void : {}
 {
-    LOOKAHEAD("size") SizeMethod()
+    LOOKAHEAD(<SIZE>) SizeMethod()
   |
     LOOKAHEAD(Identifier() "(") Method()
 }
 
 void SizeMethod() : {}
 {
-    "size" "(" ")"
+    <SIZE> "(" ")"
 }
 
 void Constructor() # ConstructorNode() : {}
 {
-  "new" "("[ Expression() ( "," Expression() )* ] ")"
+  <NEW> "("[ Expression() ( "," Expression() )* ] ")"
 }
 
 
@@ -454,11 +474,11 @@
 |
   LOOKAHEAD("(") "(" Expression() ")"
 |
-  LOOKAHEAD("empty") EmptyFunction()
+  LOOKAHEAD(<EMPTY>) EmptyFunction()
 |
-  LOOKAHEAD("size") SizeFunction()
+  LOOKAHEAD(<SIZE>) SizeFunction()
 |
-  LOOKAHEAD("new" "(") Constructor()
+  LOOKAHEAD(<NEW> "(") Constructor()
 |
   LOOKAHEAD( "{" MapEntry() ) MapLiteral()
 |
@@ -490,7 +510,7 @@
 
 void Reference() : {}
 {
-  ( LOOKAHEAD("new") Constructor()
+  ( LOOKAHEAD(<NEW>) Constructor()
 |
    LOOKAHEAD(Identifier() "[" ) ArrayAccess()
 |