Beispiel #1
0
        public static IParsingResultExtended Parse(ParsingContext context)
        {
            IParsingResultExtended simple = SimpleOperatorName.Parse(context);

            if (simple != null)
            {
                return(simple);
            }

            RewindState rewind = context.RewindState;

            if (context.Parser.VerifyString("cv"))
            {
                IParsingResultExtended type = Type.Parse(context);

                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }

                return(new Cast(type));
            }

            if (context.Parser.VerifyString("li"))
            {
                IParsingResultExtended name = SourceName.Parse(context);

                if (name == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }

                return(new Literal(name));
            }

            if (context.Parser.VerifyString("v"))
            {
                if (!char.IsDigit(context.Parser.Peek))
                {
                    context.Rewind(rewind);
                    return(null);
                }

                int arity = context.Parser.Peek - '0';
                context.Parser.Position++;
                IParsingResultExtended name = SourceName.Parse(context);

                if (name == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }

                return(new VendorExtension(arity, name));
            }

            return(null);
        }
Beispiel #2
0
        public static bool StartsWith(ParsingContext context)
        {
            char peek = context.Parser.Peek;

            return(peek == 'c' || peek == 'l' || peek == 'v' || SimpleOperatorName.StartsWith(context));
        }