Пример #1
0
 private void TypeDecl(Modifiers m, List<ICSharpCode.NRefactory.Parser.AST.AttributeSection> attributes)
 {
     List<TypeReference> list;
     List<TemplateDefinition> templates;
     List<ParameterDeclarationExpression> parameter = new List<ParameterDeclarationExpression>();
     if (this.la.kind == 0x3a)
     {
         m.Check(Modifier.Classes);
         base.lexer.NextToken();
         TypeDeclaration childNode = new TypeDeclaration(m.Modifier, attributes);
         templates = childNode.Templates;
         base.compilationUnit.AddChild(childNode);
         base.compilationUnit.BlockStart(childNode);
         childNode.StartLocation = m.GetDeclarationLocation(this.t.Location);
         childNode.Type = ICSharpCode.NRefactory.Parser.AST.ClassType.Class;
         base.Expect(1);
         childNode.Name = this.t.val;
         if (this.la.kind == 0x17)
         {
             this.TypeParameterList(templates);
         }
         if (this.la.kind == 9)
         {
             this.ClassBase(out list);
             childNode.BaseTypes = list;
         }
         while (this.IdentIsWhere())
         {
             this.TypeParameterConstraintsClause(templates);
         }
         this.ClassBody();
         if (this.la.kind == 11)
         {
             base.lexer.NextToken();
         }
         childNode.EndLocation = this.t.Location;
         base.compilationUnit.BlockEnd();
     }
     else if (this.StartOf(8))
     {
         m.Check(Modifier.StructsInterfacesEnumsDelegates);
         if (this.la.kind == 0x6c)
         {
             base.lexer.NextToken();
             TypeDeclaration declaration2 = new TypeDeclaration(m.Modifier, attributes);
             templates = declaration2.Templates;
             declaration2.StartLocation = m.GetDeclarationLocation(this.t.Location);
             base.compilationUnit.AddChild(declaration2);
             base.compilationUnit.BlockStart(declaration2);
             declaration2.Type = ICSharpCode.NRefactory.Parser.AST.ClassType.Struct;
             base.Expect(1);
             declaration2.Name = this.t.val;
             if (this.la.kind == 0x17)
             {
                 this.TypeParameterList(templates);
             }
             if (this.la.kind == 9)
             {
                 this.StructInterfaces(out list);
                 declaration2.BaseTypes = list;
             }
             while (this.IdentIsWhere())
             {
                 this.TypeParameterConstraintsClause(templates);
             }
             this.StructBody();
             if (this.la.kind == 11)
             {
                 base.lexer.NextToken();
             }
             declaration2.EndLocation = this.t.Location;
             base.compilationUnit.BlockEnd();
         }
         else if (this.la.kind == 0x52)
         {
             base.lexer.NextToken();
             TypeDeclaration declaration3 = new TypeDeclaration(m.Modifier, attributes);
             templates = declaration3.Templates;
             base.compilationUnit.AddChild(declaration3);
             base.compilationUnit.BlockStart(declaration3);
             declaration3.StartLocation = m.GetDeclarationLocation(this.t.Location);
             declaration3.Type = ICSharpCode.NRefactory.Parser.AST.ClassType.Interface;
             base.Expect(1);
             declaration3.Name = this.t.val;
             if (this.la.kind == 0x17)
             {
                 this.TypeParameterList(templates);
             }
             if (this.la.kind == 9)
             {
                 this.InterfaceBase(out list);
                 declaration3.BaseTypes = list;
             }
             while (this.IdentIsWhere())
             {
                 this.TypeParameterConstraintsClause(templates);
             }
             this.InterfaceBody();
             if (this.la.kind == 11)
             {
                 base.lexer.NextToken();
             }
             declaration3.EndLocation = this.t.Location;
             base.compilationUnit.BlockEnd();
         }
         else if (this.la.kind == 0x43)
         {
             base.lexer.NextToken();
             TypeDeclaration declaration4 = new TypeDeclaration(m.Modifier, attributes);
             base.compilationUnit.AddChild(declaration4);
             base.compilationUnit.BlockStart(declaration4);
             declaration4.StartLocation = m.GetDeclarationLocation(this.t.Location);
             declaration4.Type = ICSharpCode.NRefactory.Parser.AST.ClassType.Enum;
             base.Expect(1);
             declaration4.Name = this.t.val;
             if (this.la.kind == 9)
             {
                 string str;
                 base.lexer.NextToken();
                 this.IntegralType(out str);
                 declaration4.BaseTypes.Add(new TypeReference(str));
             }
             this.EnumBody();
             if (this.la.kind == 11)
             {
                 base.lexer.NextToken();
             }
             declaration4.EndLocation = this.t.Location;
             base.compilationUnit.BlockEnd();
         }
         else
         {
             base.lexer.NextToken();
             DelegateDeclaration declaration5 = new DelegateDeclaration(m.Modifier, attributes);
             templates = declaration5.Templates;
             declaration5.StartLocation = m.GetDeclarationLocation(this.t.Location);
             if (this.NotVoidPointer())
             {
                 base.Expect(0x7a);
                 declaration5.ReturnType = new TypeReference("void", 0, null);
             }
             else if (this.StartOf(9))
             {
                 TypeReference reference;
                 this.Type(out reference);
                 declaration5.ReturnType = reference;
             }
             else
             {
                 base.SynErr(0x83);
             }
             base.Expect(1);
             declaration5.Name = this.t.val;
             if (this.la.kind == 0x17)
             {
                 this.TypeParameterList(templates);
             }
             base.Expect(20);
             if (this.StartOf(10))
             {
                 this.FormalParameterList(parameter);
                 declaration5.Parameters = parameter;
             }
             base.Expect(0x15);
             while (this.IdentIsWhere())
             {
                 this.TypeParameterConstraintsClause(templates);
             }
             base.Expect(11);
             declaration5.EndLocation = this.t.Location;
             base.compilationUnit.AddChild(declaration5);
         }
     }
     else
     {
         base.SynErr(0x84);
     }
 }
