private AST_expression Parse_expression(TokenKind followSet) { IncrementDepth(); DebugPrint("expr"); AST_expression expression; Token t = LookAheadToken(); switch (t.Kind) { case Exclamation: expression = Parse_unary_operator_operand(followSet); break; default: if (isMemberOf(t.Kind, FirstSet_operand)) { AST_operand left_operand = Parse_operand(followSet | BinaryOperators); if (IsBinaryOperator(LookAheadToken().Kind)) { AST_binary_operator binary_operator = Parse_binary_operator(followSet); AST_operand right_operand = Parse_operand(followSet); binary_operator.SetLeft(left_operand); binary_operator.SetRight(right_operand); expression = binary_operator; } else { expression = left_operand; } } else { Error("Expression expected. '" + t.ToString() + "' does not start an expression.", t); expression = new ASTDummy_operand(); SkipUntilFollow(followSet); } break; } DecrementDepth(); return(expression); }
public AST_unary_operator(AST_operand operand) { this.operand = operand; }
public void SetLeft(AST_operand left) { this.left = left; }
public void SetRight(AST_operand right) { this.right = right; }
public AST_binary_operator(OperatorKind kind, AST_operand left, AST_operand right) { this.kind = kind; this.left = left; this.right = right; }