def booleanExpression(self): tree = Lexeme(token_type="BOOLEAN_EXPRESSION") tmp = Lexeme(token_type="GLUE") tmp.left = self.expression() self.match("IS") tree.left = self.boolOp() tmp.right = self.expression() tree.right = tmp return tree
def ifStatement(self): if self._debug: print(" in ifStatement") self.match("IF") tree = Lexeme(token_type="IF_STATEMENT") tmp = Lexeme(token_type="GLUE") tree.left = self.booleanExpression() self.match("COMMA") tmp.left = self.block() tmp.right = self.optOtherwise() tree.right = tmp return tree
def statements(self): if self._debug: print(" in statements") tree = Lexeme(token_type="STATEMENTS") tree.left = self.statement() tree.right = self.optStatements() return tree
def commaChain(self): if self._debug: print(" in commaChain") self.match("COMMA") tree = Lexeme(token_type="GLUE") tree.left = self.expression() tree.right = self.optCommaChain() return tree
def whileStatement(self): if self._debug: print(" in whileStatement") self.match("WHILE") tree = Lexeme(token_type="WHILE_STATEMENT") tree.left = self.booleanExpression() self.match("COMMA") tree.right = self.block() return tree
def assignment(self): if self._debug: print(" in assignment") self.match("SET") tree = Lexeme(token_type="ASSIGNMENT") tree.left = self.match("VARIABLE") self.match("TO") tree.right = self.expression() self.match("PERIOD") return tree
def sequence(self): if self._debug: print(" in sequence") tree = Lexeme(token_type="GLUE") # this will be attached to the "head" in my environment tree.left = self.expression() if self.check("AND"): self.match("AND") tmp = Lexeme(token_type="GLUE") tmp.left = self.expression() tree.right = tmp elif self.commaChainPending(): tmp = self.commaChain() self.match("AND") tracer = tmp while tracer.right: tracer = tracer.right tracer.left = self.expression() tree.right = tmp return tree
def optCommaChain(self): if self._debug: print(" in optCommaChain") tree = None if self.check("COMMA"): tree = Lexeme(token_type="GLUE") self.match("COMMA") if self.expressionPending(): tree.left = self.expression() tree.right = self.optCommaChain() return tree
def sequence(self): if self._debug: print(" in sequence") tree = Lexeme(token_type="LIST") tree.left = self.expression() if self.check("AND"): self.match("AND") tmp = Lexeme(token_type="GLUE") tmp.left = self.expression() tree.right = tmp elif self.commaChainPending(): tmp = self.commaChain() self.match("AND") tracer = tmp while tracer.right: tracer = tracer.right tmp2 = Lexeme(token_type="GLUE") tmp2.left = self.expression() tracer.right = tmp2 tree.right = tmp return tree