예제 #1
0
        private Expression ParseConstantExpression()
        {
            ConstantKind kind;

            if (current == "true" || current == "false")
            {
                kind = ConstantKind.Boolean;
            }
            else if (current == TokenKind.StringLiteral)
            {
                kind = ConstantKind.String;
            }
            else if (current == TokenKind.IntegerLiteral)
            {
                kind = ConstantKind.Integer;
            }
            else if (current == TokenKind.FloatLiteral)
            {
                kind = ConstantKind.Float;
            }
            else
            {
                throw UnexpectedToken("Constant");
            }

            var token = Take();

            var expr = new ConstantExpression(token.Span, token.Value, kind);

            statm.Add(expr);

            return(expr);
        }
 protected abstract void VisitConstant(ConstantExpression expression);