Exemple #1
0
Node* Parser::PostfixExpr() {
	Node *left = PrimaryExpr();

	if(oper == ROUND_LEFT_BRACKET) {
		if( !simple && symStack->FindVar(left->GetName())->GetSymType() != FUNCTION )
			throw SemanticException(currentToken, "Term not a function");

		Next();
		Node *args = ArgumentExprList();

		if(oper != ROUND_RIGHT_BRACKET)
			throw ParserException(currentToken, "Postfix expression without ')'");

		Next();

		SymbolType type = ( (SymFunction*)( symStack->FindVar(left->GetName()) ) )->GetReturnType();

		return new NodeCall(type, left->GetName(), args);
	}
	if(oper == SQUARE_LEFT_BRACKET) {
		if( !simple && symStack->FindVar(left->GetName())->GetSymType() != ARRAY )
			throw SemanticException(currentToken, "Term not an array");

		Next();
		Node *link = Expression();

		if(oper == SQUARE_RIGHT_BRACKET) {
			Next();
			return new NodeBinary(left, ARRAY_INDEX,  link);
		}
		else throw ParserException(currentToken, "No ']'");
	}
	if(oper == OPER_POINT || oper == OPER_ARROW) {
		TokenValue _oper = oper;
		Next();
		Node *right = PrimaryExpr();
		if(right == NULL)
			throw ParserException(currentToken, "No field");

		return new NodeBinary(left, _oper, right);
	}
	if(oper == OPER_INC || oper == OPER_DEC) {
		TokenValue _oper = oper;
		Next();
		return new NodeUnary(_oper, left);
	}
	return left;
}
void
nsXFormsXPathParser::FilterExpr()
{
  PrimaryExpr();
  if (PeekToken() == nsXFormsXPathScanner::LBRACK) {
    Predicate();
  }
}