@@ -118,7 +118,10 @@ def makeAcceptType(ft):
118118 """ Creates an accept function for the given factory type. """
119119 def acceptType (self , node , memo ):
120120 """ Creates and returns a new template for a type. """
121- name = node .firstChildOfType (tokens .IDENT ).text
121+ try :
122+ name = node .firstChildOfType (tokens .IDENT ).text
123+ except (AttributeError , ):
124+ return
122125 self .variables .append (name )
123126 return getattr (self .factory , ft )(name = name , parent = self )
124127 return acceptType
@@ -201,9 +204,15 @@ def acceptVarDeclaration(self, node, memo):
201204 for varDecl in varDecls .childrenOfType (tokens .VAR_DECLARATOR ):
202205 ident = varDecl .firstChildOfType (tokens .IDENT )
203206 self .variables .append (ident .text )
207+
204208 identExp = self .factory .expr (left = ident .text , parent = self )
209+ identExp .type = self .nodeTypeToString (node )
210+ if node .firstChildOfType (tokens .MODIFIER_LIST ):
211+ identExp .modifiers = [child .text for child in node .firstChildOfType (tokens .MODIFIER_LIST ).children ]
212+
205213 declExp = varDecl .firstChildOfType (tokens .EXPR )
206214 assgnExp = identExp .pushRight (' = ' )
215+
207216 declArr = varDecl .firstChildOfType (tokens .ARRAY_INITIALIZER )
208217 if declExp :
209218 assgnExp .walk (declExp , memo )
@@ -219,8 +228,7 @@ def acceptVarDeclaration(self, node, memo):
219228 if node .firstChildOfType (tokens .TYPE ).firstChildOfType (tokens .ARRAY_DECLARATOR_LIST ):
220229 val = assgnExp .pushRight ('[]' )
221230 else :
222- typ = self .nodeTypeToString (node )
223- val = assgnExp .pushRight ('{0}()' .format (typ ))
231+ val = assgnExp .pushRight ('{0}()' .format (identExp .type ))
224232 return self
225233
226234
0 commit comments