Exemple #1
0
	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
Exemple #2
0
	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
Exemple #3
0
	def statements(self):
		if self._debug: print(" in statements")
		tree = Lexeme(token_type="STATEMENTS")
		tree.left = self.statement()
		tree.right = self.optStatements()

		return tree
Exemple #4
0
	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
Exemple #5
0
	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
Exemple #6
0
	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
Exemple #7
0
	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
Exemple #8
0
	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
Exemple #9
0
	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