commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r809312 - /commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/parser/Parser.jjt
Date Sun, 30 Aug 2009 11:09:20 GMT
Author: henrib
Date: Sun Aug 30 11:09:20 2009
New Revision: 809312

URL: http://svn.apache.org/viewvc?rev=809312&view=rev
Log:
No functional change, just a reordering to make grammar easier to follow and maintain.

Modified:
    commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/parser/Parser.jjt

Modified: commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/parser/Parser.jjt
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/parser/Parser.jjt?rev=809312&r1=809311&r2=809312&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/parser/Parser.jjt
(original)
+++ commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/parser/Parser.jjt
Sun Aug 30 11:09:20 2009
@@ -30,7 +30,6 @@
    STATIC=false;
    VISITOR=true;
    NODE_CLASS="JexlNode";
-   NODE_USES_PARSER=true;
    UNICODE_INPUT=true;
 }
 
@@ -86,7 +85,7 @@
 
 
 /***************************************
- *      Program
+ *      Statements
  ***************************************/
 
 ASTJexlScript JexlScript() : {}
@@ -96,32 +95,52 @@
 }
 
 
+void Statement() #void : {}
+{
+    ";"
+    | LOOKAHEAD(3) Block()
+    | IfStatement()
+    | ForeachStatement()
+    | WhileStatement()
+    | ExpressionStatement()
+}
+
 void Block() #Block : {}
 {
     "{" ( Statement() )* "}"
 }
 
-void EmptyFunction() : {}
+
+void ExpressionStatement() #void : {}
 {
-    "empty"
-    ( Reference() | "(" Expression() ")" )
+    Expression() (LOOKAHEAD(2) ";")?
 }
 
-void SizeFunction() : {}
+
+void IfStatement() : {}
 {
-    "size" "(" Expression() ")"
+    "if" "(" Expression() ")" Statement() ( LOOKAHEAD(1) "else" Statement() )?
 }
 
-void Identifier() :
+
+void WhileStatement() : {}
 {
-   Token t;
+  "while" "(" Expression() ")" Statement()
 }
+
+
+void ForeachStatement() : {}
 {
-    t=<IDENTIFIER>
-    { jjtThis.image = t.image; }
+    "for" "(" Reference() ":"  Expression() ")" Statement()
+|
+    "foreach" "(" Reference() "in"  Expression() ")" Statement()
 }
 
 
+/***************************************
+ *      Expression syntax
+ ***************************************/
+
 void Expression() #void : {}
 {
     LOOKAHEAD( Reference() "=" )  Assignment()
@@ -132,7 +151,7 @@
 
 void Assignment() #Assignment(2) : {}
 {
-  Reference() "=" Expression()
+    Reference() "=" Expression()
 }
 
 /***************************************
@@ -246,8 +265,7 @@
     "-" { jjtThis.image = "-"; }
 }
 
-void MultiplicativeExpression() #void :
-{}
+void MultiplicativeExpression() #void : {}
 {
   UnaryExpression()
   (
@@ -263,8 +281,7 @@
   )?
 }
 
-void UnaryExpression() #void :
-{}
+void UnaryExpression() #void : {}
 {
   "-" UnaryExpression() #UnaryMinusNode(1)
 |
@@ -277,30 +294,20 @@
   PrimaryExpression()
 }
 
-void PrimaryExpression() #void : {}
-{
-  Literal()
-|
-  LOOKAHEAD(3)  Reference()
-|
-  LOOKAHEAD("(") "(" Expression() ")"
-|
-  LOOKAHEAD("empty") EmptyFunction()
-|
-  LOOKAHEAD("size") SizeFunction()
-|
-  LOOKAHEAD("new" "(") Constructor()
-|
-  LOOKAHEAD( "{" MapEntry() ) MapLiteral()
-|
-  LOOKAHEAD( "[" Expression() ) ArrayLiteral()
-}
-
 
 /***************************************
- *      Literals
+ *      Identifier & Literals
  ***************************************/
 
+void Identifier() :
+{
+    Token t;
+}
+{
+    t=<IDENTIFIER>
+    { jjtThis.image = t.image; }
+}
+
 void Literal() #void :
 {
    Token t;
@@ -357,58 +364,42 @@
   { jjtThis.image = Parser.buildString(t.image, true); }
 }
 
-/***************************************
- *      Statements
- ***************************************/
-
-void Statement() #void : {}
+void ArrayLiteral() : {}
 {
-    ";"
-    | LOOKAHEAD(3) Block()
-    | IfStatement()
-    | ForeachStatement()
-    | WhileStatement()
-    | ExpressionStatement()
+  "[" Expression() ( "," Expression() )* "]"
 }
 
-
-void ExpressionStatement() #void : {}
+void MapLiteral() : {}
 {
-    Expression() (LOOKAHEAD(2) ";")?
+    "{"  MapEntry() ( "," MapEntry() )* "}"
 }
 
-
-void IfStatement() : {}
+void MapEntry() : {}
 {
-    "if" "(" Expression() ")" Statement() ( LOOKAHEAD(1) "else" Statement() )?
+    Expression() ":" Expression()
 }
 
 
-void WhileStatement() : {}
-{
-  "while" "(" Expression() ")" Statement()
-}
+/***************************************
+ *      Functions & Methods
+ ***************************************/
 
-void ForeachStatement() : {}
+void EmptyFunction() : {}
 {
-    "for" "(" Reference() ":"  Expression() ")" Statement()
+    LOOKAHEAD(3) "empty" "(" Expression() ")"
 |
-    "foreach" "(" Reference() "in"  Expression() ")" Statement()
+    "empty" Reference()
 }
 
-void ArrayLiteral() : {}
+void SizeFunction() : {}
 {
-  "[" Expression() ( "," Expression() )* "]"
+    "size" "(" Expression() ")"
 }
 
-void MapLiteral() : {}
+void Function() #FunctionNode: {}
 {
-    "{"  MapEntry() ( "," MapEntry() )* "}"
-}
 
-void MapEntry() : {}
-{
-    Expression() ":" Expression()
+   Identifier() ":" Identifier() "("[ Expression() ( "," Expression() )* ] ")"
 }
 
 void Method() #MethodNode: {}
@@ -416,16 +407,6 @@
    Identifier() "("[ Expression() ( "," Expression() )* ] ")"
 }
 
