private NVExpression ParseNVTerm() { // NVTerm -> NVFactor { NVMulOp NVFactor }. NVExpression expr = ParseNVFactor(); while (CurrentTokenIn(TokenType.NVMul, TokenType.NVDiv, TokenType.NVMod)) { expr = new NVBinaryExpression(ParseNVMulOp(), expr, ParseNVFactor()); expr.Position = new Position((NVBinaryExpression)expr); } return expr; }
private NVExpression ParseNVRelExpression() { // NVRelExpression -> NVSimpleExpression [ NVRelOp NVSimpleExpression ]. NVExpression expr = ParseNVSimpleExpression(); if (CurrentTokenIn(TokenType.NVLte, TokenType.NVLt, TokenType.NVGt, TokenType.NVGte, TokenType.NVEqEq, TokenType.NVNeq)) { expr = new NVBinaryExpression(ParseNVRelOp(), expr, ParseNVSimpleExpression()); expr.Position = new Position((NVBinaryExpression)expr); } return expr; }
private NVExpression ParseNVSimpleExpression() { // NVSimpleExpression -> NVTerm { NVAddOp NVTerm }. NVExpression expr = ParseNVTerm(); while (CurrentTokenIn(TokenType.NVPlus, TokenType.NVMinus)) { expr = new NVBinaryExpression(ParseNVAddOp(), expr, ParseNVTerm()); expr.Position = new Position((NVBinaryExpression)expr); } return expr; }
private NVExpression ParseNVExpression() { // NVExpression -> NVAndExpression { ( "||" | "or" ) NVAndExpression }. NVExpression expr = ParseNVAndExpression(); while (CurrentTokenType == TokenType.NVOr) { _scanner.GetToken(); expr = new NVBinaryExpression(Operator.Or, expr, ParseNVAndExpression()); expr.Position = new Position((NVBinaryExpression)expr); } return expr; }