Title: [1128] trunk/qdox/src/grammar/parser.y: Rename/reformat literal
Revision
1128
Author
rfscholte
Date
2011-03-22 16:06:04 -0500 (Tue, 22 Mar 2011)

Log Message

Rename/reformat literal
Redefine MethodDeclaration

Modified Paths


Diff

Modified: trunk/qdox/src/grammar/parser.y (1127 => 1128)

--- trunk/qdox/src/grammar/parser.y	2011-03-21 22:16:27 UTC (rev 1127)
+++ trunk/qdox/src/grammar/parser.y	2011-03-22 21:06:04 UTC (rev 1128)
@@ -56,7 +56,7 @@
 %type <type> PrimitiveType NumericType IntegralType FloatingPointType
 %type <type> InterfaceType
 %type <type> Wildcard
-%type <annoval> _expression_ literal Annotation ElementValue ElementValueArrayInitializer
+%type <annoval> _expression_ Literal Annotation ElementValue ElementValueArrayInitializer
 %type <annoval> ConditionalExpression ConditionalOrExpression ConditionalAndExpression InclusiveOrExpression ExclusiveOrExpression AndExpression
 %type <annoval> EqualityExpression RelationalExpression ShiftExpression AdditiveExpression MultiplicativeExpression
 %type <annoval> UnaryExpression UnaryExpressionNotPlusMinus primary
@@ -303,9 +303,24 @@
               | PARENOPEN typename dims PARENCLOSE UnaryExpressionNotPlusMinus  { $$ = new AnnotationCast(new TypeDef($2, $3), $5); };
 
 PostfixExpression: primary;
-    	
+
+//Primary: PrimaryNoNewArray
+//       | ArrayCreationExpression;
+       
+//PrimaryNoNewArray: Literal
+//                 | Type DOT CLASS
+//                 | VOID DOT CLASS
+//                 | THIS
+//        ClassName.this
+//        ( _expression_ )
+//        ClassInstanceCreationExpression
+//        FieldAccess
+//        MethodInvocation
+//        ArrayAccess
+       
+
 primary:
-    literal |
+    Literal |
     PARENOPEN _expression_ PARENCLOSE { $$ = new AnnotationParenExpression($2); } |
     PrimitiveType Dims_opt DOT CLASS { $$ = new AnnotationTypeRef(new TypeDef($1.name, $2)); } |
     typename DOT CLASS { $$ = new AnnotationTypeRef(new TypeDef($1, 0)); } |
@@ -318,14 +333,36 @@
     SQUAREOPEN SQUARECLOSE { $$ = 1; } |
     dims SQUAREOPEN SQUARECLOSE { $$ = $1 + 1; };
 	
-literal:
-    DOUBLE_LITERAL { $$ = new AnnotationConstant(toDouble($1), $1); } |
-    FLOAT_LITERAL { $$ = new AnnotationConstant(toFloat($1), $1); } |
-    LONG_LITERAL { $$ = new AnnotationConstant(toLong($1), $1); } |
-    INTEGER_LITERAL { $$ = new AnnotationConstant(toInteger($1), $1); } |
-    BOOLEAN_LITERAL { $$ = new AnnotationConstant(toBoolean($1), $1); } |
-    CHAR_LITERAL { String s = lexer.getCodeBody(); $$ = new AnnotationConstant(toChar(s), s); } |
-    STRING_LITERAL { String s = lexer.getCodeBody(); $$ = new AnnotationConstant(toString(s), s); };
+Literal: INTEGER_LITERAL
+         { 
+           $$ = new AnnotationConstant(toInteger($1), $1); 
+         } 
+       | LONG_LITERAL 
+         { 
+           $$ = new AnnotationConstant(toLong($1), $1); 
+         } 
+       | FLOAT_LITERAL 
+         { 
+           $$ = new AnnotationConstant(toFloat($1), $1); 
+         } 
+       | DOUBLE_LITERAL 
+         { 
+           $$ = new AnnotationConstant(toDouble($1), $1);
+         } 
+       | BOOLEAN_LITERAL 
+         { 
+           $$ = new AnnotationConstant(toBoolean($1), $1);
+         } 
+       | CHAR_LITERAL 
+         {
+           String s = lexer.getCodeBody(); 
+           $$ = new AnnotationConstant(toChar(s), s); 
+         } 
+       | STRING_LITERAL 
+         { 
+           String s = lexer.getCodeBody(); 
+           $$ = new AnnotationConstant(toString(s), s); 
+         };
         
 PrimitiveType:
 	NumericType |
@@ -590,34 +627,39 @@
                         $$ = new TypeDef($1,$2);
                       };
 
-// ----- METHOD
+// 8.4 Method Declarations
+MethodDeclaration: MethodHeader memberend /* =MethodBody*/ 
+                   {
+                     mth.body = $2;
+                     builder.endMethod(mth);
+                     mth = new MethodDef();
+                   };
 
-MethodDeclaration:
-    AnyModifiers_opt TypeParameters Type /* =ResultType */ IDENTIFIER {
-        builder.beginMethod();
-        mth.lineNumber = lexer.getLine();
-        mth.modifiers.addAll(modifiers); modifiers.clear(); 
-        mth.typeParams = typeParams;
-        mth.returnType = $3;
-        mth.name = $4;
-    } methoddef Dims_opt Throws_opt memberend /* =MethodBody */ {
-        mth.dimensions = $7;
-        mth.body = $9;
-        builder.endMethod(mth);
-        mth = new MethodDef(); 
-    } |
-    AnyModifiers_opt Type /* =ResultType */ IDENTIFIER {
-        builder.beginMethod();
-        mth.lineNumber = lexer.getLine();
-        mth.modifiers.addAll(modifiers); modifiers.clear();
-        mth.returnType = $2;
-        mth.name = $3;
-    } methoddef Dims_opt Throws_opt memberend /* =MethodBody */ {
-        mth.dimensions = $6;
-        mth.body = $8;
-        builder.endMethod(mth);
-        mth = new MethodDef();
-    };
+MethodHeader: AnyModifiers_opt TypeParameters Type /* =ResultType */ IDENTIFIER 
+              {
+                builder.beginMethod();
+                mth.lineNumber = lexer.getLine();
+                mth.modifiers.addAll(modifiers); modifiers.clear();
+                mth.typeParams = typeParams;
+                mth.returnType = $3;
+                mth.name = $4;
+              } 
+              methoddef Dims_opt Throws_opt
+              {
+                mth.dimensions = $7;
+              } 
+            | AnyModifiers_opt Type /* =ResultType */ IDENTIFIER 
+              {
+                builder.beginMethod();
+                mth.lineNumber = lexer.getLine();
+                mth.modifiers.addAll(modifiers); modifiers.clear();
+                mth.returnType = $2;
+                mth.name = $3;
+              } 
+              methoddef Dims_opt Throws_opt 
+              {
+                mth.dimensions = $6;
+              };
 
 constructor:
     AnyModifiers_opt IDENTIFIER {


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to