예제 #1
0
 public virtual void Visit(TemplateThisParameter p)
 {
     if (p.FollowParameter != null)
     {
         p.FollowParameter.Accept(this);
     }
 }
 bool Handle(TemplateThisParameter p, ISemantic arg)
 {
     // Only special handling required for method calls
     return Handle(p.FollowParameter,arg);
 }
 public virtual void Visit(TemplateThisParameter p)
 {
     VisitTemplateParameter (p);
     if (p.FollowParameter != null)
         p.FollowParameter.Accept(this);
 }
예제 #4
0
        TemplateParameter TemplateParameter(DNode parent)
        {
            CodeLocation startLoc;

            // TemplateThisParameter
            if (laKind == (This))
            {
                Step();

                startLoc = t.Location;
                var end = t.EndLocation;

                var ret= new TemplateThisParameter(TemplateParameter(parent), parent) { Location=startLoc, EndLocation=end };
                LastParsedObject = ret;
                return ret;
            }

            // TemplateTupleParameter
            else if (laKind == (Identifier) && Lexer.CurrentPeekToken.Kind == TripleDot)
            {
                Step();
                startLoc = t.Location;
                var id = t.Value;
                Step();

                var ret=new TemplateTupleParameter(id, startLoc, parent) { Location=startLoc, EndLocation=t.EndLocation	};
                LastParsedObject = ret;
                return ret;
            }

            // TemplateAliasParameter
            else if (laKind == (Alias))
            {
                Step();

                startLoc = t.Location;
                TemplateAliasParameter al;

                if(Expect(Identifier))
                    al = new TemplateAliasParameter(t.Value, t.Location, parent);
                else
                    al = new TemplateAliasParameter(0, CodeLocation.Empty, parent);
                al.Location = startLoc;
                LastParsedObject = al;

                // TODO?:
                // alias BasicType Declarator TemplateAliasParameterSpecialization_opt TemplateAliasParameterDefault_opt

                // TemplateAliasParameterSpecialization
                if (laKind == (Colon))
                {
                    Step();

                    AllowWeakTypeParsing=true;
                    al.SpecializationType = Type();
                    AllowWeakTypeParsing=false;

                    if (al.SpecializationType==null)
                        al.SpecializationExpression = ConditionalExpression();
                }

                // TemplateAliasParameterDefault
                if (laKind == (Assign))
                {
                    Step();

                    AllowWeakTypeParsing=true;
                    al.DefaultType = Type();
                    AllowWeakTypeParsing=false;

                    if (al.DefaultType==null)
                        al.DefaultExpression = ConditionalExpression();
                }
                al.EndLocation = t.EndLocation;
                return al;
            }

            // TemplateTypeParameter
            else if (laKind == (Identifier) && (Lexer.CurrentPeekToken.Kind == (Colon) || Lexer.CurrentPeekToken.Kind == (Assign) || Lexer.CurrentPeekToken.Kind == (Comma) || Lexer.CurrentPeekToken.Kind == (CloseParenthesis)))
            {
                Expect(Identifier);
                var tt = new TemplateTypeParameter(t.Value, t.Location, parent) { Location = t.Location };
                LastParsedObject = tt;

                if (laKind == Colon)
                {
                    Step();
                    tt.Specialization = Type();
                }

                if (laKind == Assign)
                {
                    Step();
                    tt.Default = Type();
                }
                tt.EndLocation = t.EndLocation;
                return tt;
            }

            // TemplateValueParameter
            startLoc = la.Location;
            var bt = BasicType();
            var dv = Declarator(bt,false, null);

            if (dv == null) {
                SynErr (t.Kind, "Declarator expected for parsing template value parameter");
                return null;
            }

            var tv = new TemplateValueParameter(dv.NameHash, dv.NameLocation, parent) {
                Location=la.Location,
                Type = dv.Type
            };
            LastParsedObject = tv;

            if (laKind == (Colon))
            {
                Step();
                tv.SpecializationExpression = ConditionalExpression();
            }

            if (laKind == (Assign))
            {
                Step();
                tv.DefaultExpression = AssignExpression();
            }
            tv.EndLocation = t.EndLocation;
            return tv;
        }
예제 #5
0
        ITemplateParameter TemplateParameter()
        {
            // TemplateThisParameter
            if (laKind == (This))
            {
                Step();

                var ret= new TemplateThisParameter()
                {
                    Location=t.Location,
                    FollowParameter=TemplateParameter(),
                    EndLocation=t.EndLocation
                };
                LastParsedObject = ret;
                return ret;
            }

            // TemplateTupleParameter
            if (laKind == (Identifier) && Lexer.CurrentPeekToken.Kind == TripleDot)
            {
                Step();
                var startLoc = t.Location;
                var id = t.Value;
                Step();

                var ret=new TemplateTupleParameter() { Name=id, Location=startLoc, EndLocation=t.EndLocation};
                LastParsedObject = ret;
                return ret;
            }

            // TemplateAliasParameter
            if (laKind == (Alias))
            {
                Step();
                var al = new TemplateAliasParameter() { Location=t.Location };
                LastParsedObject = al;

                Expect(Identifier);

                al.Name = t.Value;

                // TODO?:
                // alias BasicType Declarator TemplateAliasParameterSpecialization_opt TemplateAliasParameterDefault_opt

                // TemplateAliasParameterSpecialization
                if (laKind == (Colon))
                {
                    Step();

                    AllowWeakTypeParsing=true;
                    al.SpecializationType = Type();
                    AllowWeakTypeParsing=false;

                    if (al.SpecializationType==null)
                        al.SpecializationExpression = ConditionalExpression();
                }

                // TemplateAliasParameterDefault
                if (laKind == (Assign))
                {
                    Step();

                    AllowWeakTypeParsing=true;
                    al.DefaultType = Type();
                    AllowWeakTypeParsing=false;

                    if (al.DefaultType==null)
                        al.DefaultExpression = ConditionalExpression();
                }
                al.EndLocation = t.EndLocation;
                return al;
            }

            // TemplateTypeParameter
            if (laKind == (Identifier) && (Lexer.CurrentPeekToken.Kind == (Colon) || Lexer.CurrentPeekToken.Kind == (Assign) || Lexer.CurrentPeekToken.Kind == (Comma) || Lexer.CurrentPeekToken.Kind == (CloseParenthesis)))
            {
                Expect(Identifier);
                var tt = new TemplateTypeParameter() { Location=t.Location };
                LastParsedObject = tt;

                tt.Name = t.Value;

                if (laKind == Colon)
                {
                    Step();
                    tt.Specialization = Type();
                }

                if (laKind == Assign)
                {
                    Step();
                    tt.Default = Type();
                }
                tt.EndLocation = t.EndLocation;
                return tt;
            }

            // TemplateValueParameter
            var tv = new TemplateValueParameter() { Location=la.Location };
            LastParsedObject = tv;

            var bt = BasicType();
            var dv = Declarator(bt,false);

            tv.Type = dv.Type;
            tv.Name = dv.Name;

            if (laKind == (Colon))
            {
                Step();
                tv.SpecializationExpression = ConditionalExpression();
            }

            if (laKind == (Assign))
            {
                Step();
                tv.DefaultExpression = AssignExpression();
            }
            tv.EndLocation = t.EndLocation;
            return tv;
        }