// <expression>         ::=	<simple expression>
//                          | <simple expression> <ifstatement><simple expression>
void SyntaxAnalyzer::expression()
{
	simpleExpression();
    
    if(relOps.find(symbol) != relOps.end()) {
        relationOperator();
        simpleExpression();
    }
} // expression( );
Esempio n. 2
0
TypePtr expression (void) {

	//------------------------------------
	// Grab the first simple expression...
	TypePtr resultType = simpleExpression();

	if (tokenIn(relationalOperatorList)) {
		//---------------------------------------
		// Snatch the second simple expression...
		getToken();
		TypePtr secondType = simpleExpression();

		checkRelationalOpTypes(resultType, secondType);
		resultType = BooleanTypePtr;
	}
	return(resultType);
}
Esempio n. 3
0
//Produção Expression'
ExpressionNode* expressionLinha(ExpressionNode* sexprE){
       printf("Expression'\n");                 
       if (lookaheadPertenceFirst(Rel_Op) == 1){
             int relOpVar = relOp();
             ExpressionNode* sexprD = simpleExpression();
             if(sexprD == NULL) return NULL; else
             return new RelOpNode(relOpVar,sexprE,sexprD);
       }else return sexprE;
}
Esempio n. 4
0
//Produção Simple_Exp'
ExpressionNode* simpleExpressionLinha(ExpressionNode* addExpE){
    printf("Simple_Exp'\n");
     if (lookaheadPertenceFirst(Add_Op) == 1){
          int addOpVar = addOp();
          ExpressionNode* addExpD = simpleExpression();
          if(addExpD == NULL) return NULL; else
          return new AddOpNode(addOpVar,addExpE,addExpD );
     }else return addExpE;

}
Esempio n. 5
0
bool multiplicationExpression(char s[], int &position)
{
	int current = position;
	if (simpleExpression(s, current) && multiplicationExpressionDash(s, current))
	{
		position = current;
		return true;
	}
	else
	{
		return false;
	}
}
Esempio n. 6
0
//Produção Expression
ExpressionNode* expression(){
       printf("Expression\n");  
       if (lookahead == LITERAL ){            
              int iLiteral = retornaIndiceLexemaAtual();
              LiteralNode* literal = new LiteralNode(iLiteral);
              match(LITERAL,followExpression, &iLiteral);
              if (lookaheadPertenceFirst(ExpressionDuasLinhas) == 1)
                  return expressionDuasLinhas(literal); 
              else
                  return literal; 
       }else{
              ExpressionNode* simpExp = simpleExpression();
              ExpressionNode* exprelinha = expressionLinha(simpExp);
              ExpressionNode* expreDuasLinhas = expressionDuasLinhas(exprelinha);
              return expreDuasLinhas; 
       }
}
Esempio n. 7
0
bool multiplicationExpressionDash(char s[], int &position)
{
	if ( isStarOrSlash(s[position]) )
	{
		int current = position + 1;
		if (simpleExpression(s, current) && multiplicationExpressionDash(s, current))
		{
			position = current;
			return true;
		}
		else
			return true;
	}
	else
	{
		return true;
	}
}