예제 #1
0
            public override Result VisitLiteral([NotNull] OclParser.LiteralContext context)
            {
                if (context.NUMBER() != null)
                {
                    return(new DoubleResult(double.Parse(context.NUMBER().GetText())));
                }
                else if (context.stringLiteral() != null)
                {
                    if (context.stringLiteral().NAME() != null)
                    {
                        return(new StringResult(context.stringLiteral().NAME().GetText()));
                    }
                    else if (context.stringLiteral().NUMBER() != null)
                    {
                        return(new StringResult(context.stringLiteral().NUMBER().GetText()));
                    }
                    else
                    {
                        return(new StringResult(string.Empty));
                    }
                }
                else if (context.booleanLiteral() != null)
                {
                    return(new BoolResult(context.booleanLiteral().GetText() == "true"));
                }

                return(null);
            }
예제 #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="OclParser.literal"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitLiteral([NotNull] OclParser.LiteralContext context)
 {
     return(VisitChildren(context));
 }