Exemplo n.º 1
0
def rvalue():
	debug('rvalue')
	
	if (lexer.lookahead().type == 'OPEN_PARANTHESIS'):
		expect_symbol('OPEN_PARANTHESIS')
		rvalue()
		expect_symbol('CLOSE_PARANTHESIS')
	elif (lexer.lookahead().type == 'CONSTANT'):
		expect_symbol('CONSTANT')
	else:
		lvalue()
		
	debug_end()
Exemplo n.º 2
0
def statement_list(): 
	debug('statement_list')
	
	if (not lexer.empty() and lexer.lookahead().type in block_first):
		block()
	else:
		statement()
		statement_list1()
	debug_end()
Exemplo n.º 3
0
def lvalue1():
	debug('lvalue1')
	follow = [ 'SEMICOLON', 'BINARY_OPERATOR', 'CLOSE_PARANTHESIS', 'COMMA' ]
	
	if (not lexer.empty() and lexer.lookahead().type in follow):
		return 
	else:
		expect_symbol('UNARY_OPERATOR')
	debug_end()
Exemplo n.º 4
0
def var_decl_list1():
	debug('var_decl_list1')
	follow = [ 'SEMICOLON' ]
	if (lexer.lookahead().type in follow):
		return 
		
	expect_symbol('COMMA')
	var_decl_list1()
	debug_end()
Exemplo n.º 5
0
def statement_list1():
	debug('statement_list1')
	follow = [ 'CLOSE_BRACE' ]
	
	if (not lexer.empty() and lexer.lookahead().type in follow):
		return
		
	statement()
	statement_list1()
	debug_end()
Exemplo n.º 6
0
def expression1():
	debug('expression1')
	follow = [ 'SEMICOLON', 'CLOSE_PARANTHESIS', 'COMMA' ]
	
	if (lexer.lookahead().type in follow):
		return
	
	expect_symbol('BINARY_OPERATOR')
	expression()
	debug_end()
Exemplo n.º 7
0
def lvalue():
	debug('lvalue')
	lookahead = lexer.lookahead()
	
	if (lookahead.type == 'ID'):
		expect_symbol('ID')
		lvalue1()
	else:
		expect_symbol('UNARY_OPERATOR')
		expect_symbol('ID')
	
	debug_end()
Exemplo n.º 8
0
def control_statement():
	debug('control_statement')
	lookahead = lexer.lookahead()
	
	if (lookahead.type in if_statement_first):
		if_statement()
	
	elif (lookahead.type in while_statement_first):
		while_statement()
	
	#elif (lookahead.type in for_statement_first):
	#  	for_statement()
	debug_end()
Exemplo n.º 9
0
def statement():
	debug('statement')
	lookahead = lexer.lookahead()
	if (lookahead.type in control_statement_first):
		control_statement() 
		
	elif (lookahead.type in expression_statement_first):
		expression_statement()
		
	elif (lookahead.type in return_statement_first):
		return_statement()
	
	elif (lookahead.type in variable_declaration_first):
		variable_declaration()
		
	debug_end()