-void Function() #FunctionNode: {}
-{
-   Identifier() ":" Identifier() "("[ Expression() ( "," Expression() )* ] ")"
-}
-
-void ArrayAccess() : {}
-{
-   Identifier() (LOOKAHEAD(2) "[" Expression() "]")+
-}
-
 void AnyMethod() #void : {}
 {
     LOOKAHEAD("size") SizeMethod()
@@ -433,31 +414,44 @@
     LOOKAHEAD(Identifier() "(") Method()
 }
 
-void Constructor() # ConstructorNode() : {}
+void SizeMethod() : {}
 {
-  "new" "("[ Expression() ( "," Expression() )* ] ")"
+    "size" "(" ")"
 }
 
-void SizeMethod() : {}
+void Constructor() # ConstructorNode() : {}
 {
-    "size" "(" ")"
+  "new" "("[ Expression() ( "," Expression() )* ] ")"
 }
 
-void Reference() : {}
+
+/***************************************
+ *     References
+ ***************************************/
+
+void PrimaryExpression() #void : {}
 {
-  ( LOOKAHEAD("new") Constructor()
+  Literal()
 |
-   LOOKAHEAD(Identifier() "[" ) ArrayAccess()
+  LOOKAHEAD(3)  Reference()
 |
-   LOOKAHEAD(Identifier() ":" Identifier() "(") Function()
+  LOOKAHEAD("(") "(" Expression() ")"
 |
-   LOOKAHEAD(Identifier() "(") Method()
+  LOOKAHEAD("empty") EmptyFunction()
 |
-   Identifier()
+  LOOKAHEAD("size") SizeFunction()
 |
-   LOOKAHEAD("{") MapLiteral()
+  LOOKAHEAD("new" "(") Constructor()
 |
-   LOOKAHEAD("[") ArrayLiteral() ) DotReference()
+  LOOKAHEAD( "{" MapEntry() ) MapLiteral()
+|
+  LOOKAHEAD( "[" Expression() ) ArrayLiteral()
+}
+
+
+void ArrayAccess() : {}
+{
+    Identifier() (LOOKAHEAD(2) "[" Expression() "]")+
 }
 
 void DotReference() #void : {}
@@ -477,6 +471,22 @@
   )*
 }
 
+void Reference() : {}
+{
+  ( LOOKAHEAD("new") Constructor()
+|
+   LOOKAHEAD(Identifier() "[" ) ArrayAccess()
+|
+   LOOKAHEAD(Identifier() ":" Identifier() "(") Function()
+|
+   LOOKAHEAD(Identifier() "(") Method()
+|
+   Identifier()
+|
+   LOOKAHEAD("{") MapLiteral()
+|
+   LOOKAHEAD("[") ArrayLiteral() ) DotReference()
+}
 
 /***************************************
  *     Identifier & String tokens



Mime
View raw message