Example #1
0
        public Literal(TParser.LiteralContext ctx, IToken parseNode) : base(parseNode.ToPosition())
        {
            var token = ctx.Start;

            Value = token.Type switch
            {
                TParser.StringLiteral => token.Text.Substring(1, token.Text.Length - 2),
                TParser.BooleanLiteral => token.Text == "verdadero",
                TParser.DecimalLiteral => double.Parse(token.Text),
                TParser.NaN => double.NaN,
                TParser.NullLiteral => null,
                _ => null
            };
        }
Example #2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>Literal</c>
 /// labeled alternative in <see cref="TParser.expression"/>.
 /// <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] TParser.LiteralContext context)
 {
     return(VisitChildren(context));
 }
Example #3
0
 public override Node VisitLiteral(TParser.LiteralContext context)
 {
     return(new Literal(context, context.Start));
 }
 /// <summary>
 /// Exit a parse tree produced by the <c>Literal</c>
 /// labeled alternative in <see cref="TParser.expression"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitLiteral([NotNull] TParser.LiteralContext context)
 {
 }