예제 #1
0
 override public void Visit(AST_expression_operand expression_operand)
 {
     base.Visit(expression_operand);
     if (expression_operand.Expression != null)
     {
         expression_operand.DataType = expression_operand.Expression.DataType;
     }
 }
예제 #2
0
        private AST_operand Parse_operand(TokenKind followSet)
        {
            IncrementDepth();
            DebugPrint("opnd");

            Token       t = LookAheadToken();
            AST_operand operand;

            switch (t.Kind)
            {
            case int_Literal:
                operand = Parse_integer_literal();
                break;

            case string_Literal:
                operand = Parse_string_literal();
                break;

            case bool_Literal:
                operand = Parse_bool_literal(followSet);
                break;

            case Identifier:
                operand = Parse_identifier(followSet);
                break;

            case OpenParenthesis:
                Match(OpenParenthesis);
                operand = new AST_expression_operand(Parse_expression(followSet | CloseParenthesis));
                if (LookAheadToken().Kind == CloseParenthesis)
                {
                    Match(CloseParenthesis);
                }
                else
                {
                    Error("')' expected, '" + LookAheadToken().ToString() + "' found.", LookAheadToken());
                    SkipUntilFollow(followSet | CloseParenthesis);
                    if (LookAheadToken().Kind == CloseParenthesis)
                    {
                        Match(CloseParenthesis);
                    }
                }
                break;

            default:
                Error("Operand expected. '" + t.ToString() + "' does not start an operand.", t);
                SkipUntilFollow(followSet);
                operand = new ASTDummy_operand();
                break;
            }

            operand.Row    = t.Row;
            operand.Column = t.Column;

            DecrementDepth();

            return(operand);
        }
예제 #3
0
 public virtual void Visit(AST_expression_operand expression_operand)
 {
     if (expression_operand.Expression != null)
     {
         IncrementDepth();
         expression_operand.Expression.Accept(this);
         DecrementDepth();
     }
 }
예제 #4
0
 override public void Visit(AST_expression_operand expression_operand)
 {
     expression_operand.Expression.Accept(this);
 }