Ejemplo n.º 1
0
void Parser::VarList()
{
	ExprRec var, index;
	/* Listen to the first variable */
	Variable(var, index);
	code.ProcessVar(var, index); /*** CODE ***/
	code.Listen(var, index); /*** CODE ***/
	/* Listen for the next variables */
	VarListTail(var, index);
}
Ejemplo n.º 2
0
void Parser::ForAssign()
{
	/* Variable to be assigned a value */
	ExprRec var, index;
	Variable(var, index);
	code.ProcessVar(var, index);
	/* Equal sign '=' */
	Match(ASSIGN_OP);
	/* Value/Expression to assign to the variable */
	ExprRec result;
	Expression(result);
	code.ForAssign(var, index, result);
}
Ejemplo n.º 3
0
void Parser::AssignStmt()
{
	/* Variable to be assigned a value */
	ExprRec var, index;
	Variable(var, index);
	code.ProcessVar(var, index);
	/* Equal sign '=' */
	Match(ASSIGN_OP);
	/* Value/Expression to assign to the variable */
	ExprRec result;
	AssignTail(result);
	code.Assign(var, index, result);
	Match(SEMICOLON);
}
Ejemplo n.º 4
0
void Parser::VarListTail(ExprRec& var, ExprRec& index) {
	switch (NextToken()) {
	case COMMA:
		Match(COMMA);
		Variable(var, index);
		code.ProcessVar(var, index); /*** CODE ***/
		code.Listen(var, index); /*** CODE ***/
		/* Recursion for other variables */
		VarListTail(var, index);
		break;
	case SEMICOLON:
		break;
	default:
		SyntaxError(NextToken(), "VarListTail");
	}
}
Ejemplo n.º 5
0
void Parser::Primary(ExprRec& result) {
	ExprRec index;

	switch (NextToken()) {
	case FALSE_SYM:
	case TRUE_SYM:
		Literal();
		result.var_type = BOOL;
		code.ProcessLit(result); /*** CODE ***/
		break;
	case INT_LIT:
		Literal();
		result.var_type = INT;
		code.ProcessLit(result); /*** CODE ***/
		break;
	case FLOAT_LIT:
		Literal();
		result.var_type = FLOAT;
		code.ProcessLit(result); /*** CODE ***/
		break;
	case CHEESE_LIT:
		Literal();
		result.var_type = CHEESE;
		code.ProcessLit(result); /*** CODE ***/
		break;
	case ID:
		Variable(result, index);
		/* var_type is retrieved from symbol table */
		code.ProcessVar(result, index); /*** CODE ***/
		break;
	case LBANANA:
		Match(LBANANA);
		Expression(result);
		Match(RBANANA);
		break;
	default:
		SyntaxError(NextToken(), "Unknown Primary Symbol");
	}
}