def varvalu(self): ''' $foo $foo.bar $foo.bar() $foo[0] $foo.bar(10) ''' self.ignore(whitespace) varn = self.varname() varv = s_ast.VarValue(kids=[varn]) # handle derefs and calls... while self.more(): if self.nextstr('.'): varv = self.varderef(varv) continue if self.nextstr('('): varv = self.varcall(varv) continue #if self.nextstr('['): #varv = self.varslice(varv) break return varv
def varderef(self, kids): assert kids and len(kids) == 2 newkid = kids[1] if newkid[0] == '$': tokencls = terminalClassMap.get(newkid.type, s_ast.Const) newkid = s_ast.VarValue(kids=[tokencls(newkid[1:])]) else: newkid = self._convert_child(kids[1]) return s_ast.VarDeref(kids=(kids[0], newkid))
def _tagsplit(cls, tag): if '$' not in tag: return [s_ast.Const(tag)] segs = tag.split('.') kids = [ s_ast.VarValue(kids=[s_ast.Const(seg[1:])]) if seg[0] == '$' else s_ast.Const(seg) for seg in segs ] return kids