void DoBlock(char Name) {
  Declarations();
  sprintf(tmp, "%c", Name);
  PostLabel("main");
  EmitLn("push rbp");
  Statements();
}
Beispiel #2
0
void Parser::Statements()
{
	if(look.kind == RETURN)
		return;
	Statement();
	Statements();
}
void Parser::Start() {
    // This is an example of a recursive-descent function for a
    // non-terminal symbol. In this case, it is just a placeholder
    // which accepts infinite numbers of T_PLUS. You will need to
    // replace this with correct code for the real grammar start symbol.
    Statements();
    
}
Beispiel #4
0
void Parser::Statement()
{
	switch(look.kind)
	{
	case LBRACE:
		Match(LBRACE);
		Statements();
		Match(RBRACE);
		return;
	case IF:
		Match(IF);
		Match(LPAREN);
		Exp();
		Match(RPAREN);
		Statement();
		Match(ELSE);
		Statement();
		return;
	case WHILE:
		Match(WHILE);
		Match(LPAREN);
		Exp();
		Match(RPAREN);
		Statement();
		return;
	case SYSTEM_OUT_PRINTLN:
		Match(SYSTEM_OUT_PRINTLN);
		Match(LPAREN);
		Exp();
		Match(RPAREN);
		Match(SEMICOLON);
		return;
	default:
		Id();
		switch(look.kind)
		{
		case EQ:
			Match(EQ);
			Exp();
			Match(SEMICOLON);
			return;
		case LBRACK:
			Match(LBRACK);
			Exp();
			Match(RBRACK);
			Match(EQ);
			Exp();
			Match(SEMICOLON);
			return;
		}
		return;
	}
}
Beispiel #5
0
void Parser::MethodDecl()
{
	Match(PUBLIC);
	Type();
	Id();
	Match(LPAREN);
	FormalList();
	Match(RPAREN);
	Match(LBRACE);
	VarDecls();
	Statements();
	Match(RETURN);
	Exp();
	Match(SEMICOLON);
	Match(RBRACE);
}
Beispiel #6
0
void DoBlock(char name){
    Declarations();
    PostLabel(name);
    Statements();
}