def function2(self, tokens): if tokens[0] != "Varname" or tokens[1] != "MapsTo": return mapsto = tokens[1] mapsto.parameters.append(tokens[0].raw) # TODO: allow several parameters tokens.popleft() tokens.popleft() mapsto.expressions = self.expressions(tokens) return mapsto
def call(self, tokens): path = [] popped = False while tokens[0] == "Varname" and tokens[1] == "Dot": path.append(tokens[0].raw) tokens.popleft() tokens.popleft() popped = True if not tokens[0] == "Varname" or not tokens[1] == "LeftBrace": if popped: raise Exception("Malformed funcion call!") else: return path.append(tokens[0].raw) tokens.popleft() tokens.popleft() args = [] while len(tokens) > 0 and tokens[0] != "RightBrace": args.append(self.expression(tokens)) if tokens[0] == "Comma": tokens.popleft() if tokens[0] == "RightBrace": tokens.popleft() else: raise Exception("Malformed function call!") return Call(path, args)