Пример #2
0
 private void ClassMemberDecl(Modifiers m, List<ICSharpCode.NRefactory.Parser.AST.AttributeSection> attributes)
 {
     ICSharpCode.NRefactory.Parser.AST.Statement stmt = null;
     if (this.StartOf(0x10))
     {
         this.StructMemberDecl(m, attributes);
     }
     else if (this.la.kind == 0x1b)
     {
         m.Check(Modifier.Destructors);
         Point location = this.t.Location;
         base.lexer.NextToken();
         base.Expect(1);
         DestructorDeclaration childNode = new DestructorDeclaration(this.t.val, m.Modifier, attributes);
         childNode.Modifier = m.Modifier;
         childNode.StartLocation = m.GetDeclarationLocation(location);
         base.Expect(20);
         base.Expect(0x15);
         childNode.EndLocation = this.t.EndLocation;
         if (this.la.kind == 0x10)
         {
             this.Block(out stmt);
         }
         else if (this.la.kind == 11)
         {
             base.lexer.NextToken();
         }
         else
         {
             base.SynErr(0x8a);
         }
         childNode.Body = (BlockStatement) stmt;
         base.compilationUnit.AddChild(childNode);
     }
     else
     {
         base.SynErr(0x8b);
     }
 }
Пример #3
0
 private void StructMemberDecl(Modifiers m, List<ICSharpCode.NRefactory.Parser.AST.AttributeSection> attributes)
 {
     string name = null;
     TypeReference reference;
     List<ParameterDeclarationExpression> parameter = new List<ParameterDeclarationExpression>();
     ICSharpCode.NRefactory.Parser.AST.Statement stmt = null;
     List<VariableDeclaration> fieldDeclaration = new List<VariableDeclaration>();
     List<TemplateDefinition> templates = new List<TemplateDefinition>();
     TypeReference typeRef = null;
     if (this.la.kind == 0x3b)
     {
         Expression expression;
         m.Check(Modifier.VBInterfacs);
         base.lexer.NextToken();
         Point location = this.t.Location;
         this.Type(out reference);
         base.Expect(1);
         FieldDeclaration childNode = new FieldDeclaration(attributes, reference, m.Modifier | Modifier.Const);
         childNode.StartLocation = m.GetDeclarationLocation(location);
         VariableDeclaration item = new VariableDeclaration(this.t.val);
         childNode.Fields.Add(item);
         base.Expect(3);
         this.Expr(out expression);
         item.Initializer = expression;
         while (this.la.kind == 14)
         {
             base.lexer.NextToken();
             base.Expect(1);
             item = new VariableDeclaration(this.t.val);
             childNode.Fields.Add(item);
             base.Expect(3);
             this.Expr(out expression);
             item.Initializer = expression;
         }
         base.Expect(11);
         childNode.EndLocation = this.t.EndLocation;
         base.compilationUnit.AddChild(childNode);
     }
     else if (this.NotVoidPointer())
     {
         m.Check(Modifier.PropertysEventsMethods);
         base.Expect(0x7a);
         Point keywordLocation = this.t.Location;
         if (this.IsExplicitInterfaceImplementation())
         {
             this.TypeName(out typeRef, false);
             if ((this.la.kind != 15) || (this.Peek(1).kind != 110))
             {
                 name = TypeReference.StripLastIdentifierFromType(ref typeRef);
             }
         }
         else if (this.la.kind == 1)
         {
             base.lexer.NextToken();
             name = this.t.val;
         }
         else
         {
             base.SynErr(140);
         }
         if (this.la.kind == 0x17)
         {
             this.TypeParameterList(templates);
         }
         base.Expect(20);
         if (this.StartOf(10))
         {
             this.FormalParameterList(parameter);
         }
         base.Expect(0x15);
         MethodDeclaration declaration3 = new MethodDeclaration(name, m.Modifier, new TypeReference("void"), parameter, attributes);
         declaration3.StartLocation = m.GetDeclarationLocation(keywordLocation);
         declaration3.EndLocation = this.t.EndLocation;
         declaration3.Templates = templates;
         if (typeRef != null)
         {
             declaration3.InterfaceImplementations.Add(new InterfaceImplementation(typeRef, name));
         }
         base.compilationUnit.AddChild(declaration3);
         base.compilationUnit.BlockStart(declaration3);
         while (this.IdentIsWhere())
         {
             this.TypeParameterConstraintsClause(templates);
         }
         if (this.la.kind == 0x10)
         {
             this.Block(out stmt);
         }
         else if (this.la.kind == 11)
         {
             base.lexer.NextToken();
         }
         else
         {
             base.SynErr(0x8d);
         }
         base.compilationUnit.BlockEnd();
         declaration3.Body = (BlockStatement) stmt;
     }
     else if (this.la.kind == 0x44)
     {
         m.Check(Modifier.PropertysEventsMethods);
         base.lexer.NextToken();
         EventDeclaration declaration4 = new EventDeclaration(null, null, m.Modifier, attributes, null);
         declaration4.StartLocation = this.t.Location;
         base.compilationUnit.AddChild(declaration4);
         base.compilationUnit.BlockStart(declaration4);
         EventAddRegion addBlock = null;
         EventRemoveRegion removeBlock = null;
         this.Type(out reference);
         declaration4.TypeReference = reference;
         if (this.IsExplicitInterfaceImplementation())
         {
             this.TypeName(out typeRef, false);
             name = TypeReference.StripLastIdentifierFromType(ref typeRef);
             declaration4.InterfaceImplementations.Add(new InterfaceImplementation(typeRef, name));
         }
         else if (this.la.kind == 1)
         {
             base.lexer.NextToken();
             name = this.t.val;
         }
         else
         {
             base.SynErr(0x8e);
         }
         declaration4.Name = name;
         declaration4.EndLocation = this.t.EndLocation;
         if (this.la.kind == 0x10)
         {
             base.lexer.NextToken();
             declaration4.BodyStart = this.t.Location;
             this.EventAccessorDecls(out addBlock, out removeBlock);
             base.Expect(0x11);
             declaration4.BodyEnd = this.t.EndLocation;
         }
         if (this.la.kind == 11)
         {
             base.lexer.NextToken();
         }
         base.compilationUnit.BlockEnd();
         declaration4.AddRegion = addBlock;
         declaration4.RemoveRegion = removeBlock;
     }
     else if (this.IdentAndLPar())
     {
         m.Check(Modifier.StaticConstructors | Modifier.Visibility);
         base.Expect(1);
         string val = this.t.val;
         Point point3 = this.t.Location;
         base.Expect(20);
         if (this.StartOf(10))
         {
             m.Check(Modifier.Constructors);
             this.FormalParameterList(parameter);
         }
         base.Expect(0x15);
         ICSharpCode.NRefactory.Parser.AST.ConstructorInitializer ci = null;
         if (this.la.kind == 9)
         {
             m.Check(Modifier.Constructors);
             this.ConstructorInitializer(out ci);
         }
         ConstructorDeclaration declaration5 = new ConstructorDeclaration(val, m.Modifier, parameter, ci, attributes);
         declaration5.StartLocation = point3;
         declaration5.EndLocation = this.t.EndLocation;
         if (this.la.kind == 0x10)
         {
             this.Block(out stmt);
         }
         else if (this.la.kind == 11)
         {
             base.lexer.NextToken();
         }
         else
         {
             base.SynErr(0x8f);
         }
         declaration5.Body = (BlockStatement) stmt;
         base.compilationUnit.AddChild(declaration5);
     }
     else if ((this.la.kind == 0x45) || (this.la.kind == 0x4f))
     {
         m.Check(Modifier.Operators);
         if (m.isNone)
         {
             this.Error("at least one modifier must be set");
         }
         bool flag = true;
         Point empty = Point.Empty;
         if (this.la.kind == 0x4f)
         {
             base.lexer.NextToken();
             empty = this.t.Location;
         }
         else
         {
             base.lexer.NextToken();
             flag = false;
             empty = this.t.Location;
         }
         base.Expect(0x5b);
         this.Type(out reference);
         TypeReference typeReference = reference;
         base.Expect(20);
         this.Type(out reference);
         base.Expect(1);
         string parameterName = this.t.val;
         base.Expect(0x15);
         Point point5 = this.t.Location;
         if (this.la.kind == 0x10)
         {
             this.Block(out stmt);
         }
         else if (this.la.kind == 11)
         {
             base.lexer.NextToken();
             stmt = null;
         }
         else
         {
             base.SynErr(0x90);
         }
         List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
         parameters.Add(new ParameterDeclarationExpression(reference, parameterName));
         OperatorDeclaration declaration6 = new OperatorDeclaration(m.Modifier, attributes, parameters, typeReference, flag ? ConversionType.Implicit : ConversionType.Explicit);
         declaration6.Body = (BlockStatement) stmt;
         declaration6.StartLocation = m.GetDeclarationLocation(empty);
         declaration6.EndLocation = point5;
         base.compilationUnit.AddChild(declaration6);
     }
     else if (this.StartOf(0x11))
     {
         this.TypeDecl(m, attributes);
     }
     else if (this.StartOf(9))
     {
         this.Type(out reference);
         Point point6 = this.t.Location;
         if (this.la.kind == 0x5b)
         {
             OverloadableOperatorType type;
             TypeReference reference4;
             m.Check(Modifier.Operators);
             if (m.isNone)
             {
                 this.Error("at least one modifier must be set");
             }
             base.lexer.NextToken();
             this.OverloadableOperator(out type);
             TypeReference reference5 = null;
             string str4 = null;
             base.Expect(20);
             this.Type(out reference4);
             base.Expect(1);
             string str5 = this.t.val;
             if (this.la.kind == 14)
             {
                 base.lexer.NextToken();
                 this.Type(out reference5);
                 base.Expect(1);
                 str4 = this.t.val;
             }
             else if (this.la.kind != 0x15)
             {
                 base.SynErr(0x91);
             }
             Point point7 = this.t.Location;
             base.Expect(0x15);
             if (this.la.kind == 0x10)
             {
                 this.Block(out stmt);
             }
             else if (this.la.kind == 11)
             {
                 base.lexer.NextToken();
             }
             else
             {
                 base.SynErr(0x92);
             }
             List<ParameterDeclarationExpression> list5 = new List<ParameterDeclarationExpression>();
             list5.Add(new ParameterDeclarationExpression(reference4, str5));
             if (reference5 != null)
             {
                 list5.Add(new ParameterDeclarationExpression(reference5, str4));
             }
             OperatorDeclaration declaration7 = new OperatorDeclaration(m.Modifier, attributes, list5, reference, type);
             declaration7.Body = (BlockStatement) stmt;
             declaration7.StartLocation = m.GetDeclarationLocation(point6);
             declaration7.EndLocation = point7;
             base.compilationUnit.AddChild(declaration7);
         }
         else if (this.IsVarDecl())
         {
             m.Check(Modifier.Fields);
             FieldDeclaration declaration8 = new FieldDeclaration(attributes, reference, m.Modifier);
             declaration8.StartLocation = m.GetDeclarationLocation(point6);
             this.VariableDeclarator(fieldDeclaration);
             while (this.la.kind == 14)
             {
                 base.lexer.NextToken();
                 this.VariableDeclarator(fieldDeclaration);
             }
             base.Expect(11);
             declaration8.EndLocation = this.t.EndLocation;
             declaration8.Fields = fieldDeclaration;
             base.compilationUnit.AddChild(declaration8);
         }
         else if (this.la.kind == 110)
         {
             PropertyGetRegion region3;
             PropertySetRegion region4;
             m.Check(Modifier.Indexers);
             base.lexer.NextToken();
             base.Expect(0x12);
             this.FormalParameterList(parameter);
             base.Expect(0x13);
             Point endLocation = this.t.EndLocation;
             base.Expect(0x10);
             IndexerDeclaration declaration9 = new IndexerDeclaration(reference, parameter, m.Modifier, attributes);
             declaration9.StartLocation = point6;
             declaration9.EndLocation = endLocation;
             declaration9.BodyStart = this.t.Location;
             this.AccessorDecls(out region3, out region4);
             base.Expect(0x11);
             declaration9.BodyEnd = this.t.EndLocation;
             declaration9.GetRegion = region3;
             declaration9.SetRegion = region4;
             base.compilationUnit.AddChild(declaration9);
         }
         else if (this.la.kind == 1)
         {
             if (this.IsExplicitInterfaceImplementation())
             {
                 this.TypeName(out typeRef, false);
                 if ((this.la.kind != 15) || (this.Peek(1).kind != 110))
                 {
                     name = TypeReference.StripLastIdentifierFromType(ref typeRef);
                 }
             }
             else if (this.la.kind == 1)
             {
                 base.lexer.NextToken();
                 name = this.t.val;
             }
             else
             {
                 base.SynErr(0x93);
             }
             Point point9 = this.t.EndLocation;
             if (((this.la.kind == 0x10) || (this.la.kind == 20)) || (this.la.kind == 0x17))
             {
                 if ((this.la.kind == 20) || (this.la.kind == 0x17))
                 {
                     m.Check(Modifier.PropertysEventsMethods);
                     if (this.la.kind == 0x17)
                     {
                         this.TypeParameterList(templates);
                     }
                     base.Expect(20);
                     if (this.StartOf(10))
                     {
                         this.FormalParameterList(parameter);
                     }
                     base.Expect(0x15);
                     MethodDeclaration declaration10 = new MethodDeclaration(name, m.Modifier, reference, parameter, attributes);
                     if (typeRef != null)
                     {
                         declaration10.InterfaceImplementations.Add(new InterfaceImplementation(typeRef, name));
                     }
                     declaration10.StartLocation = m.GetDeclarationLocation(point6);
                     declaration10.EndLocation = this.t.EndLocation;
                     declaration10.Templates = templates;
                     base.compilationUnit.AddChild(declaration10);
                     while (this.IdentIsWhere())
                     {
                         this.TypeParameterConstraintsClause(templates);
                     }
                     if (this.la.kind == 0x10)
                     {
                         this.Block(out stmt);
                     }
                     else if (this.la.kind == 11)
                     {
                         base.lexer.NextToken();
                     }
                     else
                     {
                         base.SynErr(0x94);
                     }
                     declaration10.Body = (BlockStatement) stmt;
                 }
                 else
                 {
                     PropertyGetRegion region5;
                     PropertySetRegion region6;
                     base.lexer.NextToken();
                     PropertyDeclaration declaration11 = new PropertyDeclaration(name, reference, m.Modifier, attributes);
                     if (typeRef != null)
                     {
                         declaration11.InterfaceImplementations.Add(new InterfaceImplementation(typeRef, name));
                     }
                     declaration11.StartLocation = m.GetDeclarationLocation(point6);
                     declaration11.EndLocation = point9;
                     declaration11.BodyStart = this.t.Location;
                     this.AccessorDecls(out region5, out region6);
                     base.Expect(0x11);
                     declaration11.GetRegion = region5;
                     declaration11.SetRegion = region6;
                     declaration11.BodyEnd = this.t.EndLocation;
                     base.compilationUnit.AddChild(declaration11);
                 }
             }
             else if (this.la.kind == 15)
             {
                 PropertyGetRegion region7;
                 PropertySetRegion region8;
                 m.Check(Modifier.Indexers);
                 base.lexer.NextToken();
                 base.Expect(110);
                 base.Expect(0x12);
                 this.FormalParameterList(parameter);
                 base.Expect(0x13);
                 IndexerDeclaration declaration12 = new IndexerDeclaration(reference, parameter, m.Modifier, attributes);
                 declaration12.StartLocation = m.GetDeclarationLocation(point6);
                 declaration12.EndLocation = this.t.EndLocation;
                 if (typeRef != null)
                 {
                     declaration12.InterfaceImplementations.Add(new InterfaceImplementation(typeRef, "this"));
                 }
                 base.Expect(0x10);
                 Point point10 = this.t.Location;
                 this.AccessorDecls(out region7, out region8);
                 base.Expect(0x11);
                 declaration12.BodyStart = point10;
                 declaration12.BodyEnd = this.t.EndLocation;
                 declaration12.GetRegion = region7;
                 declaration12.SetRegion = region8;
                 base.compilationUnit.AddChild(declaration12);
             }
             else
             {
                 base.SynErr(0x95);
             }
         }
         else
         {
             base.SynErr(150);
         }
     }
     else
     {
         base.SynErr(0x97);
     }
 }