Exemplo n.º 1
0
        public static IParsingResultExtended Parse(ParsingContext context)
        {
            IParsingResultExtended name = UnscopedName.Parse(context);

            if (name != null)
            {
                context.SubstitutionTable.Add(name);
                return(name);
            }

            return(Substitution.Parse(context));
        }
Exemplo n.º 2
0
        public static IParsingResultExtended Parse(ParsingContext context)
        {
            IParsingResultExtended substitution = Substitution.Parse(context);

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

            IParsingResultExtended parameter = TemplateParam.Parse(context);

            if (parameter != null)
            {
                IParsingResultExtended result = new TemplateTemplateParam(parameter);
                context.SubstitutionTable.Add(result);
                return(result);
            }
            return(null);
        }
Exemplo n.º 3
0
        public static IParsingResult Parse(ParsingContext context)
        {
            IParsingResult param = TemplateParam.Parse(context);

            if (param != null)
            {
                TemplateArgs   args   = TemplateArgs.Parse(context);
                IParsingResult result = new Template(param, args);

                context.SubstitutionTable.Add(result);
                return(result);
            }

            IParsingResult decltype = Decltype.Parse(context);

            if (decltype != null)
            {
                context.SubstitutionTable.Add(decltype);
                return(decltype);
            }

            return(Substitution.Parse(context));
        }
Exemplo n.º 4
0
        public static IParsingResultExtended Parse(ParsingContext context)
        {
            IParsingResultExtended type = BuiltinType.Parse(context);

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

            type = ClassEnumType.Parse(context);
            if (type != null)
            {
                return(AddToSubstitutionTable(context, type));
            }

            RewindState rewind = context.RewindState;

            type = Substitution.Parse(context);
            if (type != null)
            {
                if (context.Parser.Peek != 'I')
                {
                    return(type);
                }

                context.Rewind(rewind);
            }

            type = FunctionType.Parse(context) ?? ArrayType.Parse(context) ?? PointerToMemberType.Parse(context);
            if (type != null)
            {
                return(AddToSubstitutionTable(context, type));
            }

            type = TemplateParam.Parse(context);
            if (type != null)
            {
                if (context.Parser.Peek != 'I')
                {
                    return(AddToSubstitutionTable(context, type));
                }

                context.Rewind(rewind);
            }

            type = TemplateTemplateParam.Parse(context);
            if (type != null)
            {
                TemplateArgs arguments = TemplateArgs.Parse(context);

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

                return(AddToSubstitutionTable(context, new TemplateTemplate(type, arguments)));
            }

            type = Decltype.Parse(context);
            if (type != null)
            {
                return(type);
            }

            CvQualifiers qualifiers = CvQualifiers.Parse(context);

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

                if (type is BuiltinType)
                {
                    return(new QualifiedBuiltin(qualifiers, type));
                }
                return(AddToSubstitutionTable(context, new Qualified(qualifiers, type)));
            }

            if (context.Parser.VerifyString("P"))
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }
                return(AddToSubstitutionTable(context, new PointerTo(type)));
            }

            if (context.Parser.VerifyString("R"))
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }
                return(AddToSubstitutionTable(context, new LvalueRef(type)));
            }

            if (context.Parser.VerifyString("O"))
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }
                return(AddToSubstitutionTable(context, new RvalueRef(type)));
            }

            if (context.Parser.VerifyString("C"))
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }
                return(AddToSubstitutionTable(context, new Complex(type)));
            }

            if (context.Parser.VerifyString("G"))
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }
                return(AddToSubstitutionTable(context, new Imaginary(type)));
            }

            if (context.Parser.VerifyString("U"))
            {
                IParsingResult name = SourceName.Parse(context);

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

                TemplateArgs arguments = TemplateArgs.Parse(context);

                type = Parse(context);
                return(AddToSubstitutionTable(context, new VendorExtension(name, arguments, type)));
            }

            if (context.Parser.VerifyString("Dp"))
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }
                return(AddToSubstitutionTable(context, new PackExtension(type)));
            }

            return(null);
        }