Beispiel #1
0
        public UstNode VisitPatternBoolLiteral(DslParser.PatternBoolLiteralContext context)
        {
            var boolText = context.PatternBool().GetText();
            var result   = new PatternBooleanLiteral(boolText == "bool" ? (bool?)null : bool.Parse(boolText));

            result.TextSpan = context.GetTextSpan();
            return(result);
        }
Beispiel #2
0
        public PatternUst VisitLiteral(DslParser.LiteralContext context)
        {
            PatternUst result;
            var        textSpan = context.GetTextSpan();

            if (context.Id() != null)
            {
                result = ProcessId(context.Id());
            }
            else if (context.String() != null)
            {
                result = new PatternStringLiteral(RemoveQuotes(context.GetText()), textSpan);
            }
            else if (context.Oct() != null)
            {
                result = new PatternIntLiteral(
                    System.Convert.ToInt64(context.Oct().GetText(), 8), textSpan);
            }
            else if (context.Int() != null)
            {
                string text = context.Int().GetText();
                if (long.TryParse(text, out long longValue))
                {
                    result = new PatternIntLiteral(longValue, textSpan);
                }
                else
                {
                    result = new PatternBigIntLiteral(longValue, textSpan);
                }
            }
            else if (context.Hex() != null)
            {
                result = new PatternIntLiteral(
                    System.Convert.ToInt64(context.Hex().GetText(), 16), textSpan);
            }
            else if (context.Bool() != null)
            {
                result = new PatternBooleanLiteral(bool.Parse(context.Bool().GetText()), textSpan);
            }
            else if (context.Null() != null)
            {
                result = new PatternNullLiteral(textSpan);
            }
            else
            {
                throw new NotImplementedException();
            }
            return(result);
        }
Beispiel #3
0
 public virtual T Visit(PatternBooleanLiteral patternBooleanLiteral)
 {
     return(VisitChildren(patternBooleanLiteral));
 }
Beispiel #4
0
 public virtual void Exit(PatternBooleanLiteral patternBooleanLiteral)
 {
 }