Minor refactoring of Parser (formal parameters) development
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 02 Sep 2013 09:57:12 +0100
branchdevelopment
changeset 2702 e6ebebcddbec
parent 2701 44a062d9aae8
child 2703 cec245f60b30
Minor refactoring of Parser (formal parameters)
tools/JavaParser.st
tools/JavaParserII.st
--- a/tools/JavaParser.st	Mon Sep 02 01:02:26 2013 +0100
+++ b/tools/JavaParser.st	Mon Sep 02 09:57:12 2013 +0100
@@ -110,6 +110,16 @@
     "Created: / 24-08-2013 / 01:40:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+formalParameters 
+
+"/        ^ (self tokenFor: '(') ,
+"/        formalParameterDecls optional ,
+"/        (self tokenFor: ')')
+    ^ super formalParameters ==> [:nodes | nodes second ]
+
+    "Created: / 31-08-2013 / 23:09:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 normalClassDeclaration 
     "
         ^ classModifiers , (self  classKW) , self typeNameIdentifier ,
@@ -128,6 +138,32 @@
     ]
 
     "Created: / 04-04-2013 / 00:04:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+normalParameterDecls
+"/    ^ normalParameterDecl , ((self tokenFor: ',') , normalParameterDecl) star
+    ^ super normalParameterDecls ==> [:nodes|
+"/        | params |
+"/
+"/        params := OrderedCollection new.
+"/        params add: nodes first.
+"/        nodes second do:[:pair|
+"/            params add: pair second
+"/        ].
+"/        params.
+        nodes.
+    ].
+
+    "Created: / 01-09-2013 / 09:30:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+normalParameterDeclsAndEllipsisParameterDecl
+"/    ^ normalParameterDecls , (self tokenFor: ',') , ellipsisParameterDecl
+    ^ super normalParameterDeclsAndEllipsisParameterDecl ==> [:nodes |
+        nodes first copyWith: nodes third.
+    ]
+
+    "Created: / 01-09-2013 / 09:29:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaParser methodsFor:'grammar-classes-method'!
--- a/tools/JavaParserII.st	Mon Sep 02 01:02:26 2013 +0100
+++ b/tools/JavaParserII.st	Mon Sep 02 09:57:12 2013 +0100
@@ -41,7 +41,8 @@
 		arrayCreator createdName arrayInitializer constructorDeclaration
 		constructorModifiers methodNotConstructorDeclaration wildcard
 		emptySquaredParenthesis methodModifierNotAnnotation
-		classModifierNotAnnotation classInitializer methodBody'
+		classModifierNotAnnotation classInitializer methodBody
+		normalParameterDeclsAndEllipsisParameterDecl normalParameterDecls'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Languages-Java-Parser'
@@ -464,15 +465,20 @@
 !
 
 formalParameterDecls
-	
-	^ ellipsisParameterDecl
+
+    ^ ellipsisParameterDecl
+        / normalParameterDeclsAndEllipsisParameterDecl
+        / normalParameterDecls optional
+
 
-    /   ((normalParameterDecl , 
-		(self tokenFor: ',')) plus , 
-		ellipsisParameterDecl)
-		
-    /   (normalParameterDecl , 
-		((self tokenFor: ',') , normalParameterDecl) star)
+"/    /   ((normalParameterDecl , 
+"/                (self tokenFor: ',')) plus , 
+"/                ellipsisParameterDecl)
+"/                
+"/    /   (normalParameterDecl , 
+"/                ((self tokenFor: ',') , normalParameterDecl) star)
+
+    "Modified: / 01-09-2013 / 03:17:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 formalParameters 
@@ -503,6 +509,18 @@
     "Modified: / 15-03-2012 / 09:01:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+normalParameterDecls
+    ^ normalParameterDecl , ((self tokenFor: ',') , normalParameterDecl) star
+
+    "Created: / 01-09-2013 / 03:18:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+normalParameterDeclsAndEllipsisParameterDecl
+    ^ normalParameterDecls , (self tokenFor: ',') , ellipsisParameterDecl
+
+    "Created: / 01-09-2013 / 03:16:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 primitiveType 
 
 	^ (self  booleanKW)