From b0819ac4f9abe3df15433bf3890739f364305a5b Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sat, 16 Jul 2011 17:02:08 +0100 Subject: [PATCH 01/12] Supporting installing a NuGet package into selected projects in one step. --- NRefactory.sln | 44 + NRefactoryASTGenerator/AST/Expressions.cs | 436 + NRefactoryASTGenerator/AST/GlobalLevel.cs | 107 + NRefactoryASTGenerator/AST/Node.cs | 68 + NRefactoryASTGenerator/AST/Statements.cs | 313 + NRefactoryASTGenerator/AST/TypeLevel.cs | 235 + NRefactoryASTGenerator/AssemblyInfo.cs | 29 + NRefactoryASTGenerator/Attributes.cs | 176 + NRefactoryASTGenerator/KeywordGenerator.cs | 388 + NRefactoryASTGenerator/Main.cs | 590 ++ .../NRefactoryASTGenerator.csproj | 64 + Project/Configuration/AssemblyInfo.cs | 21 + Project/NRefactory.csproj | 191 + Project/NRefactory.csproj.user | 14 + Project/Resources/ICSharpCode.NRefactory.snk | Bin 0 -> 596 bytes Project/Src/Ast/AbstractNode.cs | 73 + Project/Src/Ast/Enums.cs | 412 + Project/Src/Ast/General/BlockStatement.cs | 59 + Project/Src/Ast/General/CompilationUnit.cs | 24 + Project/Src/Ast/General/Expression.cs | 103 + .../Ast/General/LocalVariableDeclaration.cs | 99 + .../Src/Ast/General/PrimitiveExpression.cs | 53 + Project/Src/Ast/General/Statement.cs | 62 + Project/Src/Ast/Generated.cs | 5805 +++++++++++ Project/Src/Ast/INode.cs | 51 + Project/Src/Ast/INullable.cs | 12 + Project/Src/Ast/TypeReference.cs | 427 + Project/Src/AstBuilder/ExpressionBuilder.cs | 92 + Project/Src/AstBuilder/StatementBuilder.cs | 55 + Project/Src/EnvironmentInformationProvider.cs | 22 + Project/Src/IAstVisitor.cs | 278 + Project/Src/Lexer/AbstractLexer.cs | 386 + .../Lexer/CSharp/ConditionalCompilation.cs | 86 + Project/Src/Lexer/CSharp/KeywordList.txt | 215 + Project/Src/Lexer/CSharp/Keywords.cs | 132 + Project/Src/Lexer/CSharp/Lexer.cs | 1213 +++ Project/Src/Lexer/CSharp/Tokens.cs | 356 + Project/Src/Lexer/ILexer.cs | 123 + Project/Src/Lexer/LATextReader.cs | 52 + Project/Src/Lexer/LexerMemento.cs | 14 + Project/Src/Lexer/LookupTable.cs | 116 + Project/Src/Lexer/SavepointEventArgs.cs | 20 + Project/Src/Lexer/Special/BlankLine.cs | 19 + Project/Src/Lexer/Special/Comment.cs | 59 + Project/Src/Lexer/Special/CommentType.cs | 14 + Project/Src/Lexer/Special/ISpecial.cs | 52 + .../Lexer/Special/PreProcessingDirective.cs | 156 + Project/Src/Lexer/Special/SpecialTracker.cs | 71 + Project/Src/Lexer/Special/TagComment.cs | 29 + Project/Src/Lexer/Token.cs | 112 + Project/Src/Lexer/VBNet/Block.cs | 57 + Project/Src/Lexer/VBNet/ExpressionFinder.atg | 1377 +++ Project/Src/Lexer/VBNet/ExpressionFinder.cs | 157 + .../Src/Lexer/VBNet/ExpressionFinderState.cs | 22 + Project/Src/Lexer/VBNet/Extensions.cs | 22 + Project/Src/Lexer/VBNet/KeywordList.txt | 284 + Project/Src/Lexer/VBNet/Keywords.cs | 218 + Project/Src/Lexer/VBNet/Lexer.cs | 1169 +++ Project/Src/Lexer/VBNet/Parser.cs | 8613 +++++++++++++++++ Project/Src/Lexer/VBNet/PushParser.frame | 99 + Project/Src/Lexer/VBNet/Tokens.cs | 530 + Project/Src/Lexer/VBNet/VBLexerMemento.cs | 19 + Project/Src/Lexer/VBNet/XmlModeInfo.cs | 29 + Project/Src/Location.cs | 121 + Project/Src/OperatorPrecedence.cs | 84 + Project/Src/Parser/AbstractParser.cs | 106 + Project/Src/Parser/CSharp/CSharpParser.cs | 695 ++ Project/Src/Parser/CSharp/Parser.cs | 6225 ++++++++++++ Project/Src/Parser/CSharp/cs.ATG | 2622 +++++ Project/Src/Parser/Errors.cs | 50 + Project/Src/Parser/Frames/Parser.frame | 50 + Project/Src/Parser/Frames/Scanner.frame | 202 + Project/Src/Parser/Frames/SharpCoco.exe | Bin 0 -> 81920 bytes Project/Src/Parser/IParser.cs | 38 + Project/Src/Parser/ModifierList.cs | 69 + Project/Src/Parser/VBNet/ParamModifierList.cs | 49 + Project/Src/Parser/VBNet/Parser.cs | 8141 ++++++++++++++++ Project/Src/Parser/VBNet/VBNET.ATG | 3752 +++++++ Project/Src/Parser/VBNet/VBNetParser.cs | 388 + Project/Src/Parser/gen.bat | 19 + Project/Src/Parser/gen.sh | 18 + Project/Src/ParserFactory.cs | 71 + .../PrettyPrinter/AbstractOutputFormatter.cs | 228 + .../AbstractPrettyPrintOptions.cs | 42 + .../CSharp/CSharpOutputVisitor.cs | 3194 ++++++ .../PrettyPrinter/CSharp/OutputFormatter.cs | 159 + .../CSharp/PrettyPrintOptions.cs | 931 ++ .../Src/PrettyPrinter/IOutputAstVisitor.cs | 52 + .../Src/PrettyPrinter/SpecialNodesInserter.cs | 142 + .../VBNet/VBNetOutputFormatter.cs | 73 + .../PrettyPrinter/VBNet/VBNetOutputVisitor.cs | 3238 +++++++ .../VBNet/VBNetPrettyPrintOptions.cs | 18 + Project/Src/SnippetParser.cs | 142 + Project/Src/Visitors/AbstractASTVisitor.cs | 1307 +++ .../Src/Visitors/AbstractAstTransformer.cs | 2341 +++++ .../CSharpConstructsConvertVisitor.cs | 230 + Project/Src/Visitors/CodeDOMOutputVisitor.cs | 1686 ++++ .../Visitors/CodeDOMVerboseOutputGenerator.cs | 356 + Project/Src/Visitors/ConvertVisitorBase.cs | 53 + Project/Src/Visitors/LookupTableVisitor.cs | 318 + .../Src/Visitors/NodeTrackingAstVisitor.cs | 1464 +++ .../Src/Visitors/NotImplementedAstVisitor.cs | 541 ++ Project/Src/Visitors/PrefixFieldsVisitor.cs | 143 + .../Src/Visitors/RenameIdentifierVisitor.cs | 61 + Project/Src/Visitors/SetParentVisitor.cs | 33 + .../Src/Visitors/SetRegionInclusionVisitor.cs | 78 + .../Src/Visitors/ToCSharpConvertVisitor.cs | 336 + Project/Src/Visitors/ToVBNetConvertVisitor.cs | 428 + .../ToVBNetRenameConflictingVariables.cs | 90 + .../Visitors/VBNetConstructsConvertVisitor.cs | 764 ++ Test/AssemblyInfo.cs | 35 + Test/General/UnitTest.cs | 103 + Test/Lexer/CSharp/CustomLexerTests.cs | 151 + Test/Lexer/CSharp/LexerPositionTests.cs | 252 + Test/Lexer/CSharp/LexerTests.cs | 1016 ++ Test/Lexer/CSharp/NumberLexerTest.cs | 177 + Test/Lexer/CSharp/PreprocessingTests.cs | 164 + Test/Lexer/LATextReaderTests.cs | 35 + Test/Lexer/VBNet/CustomLexerTests.cs | 118 + .../VBNet/ImplicitLineContinuationTests.cs | 232 + Test/Lexer/VBNet/LexerContextTests.cs | 584 ++ Test/Lexer/VBNet/LexerPositionTests.cs | 88 + Test/Lexer/VBNet/LexerTests.cs | 1541 +++ Test/Lexer/VBNet/LiteralsTests.cs | 196 + Test/Lexer/VBNet/TokenTests.cs | 23 + Test/Lexer/VBNet/XmlModeLexerTests.cs | 994 ++ Test/NRefactoryTests.csproj | 183 + Test/Output/CSharp/CSharpOutputTest.cs | 801 ++ .../CSharp/VBNetToCSharpConverterTest.cs | 1027 ++ .../CodeDOMParenthesizedExpressionTest.cs | 23 + .../CodeDOM/CodeDOMPrimitiveExpressionTest.cs | 24 + .../CodeDOM/CodeDOMTypeReferenceTest.cs | 29 + .../CodeDOM/InvocationExpressionTest.cs | 124 + Test/Output/SnippetConversion.cs | 161 + Test/Output/SpecialOutputVisitorTest.cs | 261 + .../VBNet/CSharpToVBNetConverterTest.cs | 698 ++ Test/Output/VBNet/VBNetOutputTest.cs | 669 ++ Test/Parser/CheckParentVisitor.cs | 35 + .../Expressions/AddressOfExpressionTests.cs | 55 + .../Expressions/AnonymousMethodTests.cs | 59 + .../Expressions/ArrayCreateExpressionTests.cs | 61 + .../Expressions/AssignmentExpressionTests.cs | 153 + .../BaseReferenceExpressionTests.cs | 33 + .../BinaryOperatorExpressionTests.cs | 492 + .../Parser/Expressions/CastExpressionTests.cs | 309 + .../Expressions/CheckedExpressionTests.cs | 28 + .../ClassReferenceExpressionTests.cs | 28 + .../Expressions/ConditionalExpressionTests.cs | 123 + .../DefaultValueExpressionTests.cs | 55 + .../GlobalReferenceExpressionTests.cs | 49 + .../Expressions/IdentifierExpressionTests.cs | 72 + .../Expressions/IndexerExpressionTests.cs | 37 + .../Expressions/InvocationExpressionTests.cs | 243 + .../Expressions/LambdaExpressionTests.cs | 218 + .../MemberReferenceExpressionTests.cs | 146 + .../ObjectCreateExpressionTests.cs | 273 + .../ParenthesizedExpressionTest.cs | 38 + .../PointerReferenceExpressionTests.cs | 29 + .../Expressions/PrimitiveExpressionTests.cs | 100 + .../Expressions/QueryExpressionTests.cs | 111 + .../Expressions/QueryExpressionVBTests.cs | 633 ++ .../Expressions/SizeOfExpressionTests.cs | 28 + .../Expressions/StackAllocExpressionTests.cs | 36 + .../ThisReferenceExpressionTests.cs | 31 + .../Expressions/TypeOfExpressionTests.cs | 166 + .../Expressions/TypeOfIsExpressionTests.cs | 66 + .../TypeReferenceExpressionTests.cs | 89 + .../UnaryOperatorExpressionTests.cs | 144 + .../Expressions/UncheckedExpressionTests.cs | 29 + Test/Parser/Expressions/XmlExpressionTests.cs | 261 + .../XmlMemberAccessExpressionTests.cs | 107 + .../GlobalScope/AttributeSectionTests.cs | 134 + .../GlobalScope/DelegateDeclarationTests.cs | 75 + .../GlobalScope/NamespaceDeclarationTests.cs | 73 + .../GlobalScope/OptionDeclarationTests.cs | 87 + .../GlobalScope/TypeDeclarationTests.cs | 392 + .../GlobalScope/UsingDeclarationTests.cs | 276 + Test/Parser/LocationAssignmentCheckVisitor.cs | 26 + Test/Parser/ParseUtilCSharp.cs | 92 + Test/Parser/ParseUtilVBNet.cs | 92 + Test/Parser/SkipMethodBodiesTest.cs | 60 + Test/Parser/SnippetParserTests.cs | 30 + .../Statements/AddHandlerStatementTests.cs | 27 + Test/Parser/Statements/BlockStatementTests.cs | 47 + Test/Parser/Statements/BreakStatementTests.cs | 28 + .../Statements/CheckedStatementTests.cs | 38 + .../Statements/ContinueStatementTests.cs | 27 + .../Parser/Statements/DoLoopStatementTests.cs | 41 + Test/Parser/Statements/EmptyStatementTests.cs | 28 + Test/Parser/Statements/EndStatementTests.cs | 33 + Test/Parser/Statements/EraseStatementTests.cs | 27 + Test/Parser/Statements/ErrorStatementTests.cs | 27 + .../Statements/ExpressionStatementTests.cs | 34 + Test/Parser/Statements/FixedStatementTests.cs | 28 + .../Statements/ForNextStatementTests.cs | 33 + Test/Parser/Statements/ForStatementTests.cs | 39 + .../Statements/ForeachStatementTests.cs | 34 + .../Statements/GotoCaseStatementTests.cs | 36 + Test/Parser/Statements/GotoStatementTests.cs | 33 + .../Parser/Statements/IfElseStatementTests.cs | 185 + Test/Parser/Statements/LabelStatementTests.cs | 41 + .../LocalVariableDeclarationTests.cs | 420 + Test/Parser/Statements/LockStatementTests.cs | 28 + .../Parser/Statements/OnErrorStatementTest.cs | 27 + .../Statements/RaiseEventStatementTest.cs | 27 + Test/Parser/Statements/ReDimStatementTests.cs | 77 + .../Statements/RemoveHandlerStatement.cs | 27 + Test/Parser/Statements/ResumeStatement.cs | 27 + .../Parser/Statements/ReturnStatementTests.cs | 56 + Test/Parser/Statements/StopStatementTests.cs | 27 + .../Parser/Statements/SwitchStatementTests.cs | 44 + Test/Parser/Statements/ThrowStatementTests.cs | 35 + .../Statements/TryCatchStatementTests.cs | 53 + .../Statements/UncheckedStatementTests.cs | 39 + .../Parser/Statements/UnsafeStatementTests.cs | 28 + Test/Parser/Statements/UsingStatementTests.cs | 58 + Test/Parser/Statements/WithStatementTests.cs | 27 + Test/Parser/Statements/YieldStatementTests.cs | 45 + .../TypeLevel/ConstructorDeclarationTests.cs | 75 + Test/Parser/TypeLevel/CustomEventTests.cs | 48 + .../TypeLevel/DeclareDeclarationTests.cs | 32 + .../TypeLevel/DestructorDeclarationTests.cs | 39 + .../Parser/TypeLevel/EventDeclarationTests.cs | 97 + .../Parser/TypeLevel/FieldDeclarationTests.cs | 87 + .../TypeLevel/IndexerDeclarationTests.cs | 54 + .../TypeLevel/MethodDeclarationTests.cs | 488 + .../TypeLevel/OperatorDeclarationTests.cs | 74 + .../TypeLevel/PropertyDeclarationTests.cs | 199 + 228 files changed, 85679 insertions(+) create mode 100644 NRefactory.sln create mode 100644 NRefactoryASTGenerator/AST/Expressions.cs create mode 100644 NRefactoryASTGenerator/AST/GlobalLevel.cs create mode 100644 NRefactoryASTGenerator/AST/Node.cs create mode 100644 NRefactoryASTGenerator/AST/Statements.cs create mode 100644 NRefactoryASTGenerator/AST/TypeLevel.cs create mode 100644 NRefactoryASTGenerator/AssemblyInfo.cs create mode 100644 NRefactoryASTGenerator/Attributes.cs create mode 100644 NRefactoryASTGenerator/KeywordGenerator.cs create mode 100644 NRefactoryASTGenerator/Main.cs create mode 100644 NRefactoryASTGenerator/NRefactoryASTGenerator.csproj create mode 100644 Project/Configuration/AssemblyInfo.cs create mode 100644 Project/NRefactory.csproj create mode 100644 Project/NRefactory.csproj.user create mode 100644 Project/Resources/ICSharpCode.NRefactory.snk create mode 100644 Project/Src/Ast/AbstractNode.cs create mode 100644 Project/Src/Ast/Enums.cs create mode 100644 Project/Src/Ast/General/BlockStatement.cs create mode 100644 Project/Src/Ast/General/CompilationUnit.cs create mode 100644 Project/Src/Ast/General/Expression.cs create mode 100644 Project/Src/Ast/General/LocalVariableDeclaration.cs create mode 100644 Project/Src/Ast/General/PrimitiveExpression.cs create mode 100644 Project/Src/Ast/General/Statement.cs create mode 100644 Project/Src/Ast/Generated.cs create mode 100644 Project/Src/Ast/INode.cs create mode 100644 Project/Src/Ast/INullable.cs create mode 100644 Project/Src/Ast/TypeReference.cs create mode 100644 Project/Src/AstBuilder/ExpressionBuilder.cs create mode 100644 Project/Src/AstBuilder/StatementBuilder.cs create mode 100644 Project/Src/EnvironmentInformationProvider.cs create mode 100644 Project/Src/IAstVisitor.cs create mode 100644 Project/Src/Lexer/AbstractLexer.cs create mode 100644 Project/Src/Lexer/CSharp/ConditionalCompilation.cs create mode 100644 Project/Src/Lexer/CSharp/KeywordList.txt create mode 100644 Project/Src/Lexer/CSharp/Keywords.cs create mode 100644 Project/Src/Lexer/CSharp/Lexer.cs create mode 100644 Project/Src/Lexer/CSharp/Tokens.cs create mode 100644 Project/Src/Lexer/ILexer.cs create mode 100644 Project/Src/Lexer/LATextReader.cs create mode 100644 Project/Src/Lexer/LexerMemento.cs create mode 100644 Project/Src/Lexer/LookupTable.cs create mode 100644 Project/Src/Lexer/SavepointEventArgs.cs create mode 100644 Project/Src/Lexer/Special/BlankLine.cs create mode 100644 Project/Src/Lexer/Special/Comment.cs create mode 100644 Project/Src/Lexer/Special/CommentType.cs create mode 100644 Project/Src/Lexer/Special/ISpecial.cs create mode 100644 Project/Src/Lexer/Special/PreProcessingDirective.cs create mode 100644 Project/Src/Lexer/Special/SpecialTracker.cs create mode 100644 Project/Src/Lexer/Special/TagComment.cs create mode 100644 Project/Src/Lexer/Token.cs create mode 100644 Project/Src/Lexer/VBNet/Block.cs create mode 100644 Project/Src/Lexer/VBNet/ExpressionFinder.atg create mode 100644 Project/Src/Lexer/VBNet/ExpressionFinder.cs create mode 100644 Project/Src/Lexer/VBNet/ExpressionFinderState.cs create mode 100644 Project/Src/Lexer/VBNet/Extensions.cs create mode 100644 Project/Src/Lexer/VBNet/KeywordList.txt create mode 100644 Project/Src/Lexer/VBNet/Keywords.cs create mode 100644 Project/Src/Lexer/VBNet/Lexer.cs create mode 100644 Project/Src/Lexer/VBNet/Parser.cs create mode 100644 Project/Src/Lexer/VBNet/PushParser.frame create mode 100644 Project/Src/Lexer/VBNet/Tokens.cs create mode 100644 Project/Src/Lexer/VBNet/VBLexerMemento.cs create mode 100644 Project/Src/Lexer/VBNet/XmlModeInfo.cs create mode 100644 Project/Src/Location.cs create mode 100644 Project/Src/OperatorPrecedence.cs create mode 100644 Project/Src/Parser/AbstractParser.cs create mode 100644 Project/Src/Parser/CSharp/CSharpParser.cs create mode 100644 Project/Src/Parser/CSharp/Parser.cs create mode 100644 Project/Src/Parser/CSharp/cs.ATG create mode 100644 Project/Src/Parser/Errors.cs create mode 100644 Project/Src/Parser/Frames/Parser.frame create mode 100644 Project/Src/Parser/Frames/Scanner.frame create mode 100755 Project/Src/Parser/Frames/SharpCoco.exe create mode 100644 Project/Src/Parser/IParser.cs create mode 100644 Project/Src/Parser/ModifierList.cs create mode 100644 Project/Src/Parser/VBNet/ParamModifierList.cs create mode 100644 Project/Src/Parser/VBNet/Parser.cs create mode 100644 Project/Src/Parser/VBNet/VBNET.ATG create mode 100644 Project/Src/Parser/VBNet/VBNetParser.cs create mode 100755 Project/Src/Parser/gen.bat create mode 100644 Project/Src/Parser/gen.sh create mode 100644 Project/Src/ParserFactory.cs create mode 100644 Project/Src/PrettyPrinter/AbstractOutputFormatter.cs create mode 100644 Project/Src/PrettyPrinter/AbstractPrettyPrintOptions.cs create mode 100644 Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs create mode 100644 Project/Src/PrettyPrinter/CSharp/OutputFormatter.cs create mode 100644 Project/Src/PrettyPrinter/CSharp/PrettyPrintOptions.cs create mode 100644 Project/Src/PrettyPrinter/IOutputAstVisitor.cs create mode 100644 Project/Src/PrettyPrinter/SpecialNodesInserter.cs create mode 100644 Project/Src/PrettyPrinter/VBNet/VBNetOutputFormatter.cs create mode 100644 Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs create mode 100644 Project/Src/PrettyPrinter/VBNet/VBNetPrettyPrintOptions.cs create mode 100644 Project/Src/SnippetParser.cs create mode 100644 Project/Src/Visitors/AbstractASTVisitor.cs create mode 100644 Project/Src/Visitors/AbstractAstTransformer.cs create mode 100644 Project/Src/Visitors/CSharpConstructsConvertVisitor.cs create mode 100644 Project/Src/Visitors/CodeDOMOutputVisitor.cs create mode 100644 Project/Src/Visitors/CodeDOMVerboseOutputGenerator.cs create mode 100644 Project/Src/Visitors/ConvertVisitorBase.cs create mode 100644 Project/Src/Visitors/LookupTableVisitor.cs create mode 100644 Project/Src/Visitors/NodeTrackingAstVisitor.cs create mode 100644 Project/Src/Visitors/NotImplementedAstVisitor.cs create mode 100644 Project/Src/Visitors/PrefixFieldsVisitor.cs create mode 100644 Project/Src/Visitors/RenameIdentifierVisitor.cs create mode 100644 Project/Src/Visitors/SetParentVisitor.cs create mode 100644 Project/Src/Visitors/SetRegionInclusionVisitor.cs create mode 100644 Project/Src/Visitors/ToCSharpConvertVisitor.cs create mode 100644 Project/Src/Visitors/ToVBNetConvertVisitor.cs create mode 100644 Project/Src/Visitors/ToVBNetRenameConflictingVariables.cs create mode 100644 Project/Src/Visitors/VBNetConstructsConvertVisitor.cs create mode 100644 Test/AssemblyInfo.cs create mode 100644 Test/General/UnitTest.cs create mode 100644 Test/Lexer/CSharp/CustomLexerTests.cs create mode 100644 Test/Lexer/CSharp/LexerPositionTests.cs create mode 100644 Test/Lexer/CSharp/LexerTests.cs create mode 100644 Test/Lexer/CSharp/NumberLexerTest.cs create mode 100644 Test/Lexer/CSharp/PreprocessingTests.cs create mode 100644 Test/Lexer/LATextReaderTests.cs create mode 100644 Test/Lexer/VBNet/CustomLexerTests.cs create mode 100644 Test/Lexer/VBNet/ImplicitLineContinuationTests.cs create mode 100644 Test/Lexer/VBNet/LexerContextTests.cs create mode 100644 Test/Lexer/VBNet/LexerPositionTests.cs create mode 100644 Test/Lexer/VBNet/LexerTests.cs create mode 100644 Test/Lexer/VBNet/LiteralsTests.cs create mode 100644 Test/Lexer/VBNet/TokenTests.cs create mode 100644 Test/Lexer/VBNet/XmlModeLexerTests.cs create mode 100644 Test/NRefactoryTests.csproj create mode 100644 Test/Output/CSharp/CSharpOutputTest.cs create mode 100644 Test/Output/CSharp/VBNetToCSharpConverterTest.cs create mode 100644 Test/Output/CodeDOM/CodeDOMParenthesizedExpressionTest.cs create mode 100644 Test/Output/CodeDOM/CodeDOMPrimitiveExpressionTest.cs create mode 100644 Test/Output/CodeDOM/CodeDOMTypeReferenceTest.cs create mode 100644 Test/Output/CodeDOM/InvocationExpressionTest.cs create mode 100644 Test/Output/SnippetConversion.cs create mode 100644 Test/Output/SpecialOutputVisitorTest.cs create mode 100644 Test/Output/VBNet/CSharpToVBNetConverterTest.cs create mode 100644 Test/Output/VBNet/VBNetOutputTest.cs create mode 100644 Test/Parser/CheckParentVisitor.cs create mode 100644 Test/Parser/Expressions/AddressOfExpressionTests.cs create mode 100644 Test/Parser/Expressions/AnonymousMethodTests.cs create mode 100644 Test/Parser/Expressions/ArrayCreateExpressionTests.cs create mode 100644 Test/Parser/Expressions/AssignmentExpressionTests.cs create mode 100644 Test/Parser/Expressions/BaseReferenceExpressionTests.cs create mode 100644 Test/Parser/Expressions/BinaryOperatorExpressionTests.cs create mode 100644 Test/Parser/Expressions/CastExpressionTests.cs create mode 100644 Test/Parser/Expressions/CheckedExpressionTests.cs create mode 100644 Test/Parser/Expressions/ClassReferenceExpressionTests.cs create mode 100644 Test/Parser/Expressions/ConditionalExpressionTests.cs create mode 100644 Test/Parser/Expressions/DefaultValueExpressionTests.cs create mode 100644 Test/Parser/Expressions/GlobalReferenceExpressionTests.cs create mode 100644 Test/Parser/Expressions/IdentifierExpressionTests.cs create mode 100644 Test/Parser/Expressions/IndexerExpressionTests.cs create mode 100644 Test/Parser/Expressions/InvocationExpressionTests.cs create mode 100644 Test/Parser/Expressions/LambdaExpressionTests.cs create mode 100644 Test/Parser/Expressions/MemberReferenceExpressionTests.cs create mode 100644 Test/Parser/Expressions/ObjectCreateExpressionTests.cs create mode 100644 Test/Parser/Expressions/ParenthesizedExpressionTest.cs create mode 100644 Test/Parser/Expressions/PointerReferenceExpressionTests.cs create mode 100644 Test/Parser/Expressions/PrimitiveExpressionTests.cs create mode 100644 Test/Parser/Expressions/QueryExpressionTests.cs create mode 100644 Test/Parser/Expressions/QueryExpressionVBTests.cs create mode 100644 Test/Parser/Expressions/SizeOfExpressionTests.cs create mode 100644 Test/Parser/Expressions/StackAllocExpressionTests.cs create mode 100644 Test/Parser/Expressions/ThisReferenceExpressionTests.cs create mode 100644 Test/Parser/Expressions/TypeOfExpressionTests.cs create mode 100644 Test/Parser/Expressions/TypeOfIsExpressionTests.cs create mode 100644 Test/Parser/Expressions/TypeReferenceExpressionTests.cs create mode 100644 Test/Parser/Expressions/UnaryOperatorExpressionTests.cs create mode 100644 Test/Parser/Expressions/UncheckedExpressionTests.cs create mode 100644 Test/Parser/Expressions/XmlExpressionTests.cs create mode 100644 Test/Parser/Expressions/XmlMemberAccessExpressionTests.cs create mode 100644 Test/Parser/GlobalScope/AttributeSectionTests.cs create mode 100644 Test/Parser/GlobalScope/DelegateDeclarationTests.cs create mode 100644 Test/Parser/GlobalScope/NamespaceDeclarationTests.cs create mode 100644 Test/Parser/GlobalScope/OptionDeclarationTests.cs create mode 100644 Test/Parser/GlobalScope/TypeDeclarationTests.cs create mode 100644 Test/Parser/GlobalScope/UsingDeclarationTests.cs create mode 100644 Test/Parser/LocationAssignmentCheckVisitor.cs create mode 100644 Test/Parser/ParseUtilCSharp.cs create mode 100644 Test/Parser/ParseUtilVBNet.cs create mode 100644 Test/Parser/SkipMethodBodiesTest.cs create mode 100644 Test/Parser/SnippetParserTests.cs create mode 100644 Test/Parser/Statements/AddHandlerStatementTests.cs create mode 100644 Test/Parser/Statements/BlockStatementTests.cs create mode 100644 Test/Parser/Statements/BreakStatementTests.cs create mode 100644 Test/Parser/Statements/CheckedStatementTests.cs create mode 100644 Test/Parser/Statements/ContinueStatementTests.cs create mode 100644 Test/Parser/Statements/DoLoopStatementTests.cs create mode 100644 Test/Parser/Statements/EmptyStatementTests.cs create mode 100644 Test/Parser/Statements/EndStatementTests.cs create mode 100644 Test/Parser/Statements/EraseStatementTests.cs create mode 100644 Test/Parser/Statements/ErrorStatementTests.cs create mode 100644 Test/Parser/Statements/ExpressionStatementTests.cs create mode 100644 Test/Parser/Statements/FixedStatementTests.cs create mode 100644 Test/Parser/Statements/ForNextStatementTests.cs create mode 100644 Test/Parser/Statements/ForStatementTests.cs create mode 100644 Test/Parser/Statements/ForeachStatementTests.cs create mode 100644 Test/Parser/Statements/GotoCaseStatementTests.cs create mode 100644 Test/Parser/Statements/GotoStatementTests.cs create mode 100644 Test/Parser/Statements/IfElseStatementTests.cs create mode 100644 Test/Parser/Statements/LabelStatementTests.cs create mode 100644 Test/Parser/Statements/LocalVariableDeclarationTests.cs create mode 100644 Test/Parser/Statements/LockStatementTests.cs create mode 100644 Test/Parser/Statements/OnErrorStatementTest.cs create mode 100644 Test/Parser/Statements/RaiseEventStatementTest.cs create mode 100644 Test/Parser/Statements/ReDimStatementTests.cs create mode 100644 Test/Parser/Statements/RemoveHandlerStatement.cs create mode 100644 Test/Parser/Statements/ResumeStatement.cs create mode 100644 Test/Parser/Statements/ReturnStatementTests.cs create mode 100644 Test/Parser/Statements/StopStatementTests.cs create mode 100644 Test/Parser/Statements/SwitchStatementTests.cs create mode 100644 Test/Parser/Statements/ThrowStatementTests.cs create mode 100644 Test/Parser/Statements/TryCatchStatementTests.cs create mode 100644 Test/Parser/Statements/UncheckedStatementTests.cs create mode 100644 Test/Parser/Statements/UnsafeStatementTests.cs create mode 100644 Test/Parser/Statements/UsingStatementTests.cs create mode 100644 Test/Parser/Statements/WithStatementTests.cs create mode 100644 Test/Parser/Statements/YieldStatementTests.cs create mode 100644 Test/Parser/TypeLevel/ConstructorDeclarationTests.cs create mode 100644 Test/Parser/TypeLevel/CustomEventTests.cs create mode 100644 Test/Parser/TypeLevel/DeclareDeclarationTests.cs create mode 100644 Test/Parser/TypeLevel/DestructorDeclarationTests.cs create mode 100644 Test/Parser/TypeLevel/EventDeclarationTests.cs create mode 100644 Test/Parser/TypeLevel/FieldDeclarationTests.cs create mode 100644 Test/Parser/TypeLevel/IndexerDeclarationTests.cs create mode 100644 Test/Parser/TypeLevel/MethodDeclarationTests.cs create mode 100644 Test/Parser/TypeLevel/OperatorDeclarationTests.cs create mode 100644 Test/Parser/TypeLevel/PropertyDeclarationTests.cs diff --git a/NRefactory.sln b/NRefactory.sln new file mode 100644 index 0000000000..1cba4c9052 --- /dev/null +++ b/NRefactory.sln @@ -0,0 +1,44 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# SharpDevelop 4.0.0.5967 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryTests", "Test\NRefactoryTests.csproj", "{870115DD-960A-4406-A6B9-600BCDC36A03}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryASTGenerator", "NRefactoryASTGenerator\NRefactoryASTGenerator.csproj", "{B22522AA-B5BF-4A58-AC6D-D4B45805521F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryDemo", "..\..\..\samples\NRefactoryDemo\NRefactoryDemo.csproj", "{63199047-9D5D-474C-B3CC-62ABBB071B67}" + ProjectSection(ProjectDependencies) = postProject + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} = {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU + {870115DD-960A-4406-A6B9-600BCDC36A03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {870115DD-960A-4406-A6B9-600BCDC36A03}.Debug|Any CPU.Build.0 = Debug|Any CPU + {870115DD-960A-4406-A6B9-600BCDC36A03}.Release|Any CPU.ActiveCfg = Release|Any CPU + {870115DD-960A-4406-A6B9-600BCDC36A03}.Release|Any CPU.Build.0 = Release|Any CPU + {B22522AA-B5BF-4A58-AC6D-D4B45805521F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B22522AA-B5BF-4A58-AC6D-D4B45805521F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B22522AA-B5BF-4A58-AC6D-D4B45805521F}.Release|Any CPU.Build.0 = Release|Any CPU + {B22522AA-B5BF-4A58-AC6D-D4B45805521F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63199047-9D5D-474C-B3CC-62ABBB071B67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63199047-9D5D-474C-B3CC-62ABBB071B67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63199047-9D5D-474C-B3CC-62ABBB071B67}.Release|Any CPU.Build.0 = Release|Any CPU + {63199047-9D5D-474C-B3CC-62ABBB071B67}.Release|Any CPU.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/NRefactoryASTGenerator/AST/Expressions.cs b/NRefactoryASTGenerator/AST/Expressions.cs new file mode 100644 index 0000000000..80b603d95d --- /dev/null +++ b/NRefactoryASTGenerator/AST/Expressions.cs @@ -0,0 +1,436 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace NRefactoryASTGenerator.Ast +{ + [CustomImplementation] + abstract class Expression : AbstractNode, INullable {} + + [CustomImplementation] + class PrimitiveExpression : Expression {} + + enum ParameterModifiers { In } + enum QueryExpressionPartitionType { } + + class ParameterDeclarationExpression : Expression { + List attributes; + [QuestionMarkDefault] + string parameterName; + TypeReference typeReference; + ParameterModifiers paramModifier; + Expression defaultValue; + + public ParameterDeclarationExpression(TypeReference typeReference, string parameterName) {} + public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParameterModifiers paramModifier) {} + public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParameterModifiers paramModifier, Expression defaultValue) {} + } + + class NamedArgumentExpression : Expression { + string name; + Expression expression; + + public NamedArgumentExpression() { } + public NamedArgumentExpression(string name, Expression expression) {} + } + + class MemberInitializerExpression : Expression { + string name; + bool isKey; + Expression expression; + + public MemberInitializerExpression() { } + public MemberInitializerExpression(string name, Expression expression) {} + } + + [IncludeBoolProperty("IsAnonymousType", "return createType.IsNull || string.IsNullOrEmpty(createType.Type);")] + class ObjectCreateExpression : Expression { + TypeReference createType; + List parameters; + CollectionInitializerExpression objectInitializer; + + public ObjectCreateExpression(TypeReference createType, List parameters) {} + } + + [IncludeBoolProperty("IsImplicitlyTyped", "return createType.IsNull || string.IsNullOrEmpty(createType.Type);")] + class ArrayCreateExpression : Expression { + TypeReference createType; + List arguments; + CollectionInitializerExpression arrayInitializer; + + public ArrayCreateExpression(TypeReference createType) {} + public ArrayCreateExpression(TypeReference createType, List arguments) {} + public ArrayCreateExpression(TypeReference createType, CollectionInitializerExpression arrayInitializer) {} + } + + [ImplementNullable(NullableImplementation.Shadow)] + class CollectionInitializerExpression : Expression { + List createExpressions; + + public CollectionInitializerExpression() {} + public CollectionInitializerExpression(List createExpressions) {} + } + + enum AssignmentOperatorType {} + + class AssignmentExpression : Expression { + Expression left; + AssignmentOperatorType op; + Expression right; + + public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right) {} + } + + class BaseReferenceExpression : Expression {} + + enum BinaryOperatorType {} + + class BinaryOperatorExpression : Expression + { + Expression left; + BinaryOperatorType op; + Expression right; + + public BinaryOperatorExpression() { } + public BinaryOperatorExpression(Expression left, BinaryOperatorType op, Expression right) {} + } + + enum CastType {} + + class CastExpression : Expression + { + TypeReference castTo; + Expression expression; + CastType castType; + + public CastExpression(TypeReference castTo) {} + public CastExpression(TypeReference castTo, Expression expression, CastType castType) {} + } + + class MemberReferenceExpression : Expression + { + Expression targetObject; + string memberName; + List typeArguments; + + public MemberReferenceExpression(Expression targetObject, string memberName) {} + } + + class PointerReferenceExpression : Expression { + Expression targetObject; + string memberName; + List typeArguments; + + public PointerReferenceExpression(Expression targetObject, string memberName) {} + } + + class IdentifierExpression : Expression { + string identifier; + List typeArguments; + + public IdentifierExpression(string identifier) {} + } + + class InvocationExpression : Expression { + Expression targetObject; + List arguments; + + public InvocationExpression(Expression targetObject) {} + public InvocationExpression(Expression targetObject, List arguments) {} + } + + class ParenthesizedExpression : Expression { + Expression expression; + + public ParenthesizedExpression(Expression expression) {} + } + + class ThisReferenceExpression : Expression {} + + class TypeOfExpression : Expression { + TypeReference typeReference; + + public TypeOfExpression(TypeReference typeReference) {} + } + + class TypeReferenceExpression : Expression { + TypeReference typeReference; + + public TypeReferenceExpression(TypeReference typeReference) {} + } + + enum UnaryOperatorType {} + + class UnaryOperatorExpression : Expression { + UnaryOperatorType op; + Expression expression; + + public UnaryOperatorExpression(UnaryOperatorType op) {} + public UnaryOperatorExpression(Expression expression, UnaryOperatorType op) {} + } + + class AnonymousMethodExpression : Expression { + List parameters; + BlockStatement body; + bool hasParameterList; + } + + [IncludeMember("public Location ExtendedEndLocation { get; set; }")] + class LambdaExpression : Expression { + List parameters; + Statement statementBody; + Expression expressionBody; + TypeReference returnType; + } + + class CheckedExpression : Expression { + Expression expression; + + public CheckedExpression(Expression expression) {} + } + + class ConditionalExpression : Expression { + Expression condition; + Expression trueExpression; + Expression falseExpression; + + public ConditionalExpression() { } + public ConditionalExpression(Expression condition, Expression trueExpression, Expression falseExpression) {} + } + + class DefaultValueExpression : Expression { + TypeReference typeReference; + + public DefaultValueExpression(TypeReference typeReference) {} + } + + enum FieldDirection {} + + class DirectionExpression : Expression { + FieldDirection fieldDirection; + Expression expression; + + public DirectionExpression(FieldDirection fieldDirection, Expression expression) {} + } + + class IndexerExpression : Expression { + Expression targetObject; + List indexes; + + public IndexerExpression(Expression targetObject, List indexes) {} + } + + class SizeOfExpression : Expression { + TypeReference typeReference; + + public SizeOfExpression(TypeReference typeReference) {} + } + + class StackAllocExpression : Expression { + TypeReference typeReference; + Expression expression; + + public StackAllocExpression(TypeReference typeReference, Expression expression) {} + } + + class UncheckedExpression : Expression { + Expression expression; + + public UncheckedExpression(Expression expression) {} + } + + class AddressOfExpression : Expression { + Expression expression; + + public AddressOfExpression(Expression expression) {} + } + + class ClassReferenceExpression : Expression {} + + class TypeOfIsExpression : Expression { + Expression expression; + TypeReference typeReference; + + public TypeOfIsExpression(Expression expression, TypeReference typeReference) {} + } + + [ImplementNullable(NullableImplementation.Shadow)] + class QueryExpression : Expression { + + /// + /// Either from or aggregate clause. + /// + QueryExpressionFromClause fromClause; + + bool isQueryContinuation; + + List middleClauses; + + /// + /// C# only. + /// + QueryExpressionClause selectOrGroupClause; + } + + class QueryExpressionVB : Expression { + List clauses; + } + + [ImplementNullable] + abstract class QueryExpressionClause : AbstractNode, INullable { } + + class QueryExpressionWhereClause : QueryExpressionClause { + Expression condition; + } + + class QueryExpressionLetClause : QueryExpressionClause { + [QuestionMarkDefault] + string identifier; + Expression expression; + } + + [ImplementNullable(NullableImplementation.Shadow)] + class QueryExpressionFromClause : QueryExpressionClause { + List sources; + } + + class QueryExpressionAggregateClause : QueryExpressionClause { + CollectionRangeVariable source; + List middleClauses; + List intoVariables; + } + + [ImplementNullable] + class ExpressionRangeVariable : AbstractNode, INullable { + string identifier; + Expression expression; + TypeReference type; + } + + [ImplementNullable] + class CollectionRangeVariable : AbstractNode, INullable { + string identifier; + Expression expression; + TypeReference type; + } + + class QueryExpressionJoinClause : QueryExpressionClause { + Expression onExpression; + Expression equalsExpression; + CollectionRangeVariable source; + + string intoIdentifier; + } + + [ImplementNullable(NullableImplementation.Shadow)] + class QueryExpressionJoinVBClause : QueryExpressionClause { + CollectionRangeVariable joinVariable; + QueryExpressionJoinVBClause subJoin; + List conditions; + } + + class QueryExpressionPartitionVBClause : QueryExpressionClause { + Expression expression; + QueryExpressionPartitionType partitionType; + } + + class QueryExpressionJoinConditionVB : AbstractNode { + Expression leftSide; + Expression rightSide; + } + + class QueryExpressionOrderClause : QueryExpressionClause { + List orderings; + } + + class QueryExpressionOrdering : AbstractNode { + Expression criteria; + QueryExpressionOrderingDirection direction; + } + + enum QueryExpressionOrderingDirection { + None, Ascending, Descending + } + + class QueryExpressionSelectClause : QueryExpressionClause { + Expression projection; + } + + class QueryExpressionSelectVBClause : QueryExpressionClause { + List variables; + } + + class QueryExpressionLetVBClause : QueryExpressionClause { + List variables; + } + + class QueryExpressionDistinctClause : QueryExpressionClause { + + } + + class QueryExpressionGroupClause : QueryExpressionClause { + Expression projection; + Expression groupBy; + } + + class QueryExpressionGroupVBClause : QueryExpressionClause { + List groupVariables; + List byVariables; + List intoVariables; + } + + class QueryExpressionGroupJoinVBClause : QueryExpressionClause { + QueryExpressionJoinVBClause joinClause; + List intoVariables; + } + + enum XmlAxisType { } + + class XmlMemberAccessExpression : Expression { + Expression targetObject; + XmlAxisType axisType; + bool isXmlIdentifier; + string identifier; + + public XmlMemberAccessExpression(Expression targetObject, XmlAxisType axisType, string identifier, bool isXmlIdentifier) {} + } + + abstract class XmlExpression : Expression { } + + class XmlDocumentExpression : XmlExpression { + List expressions; + } + + enum XmlContentType { } + + class XmlContentExpression : XmlExpression { + string content; + XmlContentType type; + + public XmlContentExpression(string content, XmlContentType type) {} + } + + class XmlEmbeddedExpression : XmlExpression { + Expression inlineVBExpression; + } + + [IncludeBoolProperty("IsExpression", "return !content.IsNull;")] + [IncludeBoolProperty("NameIsExpression", "return !nameExpression.IsNull;")] + [HasChildren] + class XmlElementExpression : XmlExpression { + Expression content; + Expression nameExpression; + string xmlName; + List attributes; + } + + [IncludeBoolProperty("IsLiteralValue", "return expressionValue.IsNull;")] + class XmlAttributeExpression : XmlExpression { + string name; + string literalValue; + bool useDoubleQuotes; + Expression expressionValue; + } +} diff --git a/NRefactoryASTGenerator/AST/GlobalLevel.cs b/NRefactoryASTGenerator/AST/GlobalLevel.cs new file mode 100644 index 0000000000..033e737435 --- /dev/null +++ b/NRefactoryASTGenerator/AST/GlobalLevel.cs @@ -0,0 +1,107 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace NRefactoryASTGenerator.Ast +{ + [CustomImplementation, HasChildren] + class CompilationUnit : AbstractNode {} + + [HasChildren] + class NamespaceDeclaration : AbstractNode + { + string name; + + public NamespaceDeclaration(string name) {} + } + + enum VarianceModifier { Invariant, Covariant, Contravariant }; + + class TemplateDefinition : AttributedNode + { + [QuestionMarkDefault] + string name; + VarianceModifier varianceModifier; + List bases; + + public TemplateDefinition() {} + public TemplateDefinition(string name, List attributes) : base(attributes) {} + } + + class DelegateDeclaration : AttributedNode + { + [QuestionMarkDefault] + string name; + TypeReference returnType; + List parameters; + List templates; + + public DelegateDeclaration(Modifiers modifier, List attributes) : base(modifier, attributes) {} + } + + enum ClassType { Class } + + [HasChildren] + class TypeDeclaration : AttributedNode + { + // Children of Struct: FieldDeclaration, MethodDeclaration, EventDeclaration, ConstructorDeclaration, + // OperatorDeclaration, TypeDeclaration, IndexerDeclaration, PropertyDeclaration, in VB: DeclareDeclaration + // Childrean of class: children of struct, DestructorDeclaration + // Children of Interface: MethodDeclaration, PropertyDeclaration, IndexerDeclaration, EventDeclaration, in VB: TypeDeclaration(Enum) too + // Children of Enum: FieldDeclaration + string name; + ClassType type; + List baseTypes; + List templates; + Location bodyStartLocation; + + public TypeDeclaration(Modifiers modifier, List attributes) : base(modifier, attributes) {} + } + + [IncludeBoolProperty("IsAlias", "return !alias.IsNull;")] + [IncludeBoolProperty("IsXml", "return xmlPrefix != null;")] + class Using : AbstractNode + { + [QuestionMarkDefault] + string name; + TypeReference alias; + string xmlPrefix; + + public Using(string name) {} + public Using(string name, TypeReference alias) {} + public Using(string name, string xmlPrefix) {} + } + + [IncludeMember("public UsingDeclaration(string @namespace) : this(@namespace, TypeReference.Null) {}")] + [IncludeMember("public UsingDeclaration(string @namespace, TypeReference alias) {" + + " usings = new List(1);" + + " usings.Add(new Using(@namespace, alias)); " + + "}")] + [IncludeMember("public UsingDeclaration(string xmlNamespace, string prefix) {" + + " usings = new List(1);" + + " usings.Add(new Using(xmlNamespace, prefix)); " + + "}")] + class UsingDeclaration : AbstractNode + { + List usings; + + public UsingDeclaration(List usings) {} + } + + enum OptionType { None } + + class OptionDeclaration : AbstractNode + { + OptionType optionType; + bool optionValue; + + public OptionDeclaration(OptionType optionType, bool optionValue) {} + } + + class ExternAliasDirective : AbstractNode + { + string name; + } +} diff --git a/NRefactoryASTGenerator/AST/Node.cs b/NRefactoryASTGenerator/AST/Node.cs new file mode 100644 index 0000000000..bd791aeae1 --- /dev/null +++ b/NRefactoryASTGenerator/AST/Node.cs @@ -0,0 +1,68 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace NRefactoryASTGenerator.Ast +{ + interface INode {} + interface INullable {} + struct Location {} + + enum Modifiers { None } + + [CustomImplementation] + abstract class AbstractNode : INode {} + + abstract class AttributedNode : AbstractNode + { + List attributes; + Modifiers modifier; + + public AttributedNode() {} + public AttributedNode(List attributes) {} + public AttributedNode(Modifiers modifier, List attributes) {} + } + + abstract class ParametrizedNode : AttributedNode + { + string name; + List parameters; + + public ParametrizedNode() {} + + public ParametrizedNode(Modifiers modifier, List attributes, + string name, List parameters) + : base(modifier, attributes) + {} + } + + [CustomImplementation] + class TypeReference : AbstractNode, INullable + { + List genericTypes; + } + + [CustomImplementation] + class InnerClassTypeReference : TypeReference + { + TypeReference baseType; + } + + class AttributeSection : AbstractNode, INullable + { + string attributeTarget; + List attributes; + } + + class Attribute : AbstractNode + { + string name; + List positionalArguments; + List namedArguments; + + public Attribute() {} + public Attribute(string name, List positionalArguments, List namedArguments) {} + } +} diff --git a/NRefactoryASTGenerator/AST/Statements.cs b/NRefactoryASTGenerator/AST/Statements.cs new file mode 100644 index 0000000000..5657bafa78 --- /dev/null +++ b/NRefactoryASTGenerator/AST/Statements.cs @@ -0,0 +1,313 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace NRefactoryASTGenerator.Ast +{ + [CustomImplementation] + abstract class Statement : AbstractNode, INullable {} + + [CustomImplementation] + abstract class StatementWithEmbeddedStatement : Statement { + Statement embeddedStatement; + } + + [CustomImplementation, HasChildren] + class BlockStatement : Statement {} + + class BreakStatement : Statement {} + + enum ContinueType {} + + class ContinueStatement : Statement { + ContinueType continueType; + + public ContinueStatement() {} + public ContinueStatement(ContinueType continueType) {} + } + + enum ConditionType {} + enum ConditionPosition {} + + class DoLoopStatement : StatementWithEmbeddedStatement { + Expression condition; + ConditionType conditionType; + ConditionPosition conditionPosition; + + public DoLoopStatement(Expression condition, Statement embeddedStatement, ConditionType conditionType, ConditionPosition conditionPosition) {} + } + + class ForeachStatement : StatementWithEmbeddedStatement { + TypeReference typeReference; + string variableName; + Expression expression; + Expression nextExpression; + + public ForeachStatement(TypeReference typeReference, string variableName, Expression expression, Statement embeddedStatement) {} + public ForeachStatement(TypeReference typeReference, string variableName, Expression expression, Statement embeddedStatement, Expression nextExpression) {} + } + + class ForStatement : StatementWithEmbeddedStatement { + List initializers; + Expression condition; + List iterator; + + public ForStatement(List initializers, Expression condition, List iterator, Statement embeddedStatement) {} + } + + class GotoStatement : Statement { + string label; + + public GotoStatement(string label) {} + } + + [IncludeMember(@" + public IfElseStatement(Expression condition, Statement trueStatement) + : this(condition) { + this.trueStatement.Add(Statement.CheckNull(trueStatement)); + if (trueStatement != null) trueStatement.Parent = this; + }")] + [IncludeMember(@" + public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement) + : this(condition) { + this.trueStatement.Add(Statement.CheckNull(trueStatement)); + this.falseStatement.Add(Statement.CheckNull(falseStatement)); + if (trueStatement != null) trueStatement.Parent = this; + if (falseStatement != null) falseStatement.Parent = this; + }")] + [IncludeBoolProperty("HasElseStatements", "return falseStatement.Count > 0;")] + [IncludeBoolProperty("HasElseIfSections", "return elseIfSections.Count > 0;")] + class IfElseStatement : Statement { + Expression condition; + List trueStatement; // List for stmt : stmt : stmt ... in VB.NET + List falseStatement; + List elseIfSections; + + public IfElseStatement(Expression condition) {} + } + + class ElseIfSection : StatementWithEmbeddedStatement { + Expression condition; + + public ElseIfSection(Expression condition, Statement embeddedStatement) {} + } + + class LabelStatement : Statement { + string label; + + public LabelStatement(string label) {} + } + + [CustomImplementation] + class LocalVariableDeclaration : Statement { + TypeReference typeReference; + Modifiers modifier; + List variables; + } + + class LockStatement : StatementWithEmbeddedStatement + { + Expression lockExpression; + + public LockStatement(Expression lockExpression, Statement embeddedStatement) {} + } + + class ReturnStatement : Statement + { + Expression expression; + + public ReturnStatement(Expression expression) { } + } + + class ExpressionStatement : Statement { + Expression expression; + + public ExpressionStatement(Expression expression) {} + } + + class SwitchStatement : Statement { + Expression switchExpression; + List switchSections; + + public SwitchStatement(Expression switchExpression, List switchSections) {} + } + + class SwitchSection : BlockStatement { + List switchLabels; + + public SwitchSection() { } + public SwitchSection(List switchLabels) { } + } + + [IncludeBoolProperty("IsDefault", "return label.IsNull;")] + class CaseLabel : AbstractNode { + Expression label; + BinaryOperatorType binaryOperatorType; + Expression toExpression; + + public CaseLabel() {} + public CaseLabel(Expression label) {} + public CaseLabel(Expression label, Expression toExpression) {} + public CaseLabel(BinaryOperatorType binaryOperatorType, Expression label) {} + } + + class ThrowStatement : Statement { + Expression expression; + + public ThrowStatement(Expression expression) {} + } + + class TryCatchStatement : Statement { + Statement statementBlock; + List catchClauses; + Statement finallyBlock; + + public TryCatchStatement(Statement statementBlock, List catchClauses, Statement finallyBlock) {} + } + + class CatchClause : AbstractNode { + TypeReference typeReference; + string variableName; + Statement statementBlock; + Expression condition; + + public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock) {} + public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock, Expression condition) {} + public CatchClause(Statement statementBlock) {} + } + + class CheckedStatement : Statement { + Statement block; + + public CheckedStatement(Statement block) {} + } + + class EmptyStatement : Statement {} + + class FixedStatement : StatementWithEmbeddedStatement { + Statement pointerDeclaration; + + public FixedStatement(Statement pointerDeclaration, Statement embeddedStatement) {} + } + + [IncludeBoolProperty("IsDefaultCase", "return expression.IsNull;")] + class GotoCaseStatement : Statement { + Expression expression; + + public GotoCaseStatement(Expression expression) {} + } + + class UncheckedStatement : Statement { + Statement block; + + public UncheckedStatement(Statement block) {} + } + + class UnsafeStatement : Statement { + Statement block; + + public UnsafeStatement(Statement block) {} + } + + class UsingStatement : StatementWithEmbeddedStatement { + Statement resourceAcquisition; + + public UsingStatement(Statement resourceAcquisition, Statement embeddedStatement) {} + } + + [IncludeBoolProperty("IsYieldReturn", "return statement is ReturnStatement;")] + [IncludeBoolProperty("IsYieldBreak", "return statement is BreakStatement;")] + class YieldStatement : Statement { + Statement statement; + + public YieldStatement(Statement statement) {} + } + + class AddHandlerStatement : Statement { + Expression eventExpression; + Expression handlerExpression; + + public AddHandlerStatement(Expression eventExpression, Expression handlerExpression) {} + } + + class EndStatement : Statement {} + + class EraseStatement : Statement { + List expressions; + + public EraseStatement() {} + public EraseStatement(List expressions) {} + } + + class ErrorStatement : Statement { + Expression expression; + + public ErrorStatement(Expression expression) {} + } + + enum ExitType {} + + class ExitStatement : Statement { + ExitType exitType; + + public ExitStatement(ExitType exitType) {} + } + + class ForNextStatement : StatementWithEmbeddedStatement { + Expression start; + Expression end; + Expression step; + + List nextExpressions; + // either use typeReference+variableName + TypeReference typeReference; + string variableName; + // or use loopVariableExpression: + Expression loopVariableExpression; + } + + class OnErrorStatement : StatementWithEmbeddedStatement { + public OnErrorStatement(Statement embeddedStatement) {} + } + + class RaiseEventStatement : Statement { + string eventName; + List arguments; + + public RaiseEventStatement(string eventName, List arguments) {} + } + + class ReDimStatement : Statement { + List reDimClauses; + bool isPreserve; + + public ReDimStatement(bool isPreserve) {} + } + + class RemoveHandlerStatement : Statement { + Expression eventExpression; + Expression handlerExpression; + + public RemoveHandlerStatement(Expression eventExpression, Expression handlerExpression) {} + } + + class ResumeStatement : Statement { + string labelName; + bool isResumeNext; + + public ResumeStatement(bool isResumeNext) {} + + public ResumeStatement(string labelName) {} + } + + class StopStatement : Statement {} + + class WithStatement : Statement { + Expression expression; + BlockStatement body; + + public WithStatement(Expression expression) {} + } +} diff --git a/NRefactoryASTGenerator/AST/TypeLevel.cs b/NRefactoryASTGenerator/AST/TypeLevel.cs new file mode 100644 index 0000000000..ea901cabca --- /dev/null +++ b/NRefactoryASTGenerator/AST/TypeLevel.cs @@ -0,0 +1,235 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace NRefactoryASTGenerator.Ast +{ + class VariableDeclaration : AbstractNode + { + string name; + Expression initializer; + TypeReference typeReference; + Expression fixedArrayInitialization; + + public VariableDeclaration(string name) {} + public VariableDeclaration(string name, Expression initializer) {} + public VariableDeclaration(string name, Expression initializer, TypeReference typeReference) {} + } + + class ConstructorDeclaration : ParametrizedNode + { + ConstructorInitializer constructorInitializer; + BlockStatement body; + + public ConstructorDeclaration(string name, Modifiers modifier, + List parameters, + List attributes) + : base(modifier, attributes, name, parameters) + {} + + public ConstructorDeclaration(string name, Modifiers modifier, + List parameters, + ConstructorInitializer constructorInitializer, + List attributes) + : base(modifier, attributes, name, parameters) + {} + } + + enum ConstructorInitializerType { None } + + [ImplementNullable] + class ConstructorInitializer : AbstractNode, INullable + { + ConstructorInitializerType constructorInitializerType; + List arguments; + } + + [ImplementNullable(NullableImplementation.Abstract)] + abstract class EventAddRemoveRegion : AttributedNode, INullable + { + BlockStatement block; + List parameters; + + public EventAddRemoveRegion(List attributes) : base(attributes) {} + } + + [ImplementNullable(NullableImplementation.CompleteAbstract)] + class EventAddRegion : EventAddRemoveRegion + { + public EventAddRegion(List attributes) : base(attributes) {} + } + + [ImplementNullable(NullableImplementation.CompleteAbstract)] + class EventRemoveRegion : EventAddRemoveRegion + { + public EventRemoveRegion(List attributes) : base(attributes) {} + } + + [ImplementNullable(NullableImplementation.CompleteAbstract)] + class EventRaiseRegion : EventAddRemoveRegion + { + public EventRaiseRegion(List attributes) : base(attributes) {} + } + + class InterfaceImplementation : AbstractNode + { + TypeReference interfaceType; + [QuestionMarkDefault] + string memberName; + + public InterfaceImplementation(TypeReference interfaceType, string memberName) {} + } + + [IncludeBoolProperty("HasAddRegion", "return !addRegion.IsNull;")] + [IncludeBoolProperty("HasRemoveRegion", "return !removeRegion.IsNull;")] + [IncludeBoolProperty("HasRaiseRegion", "return !raiseRegion.IsNull;")] + class EventDeclaration : MemberNode + { + EventAddRegion addRegion; + EventRemoveRegion removeRegion; + EventRaiseRegion raiseRegion; + Location bodyStart; + Location bodyEnd; + Expression initializer; + } + + [IncludeMember(@" + public TypeReference GetTypeForField(int fieldIndex) + { + if (!typeReference.IsNull) { + return typeReference; + } + return ((VariableDeclaration)Fields[fieldIndex]).TypeReference; + }")] + [IncludeMember(@" + public VariableDeclaration GetVariableDeclaration(string variableName) + { + foreach (VariableDeclaration variableDeclaration in Fields) { + if (variableDeclaration.Name == variableName) { + return variableDeclaration; + } + } + return null; + }")] + class FieldDeclaration : AttributedNode + { + TypeReference typeReference; + List fields; + + // for enum members + public FieldDeclaration(List attributes) : base(attributes) {} + + // for all other cases + public FieldDeclaration(List attributes, TypeReference typeReference, Modifiers modifier) + : base(modifier, attributes) + {} + } + + abstract class MemberNode : ParametrizedNode + { + List interfaceImplementations; + TypeReference typeReference; + + public MemberNode() {} + + public MemberNode(Modifiers modifier, List attributes, + string name, List parameters) + : base(modifier, attributes, name, parameters) + {} + } + + class MethodDeclaration : MemberNode + { + BlockStatement body; + List handlesClause; + List templates; + bool isExtensionMethod; + } + + enum ConversionType { None } + enum OverloadableOperatorType { None } + + [IncludeBoolProperty("IsConversionOperator", "return conversionType != ConversionType.None;")] + class OperatorDeclaration : MethodDeclaration + { + ConversionType conversionType; + OverloadableOperatorType overloadableOperator; + } + + [IncludeBoolProperty("HasGetRegion", "return !getRegion.IsNull;")] + [IncludeBoolProperty("HasSetRegion", "return !setRegion.IsNull;")] + [IncludeBoolProperty("IsReadOnly", "return HasGetRegion && !HasSetRegion;")] + [IncludeBoolProperty("IsWriteOnly", "return !HasGetRegion && HasSetRegion;")] + [IncludeBoolProperty("IsIndexer", "return (Modifier & Modifiers.Default) != 0;")] + [IncludeMember(@" + internal PropertyDeclaration(string name, TypeReference typeReference, Modifiers modifier, List attributes) : this(modifier, attributes, name, null) + { + this.TypeReference = typeReference; + if ((modifier & Modifiers.ReadOnly) != Modifiers.ReadOnly) { + this.SetRegion = new PropertySetRegion(null, null); + } + if ((modifier & Modifiers.WriteOnly) != Modifiers.WriteOnly) { + this.GetRegion = new PropertyGetRegion(null, null); + } + }")] + class PropertyDeclaration : MemberNode + { + Location bodyStart; + Location bodyEnd; + PropertyGetRegion getRegion; + PropertySetRegion setRegion; + Expression initializer; + + public PropertyDeclaration(Modifiers modifier, List attributes, + string name, List parameters) + : base(modifier, attributes, name, parameters) + {} + } + + [ImplementNullable(NullableImplementation.Abstract)] + abstract class PropertyGetSetRegion : AttributedNode, INullable + { + // can be null if only the definition is there (interface declaration) + BlockStatement block; + + public PropertyGetSetRegion(BlockStatement block, List attributes) : base(attributes) {} + } + + [ImplementNullable(NullableImplementation.CompleteAbstract)] + class PropertyGetRegion : PropertyGetSetRegion + { + public PropertyGetRegion(BlockStatement block, List attributes) : base(block, attributes) {} + } + + [ImplementNullable(NullableImplementation.CompleteAbstract)] + class PropertySetRegion : PropertyGetSetRegion + { + List parameters; + + public PropertySetRegion(BlockStatement block, List attributes) : base(block, attributes) {} + } + + class DestructorDeclaration : AttributedNode + { + string name; + BlockStatement body; + + public DestructorDeclaration(string name, Modifiers modifier, List attributes) : base(modifier, attributes) {} + } + + enum CharsetModifier { None } + + class DeclareDeclaration : ParametrizedNode + { + string alias; + string library; + CharsetModifier charset; + TypeReference typeReference; + + public DeclareDeclaration(string name, Modifiers modifier, TypeReference typeReference, List parameters, List attributes, string library, string alias, CharsetModifier charset) + : base(modifier, attributes, name, parameters) + {} + } +} diff --git a/NRefactoryASTGenerator/AssemblyInfo.cs b/NRefactoryASTGenerator/AssemblyInfo.cs new file mode 100644 index 0000000000..79b1055f2f --- /dev/null +++ b/NRefactoryASTGenerator/AssemblyInfo.cs @@ -0,0 +1,29 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("NRefactory AST Generator")] +[assembly: AssemblyDescription("Parser and refactoring library for C# and VB.NET")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("ic#code")] +[assembly: AssemblyProduct("SharpDevelop")] +[assembly: AssemblyCopyright("2006 AlphaSierraPapa")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("2.0.0.1")] diff --git a/NRefactoryASTGenerator/Attributes.cs b/NRefactoryASTGenerator/Attributes.cs new file mode 100644 index 0000000000..3a492d00a5 --- /dev/null +++ b/NRefactoryASTGenerator/Attributes.cs @@ -0,0 +1,176 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.CodeDom; +using System.Reflection; +using ICSharpCode.EasyCodeDom; + +namespace NRefactoryASTGenerator +{ + public enum NullableImplementation + { + /// + /// Implement INullable with a virtual bool IsNull, create Null class and static instance + /// of it. + /// + Default, + /// + /// Create Null class and a static instance using the "new" modifier. + /// + Shadow, + /// + /// Implement INullable with a virtual bool IsNull. + /// + Abstract, + /// + /// Complete an abstract nullable implementation by creating the Null class + /// and the static instance. + /// + CompleteAbstract + } + + public abstract class TypeImplementationModifierAttribute : Attribute + { + public abstract void ModifyImplementation(CodeNamespace cns, CodeTypeDeclaration ctd, Type type); + } + + [AttributeUsage(AttributeTargets.Class)] + public class CustomImplementationAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Class)] + public class HasChildrenAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Field)] + public class QuestionMarkDefaultAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] + public class IncludeMemberAttribute : TypeImplementationModifierAttribute + { + string code; + + public IncludeMemberAttribute(string code) + { + this.code = code; + } + + public override void ModifyImplementation(CodeNamespace cns, CodeTypeDeclaration ctd, Type type) + { + ctd.Members.Add(new CodeSnippetTypeMember(code)); + } + } + + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] + public class IncludeBoolPropertyAttribute : TypeImplementationModifierAttribute + { + string name; + string code; + + public IncludeBoolPropertyAttribute(string name, string code) + { + this.name = name; + this.code = code; + } + + public override void ModifyImplementation(CodeNamespace cns, CodeTypeDeclaration ctd, Type type) + { + CodeMemberProperty prop = new CodeMemberProperty(); + prop.Name = name; + prop.Type = new CodeTypeReference(typeof(bool)); + prop.Attributes = MemberAttributes.Public | MemberAttributes.Final; + prop.GetStatements.Add(new CodeSnippetStatement("\t\t\t\t" + code)); + ctd.Members.Add(prop); + } + } + + [AttributeUsage(AttributeTargets.Class)] + public class ImplementNullableAttribute : TypeImplementationModifierAttribute + { + NullableImplementation implementation; + + public ImplementNullableAttribute() + { + this.implementation = NullableImplementation.Default; + } + + public ImplementNullableAttribute(NullableImplementation implementation) + { + this.implementation = implementation; + } + + public override void ModifyImplementation(CodeNamespace cns, CodeTypeDeclaration ctd, Type type) + { + if (implementation == NullableImplementation.Default || implementation == NullableImplementation.Abstract) { + ctd.BaseTypes.Add(new CodeTypeReference("INullable")); + CodeMemberProperty prop = new CodeMemberProperty(); + prop.Name = "IsNull"; + prop.Type = new CodeTypeReference(typeof(bool)); + prop.Attributes = MemberAttributes.Public; + prop.GetStatements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(false))); + ctd.Members.Add(prop); + } + if (implementation != NullableImplementation.Abstract) { + CodeTypeDeclaration newType = new CodeTypeDeclaration("Null" + ctd.Name); + newType.TypeAttributes = TypeAttributes.Class | TypeAttributes.NotPublic | TypeAttributes.Sealed; + newType.BaseTypes.Add(new CodeTypeReference(ctd.Name)); + cns.Types.Add(newType); + + System.Reflection.ConstructorInfo baseCtor = MainClass.GetBaseCtor(type); + if (baseCtor != null) { + CodeConstructor ctor = new CodeConstructor(); + ctor.Attributes = MemberAttributes.Private; + foreach (object o in baseCtor.GetParameters()) { + ctor.BaseConstructorArgs.Add(new CodePrimitiveExpression(null)); + } + newType.Members.Add(ctor); + } + + CodeMemberField field = new CodeMemberField(newType.Name, "Instance"); + field.Attributes = MemberAttributes.Static | MemberAttributes.Assembly; + field.InitExpression = new CodeObjectCreateExpression(new CodeTypeReference(newType.Name)); + newType.Members.Add(field); + + CodeMemberProperty prop = new CodeMemberProperty(); + prop.Name = "IsNull"; + prop.Type = new CodeTypeReference(typeof(bool)); + prop.Attributes = MemberAttributes.Public | MemberAttributes.Override; + prop.GetStatements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(true))); + newType.Members.Add(prop); + + CodeMemberMethod method = new CodeMemberMethod(); + method.Name = "AcceptVisitor"; + method.Attributes = MemberAttributes.Public | MemberAttributes.Override; + method.Parameters.Add(new CodeParameterDeclarationExpression("IAstVisitor", "visitor")); + method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "data")); + method.ReturnType = new CodeTypeReference(typeof(object)); + method.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(null))); + newType.Members.Add(method); + + method = new CodeMemberMethod(); + method.Name = "ToString"; + method.Attributes = MemberAttributes.Public | MemberAttributes.Override; + method.ReturnType = new CodeTypeReference(typeof(string)); + method.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression("[" + newType.Name + "]"))); + newType.Members.Add(method); + + prop = new CodeMemberProperty(); + prop.Name = "Null"; + prop.Type = new CodeTypeReference(ctd.Name); + prop.Attributes = MemberAttributes.Public | MemberAttributes.Static; + if (implementation == NullableImplementation.Shadow) { + prop.Attributes |= MemberAttributes.New; + } + CodeExpression ex = new CodeTypeReferenceExpression(newType.Name); + ex = new CodePropertyReferenceExpression(ex, "Instance"); + prop.GetStatements.Add(new CodeMethodReturnStatement(ex)); + ctd.Members.Add(prop); + } + } + } +} diff --git a/NRefactoryASTGenerator/KeywordGenerator.cs b/NRefactoryASTGenerator/KeywordGenerator.cs new file mode 100644 index 0000000000..4bc3aaa281 --- /dev/null +++ b/NRefactoryASTGenerator/KeywordGenerator.cs @@ -0,0 +1,388 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; + +namespace NRefactoryASTGenerator +{ + static class KeywordGenerator + { + static readonly string baseDir = "../../../Project/Src/Lexer/"; + static readonly string testBaseDir = "../../../Test/Lexer/"; + static readonly string parserBaseDir = "../../../Project/Src/Parser/"; + + public static void Generate() + { + Generate("CSharp"); + Generate("VBNet"); + } + + static void Generate(string language) + { + try { + Dictionary properties = new Dictionary(); + Dictionary sets = new Dictionary(); + List keywords = new List(); + List terminals = new List(); + Dictionary specialChars = new Dictionary(); + + ReadFile(properties, sets, keywords, terminals, specialChars, language); + + GenerateFiles(properties, sets, keywords, terminals, specialChars, language); + } catch (Exception e) { + Debug.Print(e.ToString()); + } + } + + static void GenerateFiles(Dictionary properties, Dictionary sets, + List keywords, List terminals, Dictionary specialChars, + string language) + { + GenerateKeywords(properties, keywords, language); + GenerateTokens(properties, sets, keywords, terminals, specialChars, language); + GenerateTests(keywords, specialChars, language); + GenerateKeywordSection(keywords, terminals, specialChars, language); + } + + static void GenerateKeywordSection(List keywords, List terminals, Dictionary specialChars, string language) + { + string sourceDir = Path.Combine(parserBaseDir, language, (language == "CSharp" ? "cs" : language) + ".atg"); + StringBuilder builder = new StringBuilder(); + + builder.AppendLine("/* START AUTOGENERATED TOKENS SECTION */"); + builder.AppendLine("TOKENS"); + builder.AppendLine("\t/* ----- terminal classes ----- */"); + builder.AppendLine("\t/* EOF is 0 */"); + + foreach (string terminal in terminals) { + if (terminal == "EOF") + continue; + if (terminal == "Identifier") { + builder.AppendLine("\tident"); + continue; + } + builder.AppendLine("\t" + terminal); + } + + builder.AppendLine(); + builder.AppendLine("\t/* ----- special character ----- */"); + foreach (string specialChar in specialChars.Values) { + builder.AppendLine("\t" + specialChar); + } + + builder.AppendLine(); + builder.AppendLine("\t/* ----- keywords ----- */"); + foreach (string keyword in keywords) { + builder.AppendLine("\t\"" + keyword + "\""); + } + + builder.AppendLine("/* END AUTOGENERATED TOKENS SECTION */"); + + string[] generatedLines = builder.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None); + string[] lines = File.ReadAllLines(sourceDir); + + var newContent = lines + .TakeWhile(l => l != "/* START AUTOGENERATED TOKENS SECTION */") + .Concat(generatedLines) + .Concat(lines.SkipWhile(l => l != "/* END AUTOGENERATED TOKENS SECTION */").Skip(2)) + .ToArray(); + + File.WriteAllLines(sourceDir, newContent); + } + + static void GenerateTests(List keywords, Dictionary specialChars, string language) + { + string sourceDir = Path.Combine(testBaseDir, language, "LexerTests.cs"); + using (StreamWriter writer = new StreamWriter(new FileStream(sourceDir, FileMode.Create))) { + writer.WriteLine("// this file was autogenerated by a tool."); + writer.WriteLine("using System;"); + writer.WriteLine("using System.IO;"); + writer.WriteLine("using NUnit.Framework;"); + writer.WriteLine("using ICSharpCode.NRefactory.Parser;"); + writer.WriteLine("using ICSharpCode.NRefactory.Parser.{0};", language == "VBNet" ? "VB" : language); + writer.WriteLine("using ICSharpCode.NRefactory.PrettyPrinter;"); + writer.WriteLine(); + writer.WriteLine("namespace ICSharpCode.NRefactory.Tests.Lexer.{0}", language == "VBNet" ? "VB" : language); + writer.WriteLine("{"); + writer.WriteLine("\t[TestFixture]"); + writer.WriteLine("\tpublic sealed class LexerTests"); + writer.WriteLine("\t{"); + writer.WriteLine("\t\tILexer GenerateLexer(StringReader sr)"); + writer.WriteLine("\t\t{"); + writer.WriteLine("\t\t\treturn ParserFactory.CreateLexer(SupportedLanguage.{0}, sr);", language); + writer.WriteLine("\t\t}"); + for (int i = 0; i < specialChars.Values.Count; i++) { + writer.WriteLine(); + writer.WriteLine("\t\t[Test]"); + writer.WriteLine("\t\tpublic void Test{0}()", specialChars.Keys.ElementAt(i)); + writer.WriteLine("\t\t{"); + writer.WriteLine("\t\t\tILexer lexer = GenerateLexer(new StringReader({0}));", specialChars.Values.ElementAt(i)); + writer.WriteLine("\t\t\tAssert.AreEqual(Tokens.{0}, lexer.NextToken().Kind);", specialChars.Keys.ElementAt(i)); + writer.WriteLine("\t\t}"); + } + foreach (string keyword in keywords) { + if (keyword == "Rem") + continue; + writer.WriteLine(); + writer.WriteLine("\t\t[Test]"); + writer.WriteLine("\t\tpublic void Test{0}()", UpperCaseFirst(keyword)); + writer.WriteLine("\t\t{"); + writer.WriteLine("\t\t\tILexer lexer = GenerateLexer(new StringReader(\"{0}\"));", keyword); + writer.WriteLine("\t\t\tAssert.AreEqual(Tokens.{0}, lexer.NextToken().Kind);", UpperCaseFirst(keyword)); + writer.WriteLine("\t\t}"); + } + writer.WriteLine("\t}"); + writer.WriteLine("}"); + } + } + + static void GenerateTokens(Dictionary properties, Dictionary sets, List keywords, List terminals, Dictionary specialChars, string language) + { + string sourceDir = Path.Combine(baseDir, language, "Tokens.cs"); + using (StreamWriter writer = new StreamWriter(new FileStream(sourceDir, FileMode.Create))) { + writer.WriteLine("// this file was autogenerated by a tool."); + writer.WriteLine("using System;"); + writer.WriteLine("using System.Collections;"); + writer.WriteLine(); + writer.WriteLine("namespace {0}", properties["Namespace"]); + writer.WriteLine("{"); + writer.WriteLine("\tpublic static class Tokens"); + writer.WriteLine("\t{"); + writer.WriteLine("\t\t// ----- terminal classes -----"); + int tokenValue = 0; + foreach (string terminal in terminals) + writer.WriteToken(terminal, ref tokenValue); + writer.WriteLine(); + writer.WriteLine("\t\t// ----- special character -----"); + foreach (string specialChar in specialChars.Keys) + writer.WriteToken(specialChar, ref tokenValue); + writer.WriteLine(); + writer.WriteLine("\t\t// ----- keywords -----"); + foreach (string keyword in keywords) + writer.WriteToken(keyword, ref tokenValue); + writer.WriteLine(); + writer.WriteLine("\t\tpublic const int MaxToken = {0};", tokenValue); + if (sets.Any()) { + writer.WriteLine("\t\tstatic BitArray NewSet(params int[] values)"); + writer.WriteLine("\t\t{"); + writer.WriteLine("\t\t\tBitArray bitArray = new BitArray(MaxToken);"); + writer.WriteLine("\t\t\tforeach (int val in values) {"); + writer.WriteLine("\t\t\tbitArray[val] = true;"); + writer.WriteLine("\t\t\t}"); + writer.WriteLine("\t\t\treturn bitArray;"); + writer.WriteLine("\t\t}"); + foreach (var pair in sets) { + StringBuilder builder = new StringBuilder(); + PrintList(pair.Value, builder, sets, specialChars); + writer.WriteLine("\t\tpublic static BitArray {0} = NewSet({1});", pair.Key, builder.ToString()); + } + writer.WriteLine(); + } + + // write token number --> string function. + writer.WriteLine("\t\tstatic string[] tokenList = new string[] {"); + + writer.WriteLine("\t\t\t// ----- terminal classes -----"); + foreach (string terminal in terminals) + writer.WriteLine("\t\t\t\"<{0}>\",", terminal); + + writer.WriteLine("\t\t\t// ----- special character -----"); + foreach (string specialChar in specialChars.Values) + writer.WriteLine("\t\t\t{0},", specialChar); + + writer.WriteLine("\t\t\t// ----- keywords -----"); + foreach (string keyword in keywords) + writer.WriteLine("\t\t\t\"{0}\",", keyword); + + writer.WriteLine("\t\t};"); + + writer.WriteLine("\t\tpublic static string GetTokenString(int token)"); + writer.WriteLine("\t\t{"); + writer.WriteLine("\t\t\tif (token >= 0 && token < tokenList.Length) {"); + writer.WriteLine("\t\t\t\treturn tokenList[token];"); + writer.WriteLine("\t\t\t}"); + writer.WriteLine("\t\t\tthrow new System.NotSupportedException(\"Unknown token:\" + token);"); + writer.WriteLine("\t\t}"); + + writer.WriteLine("\t}"); + writer.WriteLine("}"); + } + } + + static void PrintList(string[] value, StringBuilder builder, Dictionary sets, Dictionary specialChars) + { + for (int i = 0; i < value.Length; i++) { + string item = value[i]; + if (Regex.IsMatch(item, "\\\"(\\w+)\\\"")) // keywords + builder.Append(UpperCaseFirst(item.Trim('"', ' ', '\t'))); + else if (Regex.IsMatch(item, "\\\"(\\W+)\\\"")) // special chars + builder.Append(specialChars.Keys.ElementAt(specialChars.Values.FindIndex(it => item == it))); + else if (Regex.IsMatch(item, "@(\\w+)")) // other list + PrintList(sets[item.Substring(1)], builder, sets, specialChars); + else + builder.Append(item); + if (i + 1 < value.Length) + builder.Append(", "); + } + } + + static void GenerateKeywords(Dictionary properties, List keywords, string language) + { + string sourceDir = Path.Combine(baseDir, language, "Keywords.cs"); + using (StreamWriter writer = new StreamWriter(new FileStream(sourceDir, FileMode.Create))) { + writer.WriteLine("// this file was autogenerated by a tool."); + writer.WriteLine("using System;"); + writer.WriteLine(); + writer.WriteLine("namespace {0}", properties["Namespace"]); + writer.WriteLine("{"); + writer.WriteLine("\tpublic static class Keywords"); + writer.WriteLine("\t{"); + writer.WriteLine("\t\tstatic readonly string[] keywordList = {"); + for (int i = 0; i < keywords.Count; i++) { + writer.Write("\t\t\t\"{0}\"", properties["UpperCaseKeywords"] == "True" ? keywords[i].ToUpperInvariant() : keywords[i]); + if (i + 1 < keywords.Count) + writer.Write(","); + writer.WriteLine(); + } + writer.WriteLine("\t\t};"); + writer.WriteLine("\t\t"); + writer.WriteLine("\t\tstatic LookupTable keywords = new LookupTable({0});", properties["UpperCaseKeywords"] == "True" ? "false" : "true"); + writer.WriteLine("\t\t"); + writer.WriteLine("\t\tstatic Keywords()"); + writer.WriteLine("\t\t{"); + writer.WriteLine("\t\t\tfor (int i = 0; i < keywordList.Length; ++i) {"); + writer.WriteLine("\t\t\t\tkeywords[keywordList[i]] = i + Tokens.{0};", UpperCaseFirst(keywords[0])); + writer.WriteLine("\t\t\t}"); + writer.WriteLine("\t\t}"); + writer.WriteLine("\t\t"); + writer.WriteLine("\t\tpublic static int GetToken(string keyword)"); + writer.WriteLine("\t\t{"); + writer.WriteLine("\t\t\treturn keywords[keyword];"); + writer.WriteLine("\t\t}"); + writer.WriteLine("\t\t"); + writer.WriteLine("\t\tpublic static bool IsNonIdentifierKeyword(string word)"); + writer.WriteLine("\t\t{"); + writer.WriteLine("\t\t\tint token = GetToken(word);"); + writer.WriteLine("\t\t\tif (token < 0)"); + writer.WriteLine("\t\t\t\treturn false;"); + writer.WriteLine("\t\t\treturn !Tokens.IdentifierTokens[token];"); + writer.WriteLine("\t\t}"); + + writer.WriteLine("\t}"); + writer.WriteLine("}"); + + writer.Close(); + } + } + + #region input + static void ReadFile(Dictionary properties, Dictionary sets, + List keywords, List terminals, Dictionary specialChars, + string language) + { + string sourceDir = Path.Combine(baseDir, language, "KeywordList.txt"); + + using (StreamReader reader = new StreamReader(new FileStream(sourceDir, FileMode.Open))) { + string line = reader.ReadLine(); + while (line != null) { + ReadProperty(properties, line); + ReadKeyword(keywords, line); + ReadSet(sets, line); + ReadTerminalSymbol(terminals, line); + ReadSpecialChar(specialChars, line); + line = reader.ReadLine(); + } + reader.Close(); + } + } + + static void ReadProperty(Dictionary properties, string line) + { + // properties form: $PROPERTY = "VALUE" + Match match = Regex.Match(line, @"^\s*\$(\w+)\s*=\s*(\S+)\s*$"); + + if (match.Success) { + properties.Add(match.Groups[1].Value, match.Groups[2].Value); + } + } + + static void ReadKeyword(List keywords, string line) + { + // special keywords form: "VALUE" + Match match = Regex.Match(line, "^\\s*\\\"(\\S+)\\s*\\\"\\s*$"); + + if (match.Success) { + keywords.Add(match.Groups[1].Value); + } + } + + static void ReadSet(Dictionary sets, string line) + { + // sets form: NAME(comma separated list) + Match match = Regex.Match(line, @"^\s*(\w+)\s*\((.*)\)\s*$"); + + if (match.Success) { + sets.Add( + match.Groups[1].Value, + match.Groups[2].Value.Split(new[] {", "}, StringSplitOptions.None) + ); + } + } + + static void ReadTerminalSymbol(List terminals, string line) + { + // special terminal classes form: name + Match match = Regex.Match(line, @"^\s*(\w+)\s*$"); + + if (match.Success) { + terminals.Add(match.Groups[1].Value); + } + } + + static void ReadSpecialChar(Dictionary specialChars, string line) + { + // special characters form: name = "VALUE" + Match match = Regex.Match(line, @"^\s*(\w+)\s*=\s*(\S+)\s*$"); + + if (match.Success) { + specialChars.Add(match.Groups[1].Value, match.Groups[2].Value); + } + } + #endregion + + #region helpers + static string UpperCaseFirst(string keyword) + { + return char.ToUpperInvariant(keyword[0]) + keyword.Substring(1); + } + + static void WriteToken(this StreamWriter writer, string tokenName, ref int tokenValue) + { + string formattedName = UpperCaseFirst(tokenName).PadRight(20); + if (tokenName == "GetType" || tokenName.ToLowerInvariant() == "equals") + writer.WriteLine("\t\tnew public const int {0} = {1};", formattedName, tokenValue); + else + writer.WriteLine("\t\tpublic const int {0} = {1};", formattedName, tokenValue); + tokenValue++; + } + + static int FindIndex(this IEnumerable items, Func f) + { + int index = -1; + foreach (T item in items) { + index++; + if (f(item)) + return index; + } + + return -1; + } + #endregion + } +} diff --git a/NRefactoryASTGenerator/Main.cs b/NRefactoryASTGenerator/Main.cs new file mode 100644 index 0000000000..2bf9b8c544 --- /dev/null +++ b/NRefactoryASTGenerator/Main.cs @@ -0,0 +1,590 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.CodeDom; +using System.Diagnostics; +using System.Reflection; +using System.IO; +using NRefactoryASTGenerator.Ast; +using ICSharpCode.EasyCodeDom; + +namespace NRefactoryASTGenerator +{ + class MainClass + { + public const string VisitPrefix = "Visit"; + + static readonly string[] lineEndings = { "\r\n", "\r", "\n" }; + + public static void Main(string[] args) + { + string directory = "../../../Project/Src/Ast/"; + string visitorsDir = "../../../Project/Src/Visitors/"; + Debug.WriteLine("AST Generator running..."); + if (!File.Exists(directory + "INode.cs")) { + Debug.WriteLine("did not find output directory"); + return; + } + if (!File.Exists(visitorsDir + "AbstractAstTransformer.cs")) { + Debug.WriteLine("did not find visitor output directory"); + return; + } + + List nodeTypes = new List(); + foreach (Type type in typeof(MainClass).Assembly.GetTypes()) { + if (type.IsClass && typeof(INode).IsAssignableFrom(type)) { + nodeTypes.Add(type); + } + } + nodeTypes.Sort(delegate(Type a, Type b) { return a.Name.CompareTo(b.Name); }); + + CodeCompileUnit ccu = new CodeCompileUnit(); + CodeNamespace cns = ccu.AddNamespace("ICSharpCode.NRefactory.Ast"); + cns.AddImport("System"); + cns.AddImport("System.Collections.Generic"); + foreach (Type type in nodeTypes) { + if (type.GetCustomAttributes(typeof(CustomImplementationAttribute), false).Length == 0) { + CodeTypeDeclaration ctd = cns.AddType(type.Name); + if (type.IsAbstract) { + ctd.TypeAttributes |= TypeAttributes.Abstract; + } + ctd.BaseTypes.Add(new CodeTypeReference(type.BaseType.Name)); + + ProcessType(type, ctd); + + foreach (object o in type.GetCustomAttributes(false)) { + if (o is TypeImplementationModifierAttribute) { + (o as TypeImplementationModifierAttribute).ModifyImplementation(cns, ctd, type); + } + } + + if (!type.IsAbstract) { + CodeMemberMethod method = new CodeMemberMethod(); + method.Name = "AcceptVisitor"; + method.Attributes = MemberAttributes.Public | MemberAttributes.Override; + method.Parameters.Add(new CodeParameterDeclarationExpression("IAstVisitor", "visitor")); + method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "data")); + method.ReturnType = new CodeTypeReference(typeof(object)); + CodeExpression ex = new CodeVariableReferenceExpression("visitor"); + ex = new CodeMethodInvokeExpression(ex, VisitPrefix + ctd.Name, + new CodeThisReferenceExpression(), + new CodeVariableReferenceExpression("data")); + method.Statements.Add(new CodeMethodReturnStatement(ex)); + ctd.Members.Add(method); + + method = new CodeMemberMethod(); + method.Name = "ToString"; + method.Attributes = MemberAttributes.Public | MemberAttributes.Override; + method.ReturnType = new CodeTypeReference(typeof(string)); + method.Statements.Add(new CodeMethodReturnStatement(CreateToString(type))); + ctd.Members.Add(method); + } + } + } + + System.CodeDom.Compiler.CodeGeneratorOptions settings = new System.CodeDom.Compiler.CodeGeneratorOptions(); + settings.IndentString = "\t"; + settings.VerbatimOrder = true; + + using (StringWriter writer = new StringWriter()) { + new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings); + File.WriteAllText(directory + "Generated.cs", NormalizeNewLines(writer)); + } + + ccu = new CodeCompileUnit(); + cns = ccu.AddNamespace("ICSharpCode.NRefactory"); + cns.AddImport("System"); + cns.AddImport("ICSharpCode.NRefactory.Ast"); + cns.Types.Add(CreateAstVisitorInterface(nodeTypes)); + + using (StringWriter writer = new StringWriter()) { + new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings); + File.WriteAllText(visitorsDir + "../IAstVisitor.cs", NormalizeNewLines(writer)); + } + + ccu = new CodeCompileUnit(); + cns = ccu.AddNamespace("ICSharpCode.NRefactory.Visitors"); + cns.AddImport("System"); + cns.AddImport("System.Collections.Generic"); + cns.AddImport("System.Diagnostics"); + cns.AddImport("ICSharpCode.NRefactory.Ast"); + cns.Types.Add(CreateAstVisitorClass(nodeTypes, false)); + + using (StringWriter writer = new StringWriter()) { + new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings); + File.WriteAllText(visitorsDir + "AbstractAstVisitor.cs", NormalizeNewLines(writer)); + } + + ccu = new CodeCompileUnit(); + cns = ccu.AddNamespace("ICSharpCode.NRefactory.Visitors"); + cns.AddImport("System"); + cns.AddImport("System.Collections.Generic"); + cns.AddImport("System.Diagnostics"); + cns.AddImport("ICSharpCode.NRefactory.Ast"); + cns.Types.Add(CreateAstVisitorClass(nodeTypes, true)); + + using (StringWriter writer = new StringWriter()) { + new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings); + File.WriteAllText(visitorsDir + "AbstractAstTransformer.cs", NormalizeNewLines(writer)); + } + + ccu = new CodeCompileUnit(); + cns = ccu.AddNamespace("ICSharpCode.NRefactory.Visitors"); + cns.AddImport("System"); + cns.AddImport("ICSharpCode.NRefactory.Ast"); + cns.Types.Add(CreateNodeTrackingAstVisitorClass(nodeTypes)); + + using (StringWriter writer = new StringWriter()) { + new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings); + // CodeDom cannot output "sealed", so we need to use this hack: + File.WriteAllText(visitorsDir + "NodeTrackingAstVisitor.cs", + NormalizeNewLines(writer).Replace("public override object", "public sealed override object")); + } + + //NotImplementedAstVisitor + ccu = new CodeCompileUnit(); + cns = ccu.AddNamespace("ICSharpCode.NRefactory.Visitors"); + cns.AddImport("System"); + cns.AddImport("ICSharpCode.NRefactory.Ast"); + cns.Types.Add(CreateNotImplementedAstVisitorClass(nodeTypes)); + + using (StringWriter writer = new StringWriter()) { + new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings); + File.WriteAllText(visitorsDir + "NotImplementedAstVisitor.cs", NormalizeNewLines(writer)); + } + Debug.WriteLine("AST Generator done!"); + + Debug.WriteLine("start keyword list generation..."); + + KeywordGenerator.Generate(); + + Debug.WriteLine("keyword list generation done!"); + } + + static string NormalizeNewLines(StringWriter writer) + { + return string.Join(Environment.NewLine, writer.ToString().Split(lineEndings, StringSplitOptions.None)); + } + + static CodeTypeDeclaration CreateAstVisitorInterface(List nodeTypes) + { + CodeTypeDeclaration td = new CodeTypeDeclaration("IAstVisitor"); + td.IsInterface = true; + + foreach (Type t in nodeTypes) { + if (!t.IsAbstract) { + EasyMethod m = td.AddMethod(typeof(object), VisitPrefix + t.Name); + m.AddParameter(ConvertType(t), GetFieldName(t.Name)); + m.AddParameter(typeof(object), "data"); + } + } + return td; + } + + static CodeTypeDeclaration CreateAstVisitorClass(List nodeTypes, bool transformer) + { + CodeTypeDeclaration td = new CodeTypeDeclaration(transformer ? "AbstractAstTransformer" : "AbstractAstVisitor"); + td.TypeAttributes = TypeAttributes.Public | TypeAttributes.Abstract; + td.BaseTypes.Add(new CodeTypeReference("IAstVisitor")); + + if (transformer) { + string comment = + "The AbstractAstTransformer will iterate through the whole AST,\n " + + "just like the AbstractAstVisitor. However, the AbstractAstTransformer allows\n " + + "you to modify the AST at the same time: It does not use 'foreach' internally,\n " + + "so you can add members to collections of parents of the current node (but\n " + + "you cannot insert or delete items as that will make the index used invalid).\n " + + "You can use the methods ReplaceCurrentNode and RemoveCurrentNode to replace\n " + + "or remove the current node, totally independent from the type of the parent node."; + Easy.AddSummary(td, comment); + + CodeMemberField field = td.AddField(Easy.TypeRef("Stack", "INode"), "nodeStack"); + field.InitExpression = Easy.New(field.Type); + + /* + CodeExpression nodeStack = Easy.Var("nodeStack"); + CodeMemberProperty p = new CodeMemberProperty(); + p.Name = "CurrentNode"; + p.Type = new CodeTypeReference("INode"); + p.Attributes = MemberAttributes.Public | MemberAttributes.Final; + p.GetStatements.Add(new CodeMethodReturnStatement(new CodeVariableReferenceExpression("currentNode"))); + p.SetStatements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression("currentNode"), + new CodePropertySetValueReferenceExpression())); + td.Members.Add(p); + */ + + EasyMethod m = td.AddMethod("ReplaceCurrentNode"); + m.AddParameter(Easy.TypeRef("INode"), "newNode"); + m.Statements.Add(Easy.Var("nodeStack").InvokeMethod("Pop")); + m.Statements.Add(Easy.Var("nodeStack").InvokeMethod("Push", Easy.Var("newNode"))); + + m = td.AddMethod("RemoveCurrentNode"); + m.Statements.Add(Easy.Var("nodeStack").InvokeMethod("Pop")); + m.Statements.Add(Easy.Var("nodeStack").InvokeMethod("Push", Easy.Null)); + } + + foreach (Type type in nodeTypes) { + if (!type.IsAbstract) { + EasyMethod m = td.AddMethod(typeof(object), VisitPrefix + type.Name); + m.Attributes = MemberAttributes.Public; + m.AddParameter(ConvertType(type), GetFieldName(type.Name)); + m.AddParameter(typeof(object), "data"); + + List assertions = new List(); + string varVariableName = GetFieldName(type.Name); + CodeExpression var = Easy.Var(varVariableName); + assertions.Add(AssertIsNotNull(var)); + + AddFieldVisitCode(m, type, var, assertions, transformer); + + if (type.GetCustomAttributes(typeof(HasChildrenAttribute), true).Length > 0) { + if (transformer) { + m.Statements.Add(new CodeSnippetStatement(CreateTransformerLoop(varVariableName + ".Children", "INode"))); + m.Body.Return(Easy.Null); + } else { + m.Body.Return(var.InvokeMethod("AcceptChildren", Easy.This, Easy.Var("data"))); + } + } else { + CodeExpressionStatement lastStatement = null; + if (m.Statements.Count > 0) { + lastStatement = m.Statements[m.Statements.Count - 1] as CodeExpressionStatement; + } + if (lastStatement != null) { + m.Statements.RemoveAt(m.Statements.Count - 1); + m.Body.Return(lastStatement.Expression); + } else { + m.Body.Return(Easy.Null); + } + } + + for (int i = 0; i < assertions.Count; i++) { + m.Statements.Insert(i, assertions[i]); + } + } + } + return td; + } + + static void AddFieldVisitCode(EasyMethod m, Type type, CodeExpression var, List assertions, bool transformer) + { + if (type != null) { + if (type.BaseType != typeof(StatementWithEmbeddedStatement)) { + AddFieldVisitCode(m, type.BaseType, var, assertions, transformer); + } + foreach (FieldInfo field in type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic)) { + AddVisitCode(m, field, var, assertions, transformer); + } + if (type.BaseType == typeof(StatementWithEmbeddedStatement)) { + AddFieldVisitCode(m, type.BaseType, var, assertions, transformer); + } + } + } + + static CodeStatement AssertIsNotNull(CodeExpression expr) + { + return new CodeExpressionStatement( + Easy.Type("Debug").InvokeMethod("Assert", + Easy.Binary(expr, + CodeBinaryOperatorType.IdentityInequality, + Easy.Null)) + ); + } + + static string GetCode(CodeExpression ex) + { + using (StringWriter writer = new StringWriter()) { + new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromExpression(ex, writer, null); + return writer.ToString(); + } + } + + static string CreateTransformerLoop(string collection, string typeName) + { + return + "\t\t\tfor (int i = 0; i < " + collection + ".Count; i++) {\n" + + "\t\t\t\t" + typeName + " o = " + collection + "[i];\n" + + "\t\t\t\tDebug.Assert(o != null);\n" + + "\t\t\t\tnodeStack.Push(o);\n" + + "\t\t\t\to.AcceptVisitor(this, data);\n" + + (typeName == "INode" + ? "\t\t\t\to = nodeStack.Pop();\n" + : "\t\t\t\to = (" + typeName + ")nodeStack.Pop();\n") + + "\t\t\t\tif (o == null)\n" + + "\t\t\t\t\t" + collection + ".RemoveAt(i--);\n" + + "\t\t\t\telse\n" + + "\t\t\t\t\t" + collection + "[i] = o;\n" + + "\t\t\t}"; + } + + static bool AddVisitCode(EasyMethod m, FieldInfo field, CodeExpression var, List assertions, bool transformer) + { + CodeExpression prop = var.Property(GetPropertyName(field.Name)); + CodeExpression nodeStack = Easy.Var("nodeStack"); + if (field.FieldType.FullName.StartsWith("System.Collections.Generic.List")) { + Type elType = field.FieldType.GetGenericArguments()[0]; + if (!typeof(INode).IsAssignableFrom(elType)) + return false; + assertions.Add(AssertIsNotNull(prop)); + string code; + if (transformer) { + code = CreateTransformerLoop(GetCode(prop), ConvertType(elType).BaseType); + } else { + code = + "\t\t\tforeach (" + ConvertType(elType).BaseType + " o in " + GetCode(prop) + ") {\n" + + "\t\t\t\tDebug.Assert(o != null);\n" + + "\t\t\t\to.AcceptVisitor(this, data);\n" + + "\t\t\t}"; + } + m.Statements.Add(new CodeSnippetStatement(code)); + return true; + } + if (!typeof(INode).IsAssignableFrom(field.FieldType)) + return false; + assertions.Add(AssertIsNotNull(prop)); + if (transformer) { + m.Statements.Add(nodeStack.InvokeMethod("Push", prop)); + } + m.Statements.Add(prop.InvokeMethod("AcceptVisitor", + Easy.This, + Easy.Var("data"))); + if (transformer) { + m.Body.Assign(prop, nodeStack.InvokeMethod("Pop").CastTo(ConvertType(field.FieldType))); + } + return true; + } + + static CodeExpression CreateToString(Type type) + { + CodeMethodInvokeExpression ie = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(string)), + "Format"); + CodePrimitiveExpression prim = new CodePrimitiveExpression(); + ie.Parameters.Add(prim); + string text = "[" + type.Name; + int index = 0; + do { + foreach (FieldInfo field in type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic)) { + text += " " + GetPropertyName(field.Name) + "={" + index.ToString() + "}"; + index++; + if (typeof(System.Collections.ICollection).IsAssignableFrom(field.FieldType)) { + ie.Parameters.Add(new CodeSnippetExpression("GetCollectionString(" + GetPropertyName(field.Name) + ")")); + } else { + ie.Parameters.Add(new CodeVariableReferenceExpression(GetPropertyName(field.Name))); + } + } + type = type.BaseType; + } while (type != null); + prim.Value = text + "]"; + if (ie.Parameters.Count == 1) + return prim; + else + return ie; + // return String.Format("[AnonymousMethodExpression: Parameters={0} Body={1}]", + // GetCollectionString(Parameters), + // Body); + } + + static void ProcessType(Type type, CodeTypeDeclaration ctd) + { + foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic)) { + ctd.AddField(ConvertType(field.FieldType), field.Name).Attributes = 0; + } + foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic)) { + EasyProperty p = ctd.AddProperty(ConvertType(field.FieldType), GetPropertyName(field.Name)); + p.Getter.Return(Easy.Var(field.Name)); + CodeExpression ex; + if (field.FieldType.IsValueType) + ex = new CodePropertySetValueReferenceExpression(); + else + ex = GetDefaultValue("value", field); + p.Setter.Assign(Easy.Var(field.Name), ex); + if (typeof(INode).IsAssignableFrom(field.FieldType)) { + if (typeof(INullable).IsAssignableFrom(field.FieldType)) { + p.SetStatements.Add(new CodeSnippetStatement("\t\t\t\tif (!" +field.Name+".IsNull) "+field.Name+".Parent = this;")); + } else { + p.SetStatements.Add(new CodeSnippetStatement("\t\t\t\t"+field.Name+".Parent = this;")); + } + } + } + foreach (ConstructorInfo ctor in type.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { + CodeConstructor c = new CodeConstructor(); + if (type.IsAbstract) + c.Attributes = MemberAttributes.Family; + else + c.Attributes = MemberAttributes.Public; + ctd.Members.Add(c); + ConstructorInfo baseCtor = GetBaseCtor(type); + foreach(ParameterInfo param in ctor.GetParameters()) { + c.Parameters.Add(new CodeParameterDeclarationExpression(ConvertType(param.ParameterType), + param.Name)); + if (baseCtor != null && Array.Exists(baseCtor.GetParameters(), delegate(ParameterInfo p) { return param.Name == p.Name; })) + continue; + c.Statements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(GetPropertyName(param.Name)), + new CodeVariableReferenceExpression(param.Name))); + } + if (baseCtor != null) { + foreach(ParameterInfo param in baseCtor.GetParameters()) { + c.BaseConstructorArgs.Add(new CodeVariableReferenceExpression(param.Name)); + } + } + // initialize fields that were not initialized by parameter + foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic)) { + if (field.FieldType.IsValueType && field.FieldType != typeof(Location)) + continue; + if (Array.Exists(ctor.GetParameters(), delegate(ParameterInfo p) { return field.Name == p.Name; })) + continue; + c.Statements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(field.Name), + GetDefaultValue(null, field))); + } + } + } + + internal static ConstructorInfo GetBaseCtor(Type type) + { + ConstructorInfo[] list = type.BaseType.GetConstructors(); + if (list.Length == 0) + return null; + else + return list[0]; + } + + internal static CodeExpression GetDefaultValue(string inputVariable, FieldInfo field) + { + string code; + // get default value: + if (field.FieldType == typeof(string)) { + code = "\"\""; + if (field.GetCustomAttributes(typeof(QuestionMarkDefaultAttribute), false).Length > 0) { + if (inputVariable == null) + return new CodePrimitiveExpression("?"); + else + return new CodeSnippetExpression("string.IsNullOrEmpty(" + inputVariable + ") ? \"?\" : " + inputVariable); + } + } else if (field.FieldType.FullName.StartsWith("System.Collections.Generic.List")) { + code = "new List<" + field.FieldType.GetGenericArguments()[0].Name + ">()"; + } else if (field.FieldType == typeof(Location)) { + code = "Location.Empty"; + } else { + code = field.FieldType.Name + ".Null"; + } + if (inputVariable != null) { + code = inputVariable + " ?? " + code; + } + return new CodeSnippetExpression(code); + } + + internal static string GetFieldName(string typeName) + { + return char.ToLower(typeName[0]) + typeName.Substring(1); + } + + internal static string GetPropertyName(string fieldName) + { + return char.ToUpper(fieldName[0]) + fieldName.Substring(1); + } + + internal static CodeTypeReference ConvertType(Type type) + { + if (type.IsGenericType && !type.IsGenericTypeDefinition) { + CodeTypeReference tr = ConvertType(type.GetGenericTypeDefinition()); + foreach (Type subType in type.GetGenericArguments()) { + tr.TypeArguments.Add(ConvertType(subType)); + } + return tr; + } else if (type.FullName.StartsWith("NRefactory") || type.FullName.StartsWith("System.Collections")) { + if (type.Name == "Attribute") + return new CodeTypeReference("ICSharpCode.NRefactory.Ast.Attribute"); + return new CodeTypeReference(type.Name); + } else { + return new CodeTypeReference(type); + } + } + + static CodeTypeDeclaration CreateNodeTrackingAstVisitorClass(List nodeTypes) + { + CodeTypeDeclaration td = new CodeTypeDeclaration("NodeTrackingAstVisitor"); + td.TypeAttributes = TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Abstract; + td.BaseTypes.Add(new CodeTypeReference("AbstractAstVisitor")); + + string comment = "\n " + + "The NodeTrackingAstVisitor will iterate through the whole AST,\n " + + "just like the AbstractAstVisitor, and calls the virtual methods\n " + + "BeginVisit and EndVisit for each node being visited.\n " + + ""; + td.Comments.Add(new CodeCommentStatement(comment, true)); + comment = "\n " + + "base.Visit(node, data) calls this.TrackedVisit(node, data), so if\n " + + "you want to visit child nodes using the default visiting behaviour,\n " + + "use base.TrackedVisit(parentNode, data).\n " + + ""; + td.Comments.Add(new CodeCommentStatement(comment, true)); + + EasyMethod m = td.AddMethod("BeginVisit"); + m.Attributes = MemberAttributes.Family; + m.AddParameter(Easy.TypeRef("INode"), "node"); + + m = td.AddMethod("EndVisit"); + m.Attributes = MemberAttributes.Family; + m.AddParameter(Easy.TypeRef("INode"), "node"); + + foreach (Type type in nodeTypes) { + if (!type.IsAbstract) { + + m = td.AddMethod(typeof(object), VisitPrefix + type.Name); + m.Attributes = MemberAttributes.Public | MemberAttributes.Override; + m.AddParameter(ConvertType(type), GetFieldName(type.Name)); + m.AddParameter(new CodeTypeReference(typeof(object)), "data"); + + CodeExpression var = Easy.Var(GetFieldName(type.Name)); + + m.Body.InvokeMethod(Easy.This, "BeginVisit", var); + m.Body.DeclareVariable(typeof(object), "result").InitExpression + = Easy.This.InvokeMethod("TrackedVisit" + type.Name, var, Easy.Var("data")); + m.Body.InvokeMethod(Easy.This, "EndVisit", var); + m.Body.Return(Easy.Var("result")); + } + } + + foreach (Type type in nodeTypes) { + if (!type.IsAbstract) { + + m = td.AddMethod(typeof(object), "TrackedVisit" + type.Name); + m.Attributes = MemberAttributes.Public; + m.AddParameter(ConvertType(type), GetFieldName(type.Name)); + m.AddParameter(new CodeTypeReference(typeof(object)), "data"); + + m.Body.Return(Easy.Base.InvokeMethod(VisitPrefix + type.Name, Easy.Var(GetFieldName(type.Name)), Easy.Var("data"))); + } + } + + return td; + } + + static CodeTypeDeclaration CreateNotImplementedAstVisitorClass(List nodeTypes) + { + CodeTypeDeclaration td = new CodeTypeDeclaration("NotImplementedAstVisitor"); + td.TypeAttributes = TypeAttributes.Public | TypeAttributes.Class; + td.BaseTypes.Add(new CodeTypeReference("IAstVisitor")); + + string comment = "\n " + + "IAstVisitor implementation that always throws NotImplementedExceptions.\n " + + ""; + td.Comments.Add(new CodeCommentStatement(comment, true)); + + foreach (Type type in nodeTypes) { + if (!type.IsAbstract) { + + EasyMethod m = td.AddMethod(typeof(object), VisitPrefix + type.Name); + m.Attributes = MemberAttributes.Public; + m.AddParameter(ConvertType(type), GetFieldName(type.Name)); + m.AddParameter(new CodeTypeReference(typeof(object)), "data"); + + m.Body.Throw(Easy.New(typeof(NotImplementedException), Easy.Prim(type.Name))); + } + } + + return td; + } + } +} diff --git a/NRefactoryASTGenerator/NRefactoryASTGenerator.csproj b/NRefactoryASTGenerator/NRefactoryASTGenerator.csproj new file mode 100644 index 0000000000..c711ad7e89 --- /dev/null +++ b/NRefactoryASTGenerator/NRefactoryASTGenerator.csproj @@ -0,0 +1,64 @@ + + + + Exe + NRefactoryASTGenerator + NRefactoryASTGenerator + Debug + AnyCPU + {B22522AA-B5BF-4A58-AC6D-D4B45805521F} + False + False + False + Auto + 4194304 + x86 + 4096 + 4 + 0169 + false + v4.0 + + + bin\Debug\ + False + DEBUG;TRACE + true + Full + True + + + bin\Release\ + True + TRACE + False + None + False + + + + + 3.5 + + + + + + + + + + + + + + + + EasyCodeDom.cs + + + + + + + \ No newline at end of file diff --git a/Project/Configuration/AssemblyInfo.cs b/Project/Configuration/AssemblyInfo.cs new file mode 100644 index 0000000000..92460f78aa --- /dev/null +++ b/Project/Configuration/AssemblyInfo.cs @@ -0,0 +1,21 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: CLSCompliant(true)] +[assembly: StringFreezing()] + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("NRefactory")] +[assembly: AssemblyDescription("Parser and refactoring library for C# and VB.NET")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/Project/NRefactory.csproj b/Project/NRefactory.csproj new file mode 100644 index 0000000000..bf4c1e7325 --- /dev/null +++ b/Project/NRefactory.csproj @@ -0,0 +1,191 @@ + + + + Debug + AnyCPU + 8.0.41115 + 2.0 + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} + ICSharpCode.NRefactory + ICSharpCode.NRefactory + Library + 4 + False + False + OnBuildSuccess + Library + true + Resources\ICSharpCode.NRefactory.snk + False + False + Auto + 94896128 + AnyCPU + 4096 + False + -Microsoft.Design#CA1002;-Microsoft.Design#CA1020;-Microsoft.Design#CA1051;-Microsoft.Design#CA1062;-Microsoft.Globalization#CA1303;-Microsoft.Globalization#CA1305;-Microsoft.Naming#CA1704;-Microsoft.Performance#CA1800;-Microsoft.Performance#CA1805;-Microsoft.Usage#CA2211;-Microsoft.Usage#CA2227 + v4.0 + Client + + + False + True + TEST;DEBUG + ..\..\..\..\bin\ + false + + + True + False + TEST + ..\..\..\..\bin\ + false + + + Full + true + Project + + + false + None + + + + + 3.5 + + + + 3.5 + + + + + + + + + + + + ExpressionFinder.atg + + + + + + + + + + + + + + + + + + + + + + + + + Configuration\GlobalAssemblyInfo.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CocoParserGenerator + ICSharpCode.NRefactory.Parser.VB + Parser.cs + + + ExpressionFinder.atg + + + + + + + + + + + + + + + Never + ICSharpCode.NRefactory.Parser.VB + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Project/NRefactory.csproj.user b/Project/NRefactory.csproj.user new file mode 100644 index 0000000000..d75a3ded51 --- /dev/null +++ b/Project/NRefactory.csproj.user @@ -0,0 +1,14 @@ + + + + 8.0.41115 + ShowAllFiles + 0 + + + ..\..\..\..\bin\SharpDevelop.exe + + + ..\..\..\..\bin\SharpDevelop.exe + + \ No newline at end of file diff --git a/Project/Resources/ICSharpCode.NRefactory.snk b/Project/Resources/ICSharpCode.NRefactory.snk new file mode 100644 index 0000000000000000000000000000000000000000..b273cdc5a1b4f5bf97c3ebec42360488696ecd74 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa500982Ujt>+<9tT^t?!2N2TgLANtgS|N@fdb z6R8%Sb8#L(D|K9o3ZJt)*^q;!aG_i{#o#;?X2EA5q?ZeWl-~B?_hw9z4KZKz;{4{9 z-HT*}1O(f%J@|Y=mgW-8A6~Xj?((E5s+!I2Y4Y8c#2wS2PFHS;RlrS_tb-uWH>>5@ zTAXMEWocsVYh)OFvgonb2cl%X$BM9QcR7p1Ta@4(GU5qcvaz-Bq}IvVWVN-X&Gi?XOG^9VOHwlq9mKI#` zI}$n`!k@Z-0x<}20<`87{cxHS&hvw%iqy+Y#`0w{#`dOBwvArDFec{LXY{up(ne?`Y~0{Q|VY9Y80ruisX zT%bQF;7OJZu0J!OWl)2esaf&p3QppxHP__;@I0eL^c!$O_t^s^K%6L)aDPI*gG3E8 z^$9<`S;R1rt#I@M0Buf(*(*NB9A|te4g6&GwFO1J^Yfb6)T iZkq8)&m5$d(s1BsIMJw|?jYo53sx9zmmNI- literal 0 HcmV?d00001 diff --git a/Project/Src/Ast/AbstractNode.cs b/Project/Src/Ast/AbstractNode.cs new file mode 100644 index 0000000000..e400b74cac --- /dev/null +++ b/Project/Src/Ast/AbstractNode.cs @@ -0,0 +1,73 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; + +namespace ICSharpCode.NRefactory.Ast +{ + public abstract class AbstractNode : INode + { + List children = new List(); + + public INode Parent { get; set; } + public Location StartLocation { get; set; } + public Location EndLocation { get; set; } + public object UserData { get; set; } + + public List Children { + get { + return children; + } + set { + Debug.Assert(value != null); + children = value; + } + } + + public virtual void AddChild(INode childNode) + { + Debug.Assert(childNode != null); + childNode.Parent = this; + children.Add(childNode); + } + + public abstract object AcceptVisitor(IAstVisitor visitor, object data); + + public virtual object AcceptChildren(IAstVisitor visitor, object data) + { + foreach (INode child in children) { + Debug.Assert(child != null); + child.AcceptVisitor(visitor, data); + } + return data; + } + + public static string GetCollectionString(ICollection collection) + { + StringBuilder output = new StringBuilder(); + output.Append('{'); + + if (collection != null) { + IEnumerator en = collection.GetEnumerator(); + bool isFirst = true; + while (en.MoveNext()) { + if (!isFirst) { + output.Append(", "); + } else { + isFirst = false; + } + output.Append(en.Current == null ? "" : en.Current.ToString()); + } + } else { + return "null"; + } + + output.Append('}'); + return output.ToString(); + } + } +} diff --git a/Project/Src/Ast/Enums.cs b/Project/Src/Ast/Enums.cs new file mode 100644 index 0000000000..2b16510520 --- /dev/null +++ b/Project/Src/Ast/Enums.cs @@ -0,0 +1,412 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory.Ast +{ + [Flags] + public enum Modifiers + { + None = 0x0000, + + // Access + Private = 0x0001, + /// C# 'internal', VB 'Friend' + Internal = 0x0002, + Protected = 0x0004, + Public = 0x0008, + + // Scope + Abstract = 0x0010, // == MustOverride/MustInherit + Virtual = 0x0020, + Sealed = 0x0040, + /// C# 'static', VB 'Shared' + Static = 0x0080, + Override = 0x0100, + /// For fields: readonly (c# and vb), for properties: get-only (vb) + ReadOnly = 0x0200, + Const = 0x0400, + /// C# 'new', VB 'Shadows' + New = 0x0800, + Partial = 0x1000, + + // Special + Extern = 0x2000, + Volatile = 0x4000, + Unsafe = 0x8000, + Overloads = 0x10000, // VB specific + WithEvents = 0x20000, // VB specific + Default = 0x40000, // VB specific + Fixed = 0x80000, // C# specific (fixed size arrays in unsafe structs) + + Dim = 0x100000, // VB.NET SPECIFIC, for fields/local variables only + + /// Generated code, not part of parsed code + Synthetic = 0x200000, + /// Only for VB properties. + WriteOnly = 0x400000, // VB specific + + Visibility = Private | Public | Protected | Internal, + Classes = New | Visibility | Abstract | Sealed | Partial | Static, + VBModules = Visibility, + VBStructures = Visibility | New, + VBEnums = Visibility | New, + VBInterfacs = Visibility | New, + VBDelegates = Visibility | New, + VBMethods = Visibility | New | Static | Virtual | Sealed | Abstract | Override | Overloads, + VBExternalMethods = Visibility | New | Overloads, + VBEvents = Visibility | New | Overloads, + VBProperties = VBMethods | Default | ReadOnly | WriteOnly, + VBCustomEvents = Visibility | New | Overloads, + VBOperators = Public | Static | Overloads | New, + + + // this is not documented in the spec + VBInterfaceEvents = New, + VBInterfaceMethods = New | Overloads, + VBInterfaceProperties = New | Overloads | ReadOnly | WriteOnly | Default, + VBInterfaceEnums = New, + + Fields = New | Visibility | Static | ReadOnly | Volatile | Fixed, + PropertysEventsMethods = New | Visibility | Static | Virtual | Sealed | Override | Abstract | Extern, + Indexers = New | Visibility | Virtual | Sealed | Override | Abstract | Extern, + Operators = Public | Static | Extern, + Constants = New | Visibility, + StructsInterfacesEnumsDelegates = New | Visibility | Partial, + StaticConstructors = Extern | Static | Unsafe, + Destructors = Extern | Unsafe, + Constructors = Visibility | Extern, + } + + public enum ClassType + { + Class, + Module, + Interface, + Struct, + Enum + } + + public enum ParentType + { + ClassOrStruct, + InterfaceOrEnum, + Namespace, + Unknown + } + + public enum FieldDirection + { + None, + In, + Out, + Ref + } + + [Flags] + public enum ParameterModifiers + { + // Values must be the same as in SharpDevelop's ParameterModifiers + None = 0, + In = 1, + Out = 2, + Ref = 4, + Params = 8, + Optional = 16 + } + + public enum VarianceModifier + { + Invariant, + Covariant, + Contravariant + }; + + public enum AssignmentOperatorType + { + None, + Assign, + + Add, + Subtract, + Multiply, + Divide, + Modulus, + + Power, // (VB only) + DivideInteger, // (VB only) + ConcatString, // (VB only) + + ShiftLeft, + ShiftRight, + + BitwiseAnd, + BitwiseOr, + ExclusiveOr, + } + + public enum BinaryOperatorType + { + None, + + /// '&' in C#, 'And' in VB. + BitwiseAnd, + /// '|' in C#, 'Or' in VB. + BitwiseOr, + /// '&&' in C#, 'AndAlso' in VB. + LogicalAnd, + /// '||' in C#, 'OrElse' in VB. + LogicalOr, + /// '^' in C#, 'Xor' in VB. + ExclusiveOr, + + /// > + GreaterThan, + /// >= + GreaterThanOrEqual, + /// '==' in C#, '=' in VB. + Equality, + /// '!=' in C#, '<>' in VB. + InEquality, + /// < + LessThan, + /// <= + LessThanOrEqual, + + /// + + Add, + /// - + Subtract, + /// * + Multiply, + /// / + Divide, + /// '%' in C#, 'Mod' in VB. + Modulus, + /// VB-only: \ + DivideInteger, + /// VB-only: ^ + Power, + /// VB-only: & + Concat, + + /// C#: << + ShiftLeft, + /// C#: >> + ShiftRight, + /// VB-only: Is + ReferenceEquality, + /// VB-only: IsNot + ReferenceInequality, + + /// VB-only: Like + Like, + /// + /// C#: ?? + /// VB: IF(x, y) + /// + NullCoalescing, + + /// VB-only: ! + DictionaryAccess + } + + public enum CastType + { + /// + /// direct cast (C#, VB "DirectCast") + /// + Cast, + /// + /// try cast (C# "as", VB "TryCast") + /// + TryCast, + /// + /// converting cast (VB "CType") + /// + Conversion, + /// + /// primitive converting cast (VB "CString" etc.) + /// + PrimitiveConversion + } + + public enum UnaryOperatorType + { + None, + Not, + BitNot, + + Minus, + Plus, + + Increment, + Decrement, + + PostIncrement, + PostDecrement, + + /// Dereferencing pointer + Dereference, + /// Get address of + AddressOf + } + + public enum ContinueType + { + None, + Do, + For, + While + } + + public enum ConditionType + { + None, + Until, + While, + DoWhile + } + + public enum ConditionPosition + { + None, + Start, + End + } + + public enum ExitType + { + None, + Sub, + Function, + Property, + Do, + For, + While, + Select, + Try + } + + public enum ConstructorInitializerType + { + None, + Base, + This + } + + public enum ConversionType + { + None, + Implicit, + Explicit + } + + public enum OverloadableOperatorType + { + None, + + Add, + Subtract, + Multiply, + Divide, + Modulus, + Concat, + + UnaryPlus, + UnaryMinus, + + Not, + BitNot, + + BitwiseAnd, + BitwiseOr, + ExclusiveOr, + + ShiftLeft, + ShiftRight, + + GreaterThan, + GreaterThanOrEqual, + Equality, + InEquality, + LessThan, + LessThanOrEqual, + + Increment, + Decrement, + + IsTrue, + IsFalse, + + // VB specific + Like, + Power, + CType, + DivideInteger + } + + /// + /// Charset types, used in external methods + /// declarations (VB only). + /// + public enum CharsetModifier + { + None, + Auto, + Unicode, + Ansi + } + + /// + /// Compare type, used in the Option Compare + /// pragma (VB only). + /// + public enum OptionType + { + None, + Explicit, + Strict, + CompareBinary, + CompareText, + Infer + } + + /// + /// Specifies the ordering direction of a QueryExpressionOrdering node. + /// + public enum QueryExpressionOrderingDirection + { + None, + Ascending, + Descending + } + + /// + /// Specifies the partition type for a VB.NET + /// query expression. + /// + public enum QueryExpressionPartitionType + { + Take, + TakeWhile, + Skip, + SkipWhile + } + + public enum XmlAxisType + { + Element, // . + Attribute, // .@ + Descendents // ... + } + + public enum XmlContentType + { + Comment, + Text, + CData, + ProcessingInstruction + } +} diff --git a/Project/Src/Ast/General/BlockStatement.cs b/Project/Src/Ast/General/BlockStatement.cs new file mode 100644 index 0000000000..c9fd4d0fae --- /dev/null +++ b/Project/Src/Ast/General/BlockStatement.cs @@ -0,0 +1,59 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory.Ast +{ + public class BlockStatement : Statement + { + // Children in C#: LabelStatement, LocalVariableDeclaration, Statement + // Children in VB: LabelStatement, EndStatement, Statement + + public static new BlockStatement Null { + get { + return NullBlockStatement.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return visitor.VisitBlockStatement(this, data); + } + + public override string ToString() + { + return String.Format("[BlockStatement: Children={0}]", + GetCollectionString(base.Children)); + } + } + + internal sealed class NullBlockStatement : BlockStatement + { + public static readonly NullBlockStatement Instance = new NullBlockStatement(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return data; + } + public override object AcceptChildren(IAstVisitor visitor, object data) + { + return data; + } + public override void AddChild(INode childNode) + { + throw new InvalidOperationException(); + } + + public override string ToString() + { + return String.Format("[NullBlockStatement]"); + } + } +} diff --git a/Project/Src/Ast/General/CompilationUnit.cs b/Project/Src/Ast/General/CompilationUnit.cs new file mode 100644 index 0000000000..c395159802 --- /dev/null +++ b/Project/Src/Ast/General/CompilationUnit.cs @@ -0,0 +1,24 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections; + +namespace ICSharpCode.NRefactory.Ast +{ + public class CompilationUnit : AbstractNode + { + // Children in C#: UsingAliasDeclaration, UsingDeclaration, AttributeSection, NamespaceDeclaration + // Children in VB: OptionStatements, ImportsStatement, AttributeSection, NamespaceDeclaration + + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return visitor.VisitCompilationUnit(this, data); + } + + public override string ToString() + { + return String.Format("[CompilationUnit]"); + } + } +} diff --git a/Project/Src/Ast/General/Expression.cs b/Project/Src/Ast/General/Expression.cs new file mode 100644 index 0000000000..d315faaf4e --- /dev/null +++ b/Project/Src/Ast/General/Expression.cs @@ -0,0 +1,103 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory.Ast +{ + public abstract class Expression : AbstractNode, INullable + { + public static Expression Null { + get { + return NullExpression.Instance; + } + } + + public virtual bool IsNull { + get { + return false; + } + } + + public static Expression CheckNull(Expression expression) + { + return expression == null ? NullExpression.Instance : expression; + } + + /// + /// Returns the existing expression plus the specified integer value. + /// The old object is not modified, but might be a subobject on the new expression + /// (and thus its parent property is modified). + /// + public static Expression AddInteger(Expression expr, int value) + { + PrimitiveExpression pe = expr as PrimitiveExpression; + if (pe != null && pe.Value is int) { + int newVal = (int)pe.Value + value; + return new PrimitiveExpression(newVal, newVal.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); + } + BinaryOperatorExpression boe = expr as BinaryOperatorExpression; + if (boe != null && boe.Op == BinaryOperatorType.Add) { + // clone boe: + boe = new BinaryOperatorExpression(boe.Left, boe.Op, boe.Right); + + boe.Right = AddInteger(boe.Right, value); + if (boe.Right is PrimitiveExpression && ((PrimitiveExpression)boe.Right).Value is int) { + int newVal = (int)((PrimitiveExpression)boe.Right).Value; + if (newVal == 0) { + return boe.Left; + } else if (newVal < 0) { + ((PrimitiveExpression)boe.Right).Value = -newVal; + boe.Op = BinaryOperatorType.Subtract; + } + } + return boe; + } + if (boe != null && boe.Op == BinaryOperatorType.Subtract) { + pe = boe.Right as PrimitiveExpression; + if (pe != null && pe.Value is int) { + int newVal = (int)pe.Value - value; + if (newVal == 0) + return boe.Left; + + // clone boe: + boe = new BinaryOperatorExpression(boe.Left, boe.Op, boe.Right); + + if (newVal < 0) { + newVal = -newVal; + boe.Op = BinaryOperatorType.Add; + } + boe.Right = new PrimitiveExpression(newVal, newVal.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); + return boe; + } + } + BinaryOperatorType opType = BinaryOperatorType.Add; + if (value < 0) { + value = -value; + opType = BinaryOperatorType.Subtract; + } + return new BinaryOperatorExpression(expr, opType, new PrimitiveExpression(value, value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo))); + } + } + + internal sealed class NullExpression : Expression + { + internal static readonly NullExpression Instance = new NullExpression(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return null; + } + + public override string ToString() + { + return String.Format("[NullExpression]"); + } + } +} diff --git a/Project/Src/Ast/General/LocalVariableDeclaration.cs b/Project/Src/Ast/General/LocalVariableDeclaration.cs new file mode 100644 index 0000000000..c82f652836 --- /dev/null +++ b/Project/Src/Ast/General/LocalVariableDeclaration.cs @@ -0,0 +1,99 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.Ast +{ + public class LocalVariableDeclaration : Statement + { + TypeReference typeReference; + Modifiers modifier = Modifiers.None; + List variables = new List(); + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = TypeReference.CheckNull(value); + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public Modifiers Modifier { + get { + return modifier; + } + set { + modifier = value; + } + } + + public List Variables { + get { + return variables; + } + } + + public TypeReference GetTypeForVariable(int variableIndex) + { + if (!typeReference.IsNull) { + return typeReference; + } + + for (int i = variableIndex; i < Variables.Count;++i) { + if (!((VariableDeclaration)Variables[i]).TypeReference.IsNull) { + return ((VariableDeclaration)Variables[i]).TypeReference; + } + } + return null; + } + + public LocalVariableDeclaration(VariableDeclaration declaration) : this(TypeReference.Null) + { + Variables.Add(declaration); + } + + public LocalVariableDeclaration(TypeReference typeReference) + { + this.TypeReference = typeReference; + } + + public LocalVariableDeclaration(TypeReference typeReference, Modifiers modifier) + { + this.TypeReference = typeReference; + this.modifier = modifier; + } + + public LocalVariableDeclaration(Modifiers modifier) + { + this.typeReference = TypeReference.Null; + this.modifier = modifier; + } + + public VariableDeclaration GetVariableDeclaration(string variableName) + { + foreach (VariableDeclaration variableDeclaration in variables) { + if (variableDeclaration.Name == variableName) { + return variableDeclaration; + } + } + return null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return visitor.VisitLocalVariableDeclaration(this, data); + } + + public override string ToString() + { + return String.Format("[LocalVariableDeclaration: Type={0}, Modifier ={1} Variables={2}]", + typeReference, + modifier, + GetCollectionString(variables)); + } + } +} diff --git a/Project/Src/Ast/General/PrimitiveExpression.cs b/Project/Src/Ast/General/PrimitiveExpression.cs new file mode 100644 index 0000000000..ca76e3b5c5 --- /dev/null +++ b/Project/Src/Ast/General/PrimitiveExpression.cs @@ -0,0 +1,53 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using ICSharpCode.NRefactory.PrettyPrinter; +using System; + +namespace ICSharpCode.NRefactory.Ast +{ + public class PrimitiveExpression : Expression + { + string stringValue; + + public Parser.LiteralFormat LiteralFormat { get; set; } + public object Value { get; set; } + + public string StringValue { + get { + if (stringValue == null) + return CSharpOutputVisitor.ToCSharpString(this); + else + return stringValue; + } + set { + stringValue = value == null ? String.Empty : value; + } + } + + public PrimitiveExpression(object val) + { + this.Value = val; + } + + public PrimitiveExpression(object val, string stringValue) + { + this.Value = val; + this.StringValue = stringValue; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return visitor.VisitPrimitiveExpression(this, data); + } + + public override string ToString() + { + return String.Format("[PrimitiveExpression: Value={1}, ValueType={2}, StringValue={0}]", + this.StringValue, + this.Value, + this.Value == null ? "null" : this.Value.GetType().FullName + ); + } + } +} diff --git a/Project/Src/Ast/General/Statement.cs b/Project/Src/Ast/General/Statement.cs new file mode 100644 index 0000000000..8a07f9c12b --- /dev/null +++ b/Project/Src/Ast/General/Statement.cs @@ -0,0 +1,62 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory.Ast +{ + public abstract class Statement : AbstractNode, INullable + { + public static Statement Null { + get { + return NullStatement.Instance; + } + } + + public virtual bool IsNull { + get { + return false; + } + } + + public static Statement CheckNull(Statement statement) + { + return statement ?? NullStatement.Instance; + } + } + + public abstract class StatementWithEmbeddedStatement : Statement + { + Statement embeddedStatement; + + public Statement EmbeddedStatement { + get { + return embeddedStatement; + } + set { + embeddedStatement = Statement.CheckNull(value); + if (value != null) + value.Parent = this; + } + } + } + + internal sealed class NullStatement : Statement + { + public static readonly NullStatement Instance = new NullStatement(); + + public override bool IsNull { + get { return true; } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return data; + } + + public override string ToString() + { + return String.Format("[NullStatement]"); + } + } +} diff --git a/Project/Src/Ast/Generated.cs b/Project/Src/Ast/Generated.cs new file mode 100644 index 0000000000..1ce85dd0fe --- /dev/null +++ b/Project/Src/Ast/Generated.cs @@ -0,0 +1,5805 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ICSharpCode.NRefactory.Ast { + using System; + using System.Collections.Generic; + + + public class AddHandlerStatement : Statement { + + Expression eventExpression; + + Expression handlerExpression; + + public Expression EventExpression { + get { + return eventExpression; + } + set { + eventExpression = value ?? Expression.Null; + if (!eventExpression.IsNull) eventExpression.Parent = this; + } + } + + public Expression HandlerExpression { + get { + return handlerExpression; + } + set { + handlerExpression = value ?? Expression.Null; + if (!handlerExpression.IsNull) handlerExpression.Parent = this; + } + } + + public AddHandlerStatement(Expression eventExpression, Expression handlerExpression) { + EventExpression = eventExpression; + HandlerExpression = handlerExpression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitAddHandlerStatement(this, data); + } + + public override string ToString() { + return string.Format("[AddHandlerStatement EventExpression={0} HandlerExpression={1}]", EventExpression, HandlerExpression); + } + } + + public class AddressOfExpression : Expression { + + Expression expression; + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public AddressOfExpression(Expression expression) { + Expression = expression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitAddressOfExpression(this, data); + } + + public override string ToString() { + return string.Format("[AddressOfExpression Expression={0}]", Expression); + } + } + + public class AnonymousMethodExpression : Expression { + + List parameters; + + BlockStatement body; + + bool hasParameterList; + + public List Parameters { + get { + return parameters; + } + set { + parameters = value ?? new List(); + } + } + + public BlockStatement Body { + get { + return body; + } + set { + body = value ?? BlockStatement.Null; + if (!body.IsNull) body.Parent = this; + } + } + + public bool HasParameterList { + get { + return hasParameterList; + } + set { + hasParameterList = value; + } + } + + public AnonymousMethodExpression() { + parameters = new List(); + body = BlockStatement.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitAnonymousMethodExpression(this, data); + } + + public override string ToString() { + return string.Format("[AnonymousMethodExpression Parameters={0} Body={1} HasParameterList={2}]", GetCollectionString(Parameters), Body, HasParameterList); + } + } + + public class ArrayCreateExpression : Expression { + + TypeReference createType; + + List arguments; + + CollectionInitializerExpression arrayInitializer; + + public TypeReference CreateType { + get { + return createType; + } + set { + createType = value ?? TypeReference.Null; + if (!createType.IsNull) createType.Parent = this; + } + } + + public List Arguments { + get { + return arguments; + } + set { + arguments = value ?? new List(); + } + } + + public CollectionInitializerExpression ArrayInitializer { + get { + return arrayInitializer; + } + set { + arrayInitializer = value ?? CollectionInitializerExpression.Null; + if (!arrayInitializer.IsNull) arrayInitializer.Parent = this; + } + } + + public ArrayCreateExpression(TypeReference createType) { + CreateType = createType; + arguments = new List(); + arrayInitializer = CollectionInitializerExpression.Null; + } + + public ArrayCreateExpression(TypeReference createType, List arguments) { + CreateType = createType; + Arguments = arguments; + arrayInitializer = CollectionInitializerExpression.Null; + } + + public ArrayCreateExpression(TypeReference createType, CollectionInitializerExpression arrayInitializer) { + CreateType = createType; + ArrayInitializer = arrayInitializer; + arguments = new List(); + } + + public bool IsImplicitlyTyped { + get { + return createType.IsNull || string.IsNullOrEmpty(createType.Type); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitArrayCreateExpression(this, data); + } + + public override string ToString() { + return string.Format("[ArrayCreateExpression CreateType={0} Arguments={1} ArrayInitializer={2}]", CreateType, GetCollectionString(Arguments), ArrayInitializer); + } + } + + public class AssignmentExpression : Expression { + + Expression left; + + AssignmentOperatorType op; + + Expression right; + + public Expression Left { + get { + return left; + } + set { + left = value ?? Expression.Null; + if (!left.IsNull) left.Parent = this; + } + } + + public AssignmentOperatorType Op { + get { + return op; + } + set { + op = value; + } + } + + public Expression Right { + get { + return right; + } + set { + right = value ?? Expression.Null; + if (!right.IsNull) right.Parent = this; + } + } + + public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right) { + Left = left; + Op = op; + Right = right; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitAssignmentExpression(this, data); + } + + public override string ToString() { + return string.Format("[AssignmentExpression Left={0} Op={1} Right={2}]", Left, Op, Right); + } + } + + public class Attribute : AbstractNode { + + string name; + + List positionalArguments; + + List namedArguments; + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public List PositionalArguments { + get { + return positionalArguments; + } + set { + positionalArguments = value ?? new List(); + } + } + + public List NamedArguments { + get { + return namedArguments; + } + set { + namedArguments = value ?? new List(); + } + } + + public Attribute() { + name = ""; + positionalArguments = new List(); + namedArguments = new List(); + } + + public Attribute(string name, List positionalArguments, List namedArguments) { + Name = name; + PositionalArguments = positionalArguments; + NamedArguments = namedArguments; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitAttribute(this, data); + } + + public override string ToString() { + return string.Format("[Attribute Name={0} PositionalArguments={1} NamedArguments={2}]", Name, GetCollectionString(PositionalArguments), GetCollectionString(NamedArguments)); + } + } + + public abstract class AttributedNode : AbstractNode { + + List attributes; + + Modifiers modifier; + + public List Attributes { + get { + return attributes; + } + set { + attributes = value ?? new List(); + } + } + + public Modifiers Modifier { + get { + return modifier; + } + set { + modifier = value; + } + } + + protected AttributedNode() { + attributes = new List(); + } + + protected AttributedNode(List attributes) { + Attributes = attributes; + } + + protected AttributedNode(Modifiers modifier, List attributes) { + Modifier = modifier; + Attributes = attributes; + } + } + + public class AttributeSection : AbstractNode { + + string attributeTarget; + + List attributes; + + public string AttributeTarget { + get { + return attributeTarget; + } + set { + attributeTarget = value ?? ""; + } + } + + public List Attributes { + get { + return attributes; + } + set { + attributes = value ?? new List(); + } + } + + public AttributeSection() { + attributeTarget = ""; + attributes = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitAttributeSection(this, data); + } + + public override string ToString() { + return string.Format("[AttributeSection AttributeTarget={0} Attributes={1}]", AttributeTarget, GetCollectionString(Attributes)); + } + } + + public class BaseReferenceExpression : Expression { + + public BaseReferenceExpression() { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitBaseReferenceExpression(this, data); + } + + public override string ToString() { + return "[BaseReferenceExpression]"; + } + } + + public class BinaryOperatorExpression : Expression { + + Expression left; + + BinaryOperatorType op; + + Expression right; + + public Expression Left { + get { + return left; + } + set { + left = value ?? Expression.Null; + if (!left.IsNull) left.Parent = this; + } + } + + public BinaryOperatorType Op { + get { + return op; + } + set { + op = value; + } + } + + public Expression Right { + get { + return right; + } + set { + right = value ?? Expression.Null; + if (!right.IsNull) right.Parent = this; + } + } + + public BinaryOperatorExpression() { + left = Expression.Null; + right = Expression.Null; + } + + public BinaryOperatorExpression(Expression left, BinaryOperatorType op, Expression right) { + Left = left; + Op = op; + Right = right; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitBinaryOperatorExpression(this, data); + } + + public override string ToString() { + return string.Format("[BinaryOperatorExpression Left={0} Op={1} Right={2}]", Left, Op, Right); + } + } + + public class BreakStatement : Statement { + + public BreakStatement() { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitBreakStatement(this, data); + } + + public override string ToString() { + return "[BreakStatement]"; + } + } + + public class CaseLabel : AbstractNode { + + Expression label; + + BinaryOperatorType binaryOperatorType; + + Expression toExpression; + + public Expression Label { + get { + return label; + } + set { + label = value ?? Expression.Null; + if (!label.IsNull) label.Parent = this; + } + } + + public BinaryOperatorType BinaryOperatorType { + get { + return binaryOperatorType; + } + set { + binaryOperatorType = value; + } + } + + public Expression ToExpression { + get { + return toExpression; + } + set { + toExpression = value ?? Expression.Null; + if (!toExpression.IsNull) toExpression.Parent = this; + } + } + + public CaseLabel() { + label = Expression.Null; + toExpression = Expression.Null; + } + + public CaseLabel(Expression label) { + Label = label; + toExpression = Expression.Null; + } + + public CaseLabel(Expression label, Expression toExpression) { + Label = label; + ToExpression = toExpression; + } + + public CaseLabel(BinaryOperatorType binaryOperatorType, Expression label) { + BinaryOperatorType = binaryOperatorType; + Label = label; + toExpression = Expression.Null; + } + + public bool IsDefault { + get { + return label.IsNull; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitCaseLabel(this, data); + } + + public override string ToString() { + return string.Format("[CaseLabel Label={0} BinaryOperatorType={1} ToExpression={2}]", Label, BinaryOperatorType, ToExpression); + } + } + + public class CastExpression : Expression { + + TypeReference castTo; + + Expression expression; + + CastType castType; + + public TypeReference CastTo { + get { + return castTo; + } + set { + castTo = value ?? TypeReference.Null; + if (!castTo.IsNull) castTo.Parent = this; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public CastType CastType { + get { + return castType; + } + set { + castType = value; + } + } + + public CastExpression(TypeReference castTo) { + CastTo = castTo; + expression = Expression.Null; + } + + public CastExpression(TypeReference castTo, Expression expression, CastType castType) { + CastTo = castTo; + Expression = expression; + CastType = castType; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitCastExpression(this, data); + } + + public override string ToString() { + return string.Format("[CastExpression CastTo={0} Expression={1} CastType={2}]", CastTo, Expression, CastType); + } + } + + public class CatchClause : AbstractNode { + + TypeReference typeReference; + + string variableName; + + Statement statementBlock; + + Expression condition; + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public string VariableName { + get { + return variableName; + } + set { + variableName = value ?? ""; + } + } + + public Statement StatementBlock { + get { + return statementBlock; + } + set { + statementBlock = value ?? Statement.Null; + if (!statementBlock.IsNull) statementBlock.Parent = this; + } + } + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + if (!condition.IsNull) condition.Parent = this; + } + } + + public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock) { + TypeReference = typeReference; + VariableName = variableName; + StatementBlock = statementBlock; + condition = Expression.Null; + } + + public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock, Expression condition) { + TypeReference = typeReference; + VariableName = variableName; + StatementBlock = statementBlock; + Condition = condition; + } + + public CatchClause(Statement statementBlock) { + StatementBlock = statementBlock; + typeReference = TypeReference.Null; + variableName = ""; + condition = Expression.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitCatchClause(this, data); + } + + public override string ToString() { + return string.Format("[CatchClause TypeReference={0} VariableName={1} StatementBlock={2} Condition={3}]" + + "", TypeReference, VariableName, StatementBlock, Condition); + } + } + + public class CheckedExpression : Expression { + + Expression expression; + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public CheckedExpression(Expression expression) { + Expression = expression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitCheckedExpression(this, data); + } + + public override string ToString() { + return string.Format("[CheckedExpression Expression={0}]", Expression); + } + } + + public class CheckedStatement : Statement { + + Statement block; + + public Statement Block { + get { + return block; + } + set { + block = value ?? Statement.Null; + if (!block.IsNull) block.Parent = this; + } + } + + public CheckedStatement(Statement block) { + Block = block; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitCheckedStatement(this, data); + } + + public override string ToString() { + return string.Format("[CheckedStatement Block={0}]", Block); + } + } + + public class ClassReferenceExpression : Expression { + + public ClassReferenceExpression() { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitClassReferenceExpression(this, data); + } + + public override string ToString() { + return "[ClassReferenceExpression]"; + } + } + + public class CollectionInitializerExpression : Expression { + + List createExpressions; + + public List CreateExpressions { + get { + return createExpressions; + } + set { + createExpressions = value ?? new List(); + } + } + + public CollectionInitializerExpression() { + createExpressions = new List(); + } + + public CollectionInitializerExpression(List createExpressions) { + CreateExpressions = createExpressions; + } + + public new static CollectionInitializerExpression Null { + get { + return NullCollectionInitializerExpression.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitCollectionInitializerExpression(this, data); + } + + public override string ToString() { + return string.Format("[CollectionInitializerExpression CreateExpressions={0}]", GetCollectionString(CreateExpressions)); + } + } + + internal sealed class NullCollectionInitializerExpression : CollectionInitializerExpression { + + internal static NullCollectionInitializerExpression Instance = new NullCollectionInitializerExpression(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullCollectionInitializerExpression]"; + } + } + + public class CollectionRangeVariable : AbstractNode, INullable { + + string identifier; + + Expression expression; + + TypeReference type; + + public string Identifier { + get { + return identifier; + } + set { + identifier = value ?? ""; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public TypeReference Type { + get { + return type; + } + set { + type = value ?? TypeReference.Null; + if (!type.IsNull) type.Parent = this; + } + } + + public CollectionRangeVariable() { + identifier = ""; + expression = Expression.Null; + type = TypeReference.Null; + } + + public virtual bool IsNull { + get { + return false; + } + } + + public static CollectionRangeVariable Null { + get { + return NullCollectionRangeVariable.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitCollectionRangeVariable(this, data); + } + + public override string ToString() { + return string.Format("[CollectionRangeVariable Identifier={0} Expression={1} Type={2}]", Identifier, Expression, Type); + } + } + + internal sealed class NullCollectionRangeVariable : CollectionRangeVariable { + + internal static NullCollectionRangeVariable Instance = new NullCollectionRangeVariable(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullCollectionRangeVariable]"; + } + } + + public class ConditionalExpression : Expression { + + Expression condition; + + Expression trueExpression; + + Expression falseExpression; + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + if (!condition.IsNull) condition.Parent = this; + } + } + + public Expression TrueExpression { + get { + return trueExpression; + } + set { + trueExpression = value ?? Expression.Null; + if (!trueExpression.IsNull) trueExpression.Parent = this; + } + } + + public Expression FalseExpression { + get { + return falseExpression; + } + set { + falseExpression = value ?? Expression.Null; + if (!falseExpression.IsNull) falseExpression.Parent = this; + } + } + + public ConditionalExpression() { + condition = Expression.Null; + trueExpression = Expression.Null; + falseExpression = Expression.Null; + } + + public ConditionalExpression(Expression condition, Expression trueExpression, Expression falseExpression) { + Condition = condition; + TrueExpression = trueExpression; + FalseExpression = falseExpression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitConditionalExpression(this, data); + } + + public override string ToString() { + return string.Format("[ConditionalExpression Condition={0} TrueExpression={1} FalseExpression={2}]", Condition, TrueExpression, FalseExpression); + } + } + + public class ConstructorDeclaration : ParametrizedNode { + + ConstructorInitializer constructorInitializer; + + BlockStatement body; + + public ConstructorInitializer ConstructorInitializer { + get { + return constructorInitializer; + } + set { + constructorInitializer = value ?? ConstructorInitializer.Null; + if (!constructorInitializer.IsNull) constructorInitializer.Parent = this; + } + } + + public BlockStatement Body { + get { + return body; + } + set { + body = value ?? BlockStatement.Null; + if (!body.IsNull) body.Parent = this; + } + } + + public ConstructorDeclaration(string name, Modifiers modifier, List parameters, List attributes) { + Name = name; + Modifier = modifier; + Parameters = parameters; + Attributes = attributes; + constructorInitializer = ConstructorInitializer.Null; + body = BlockStatement.Null; + } + + public ConstructorDeclaration(string name, Modifiers modifier, List parameters, ConstructorInitializer constructorInitializer, List attributes) { + Name = name; + Modifier = modifier; + Parameters = parameters; + ConstructorInitializer = constructorInitializer; + Attributes = attributes; + body = BlockStatement.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitConstructorDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[ConstructorDeclaration ConstructorInitializer={0} Body={1} Name={2} Parameters={" + + "3} Attributes={4} Modifier={5}]", ConstructorInitializer, Body, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + public class ConstructorInitializer : AbstractNode, INullable { + + ConstructorInitializerType constructorInitializerType; + + List arguments; + + public ConstructorInitializerType ConstructorInitializerType { + get { + return constructorInitializerType; + } + set { + constructorInitializerType = value; + } + } + + public List Arguments { + get { + return arguments; + } + set { + arguments = value ?? new List(); + } + } + + public ConstructorInitializer() { + arguments = new List(); + } + + public virtual bool IsNull { + get { + return false; + } + } + + public static ConstructorInitializer Null { + get { + return NullConstructorInitializer.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitConstructorInitializer(this, data); + } + + public override string ToString() { + return string.Format("[ConstructorInitializer ConstructorInitializerType={0} Arguments={1}]", ConstructorInitializerType, GetCollectionString(Arguments)); + } + } + + internal sealed class NullConstructorInitializer : ConstructorInitializer { + + internal static NullConstructorInitializer Instance = new NullConstructorInitializer(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullConstructorInitializer]"; + } + } + + public class ContinueStatement : Statement { + + ContinueType continueType; + + public ContinueType ContinueType { + get { + return continueType; + } + set { + continueType = value; + } + } + + public ContinueStatement() { + } + + public ContinueStatement(ContinueType continueType) { + ContinueType = continueType; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitContinueStatement(this, data); + } + + public override string ToString() { + return string.Format("[ContinueStatement ContinueType={0}]", ContinueType); + } + } + + public class DeclareDeclaration : ParametrizedNode { + + string alias; + + string library; + + CharsetModifier charset; + + TypeReference typeReference; + + public string Alias { + get { + return alias; + } + set { + alias = value ?? ""; + } + } + + public string Library { + get { + return library; + } + set { + library = value ?? ""; + } + } + + public CharsetModifier Charset { + get { + return charset; + } + set { + charset = value; + } + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public DeclareDeclaration(string name, Modifiers modifier, TypeReference typeReference, List parameters, List attributes, string library, string alias, CharsetModifier charset) { + Name = name; + Modifier = modifier; + TypeReference = typeReference; + Parameters = parameters; + Attributes = attributes; + Library = library; + Alias = alias; + Charset = charset; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitDeclareDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[DeclareDeclaration Alias={0} Library={1} Charset={2} TypeReference={3} Name={4} " + + "Parameters={5} Attributes={6} Modifier={7}]", Alias, Library, Charset, TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + public class DefaultValueExpression : Expression { + + TypeReference typeReference; + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public DefaultValueExpression(TypeReference typeReference) { + TypeReference = typeReference; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitDefaultValueExpression(this, data); + } + + public override string ToString() { + return string.Format("[DefaultValueExpression TypeReference={0}]", TypeReference); + } + } + + public class DelegateDeclaration : AttributedNode { + + string name; + + TypeReference returnType; + + List parameters; + + List templates; + + public string Name { + get { + return name; + } + set { + name = string.IsNullOrEmpty(value) ? "?" : value; + } + } + + public TypeReference ReturnType { + get { + return returnType; + } + set { + returnType = value ?? TypeReference.Null; + if (!returnType.IsNull) returnType.Parent = this; + } + } + + public List Parameters { + get { + return parameters; + } + set { + parameters = value ?? new List(); + } + } + + public List Templates { + get { + return templates; + } + set { + templates = value ?? new List(); + } + } + + public DelegateDeclaration(Modifiers modifier, List attributes) { + Modifier = modifier; + Attributes = attributes; + name = "?"; + returnType = TypeReference.Null; + parameters = new List(); + templates = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitDelegateDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[DelegateDeclaration Name={0} ReturnType={1} Parameters={2} Templates={3} Attribu" + + "tes={4} Modifier={5}]", Name, ReturnType, GetCollectionString(Parameters), GetCollectionString(Templates), GetCollectionString(Attributes), Modifier); + } + } + + public class DestructorDeclaration : AttributedNode { + + string name; + + BlockStatement body; + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public BlockStatement Body { + get { + return body; + } + set { + body = value ?? BlockStatement.Null; + if (!body.IsNull) body.Parent = this; + } + } + + public DestructorDeclaration(string name, Modifiers modifier, List attributes) { + Name = name; + Modifier = modifier; + Attributes = attributes; + body = BlockStatement.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitDestructorDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[DestructorDeclaration Name={0} Body={1} Attributes={2} Modifier={3}]", Name, Body, GetCollectionString(Attributes), Modifier); + } + } + + public class DirectionExpression : Expression { + + FieldDirection fieldDirection; + + Expression expression; + + public FieldDirection FieldDirection { + get { + return fieldDirection; + } + set { + fieldDirection = value; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public DirectionExpression(FieldDirection fieldDirection, Expression expression) { + FieldDirection = fieldDirection; + Expression = expression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitDirectionExpression(this, data); + } + + public override string ToString() { + return string.Format("[DirectionExpression FieldDirection={0} Expression={1}]", FieldDirection, Expression); + } + } + + public class DoLoopStatement : StatementWithEmbeddedStatement { + + Expression condition; + + ConditionType conditionType; + + ConditionPosition conditionPosition; + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + if (!condition.IsNull) condition.Parent = this; + } + } + + public ConditionType ConditionType { + get { + return conditionType; + } + set { + conditionType = value; + } + } + + public ConditionPosition ConditionPosition { + get { + return conditionPosition; + } + set { + conditionPosition = value; + } + } + + public DoLoopStatement(Expression condition, Statement embeddedStatement, ConditionType conditionType, ConditionPosition conditionPosition) { + Condition = condition; + EmbeddedStatement = embeddedStatement; + ConditionType = conditionType; + ConditionPosition = conditionPosition; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitDoLoopStatement(this, data); + } + + public override string ToString() { + return string.Format("[DoLoopStatement Condition={0} ConditionType={1} ConditionPosition={2} EmbeddedSt" + + "atement={3}]", Condition, ConditionType, ConditionPosition, EmbeddedStatement); + } + } + + public class ElseIfSection : StatementWithEmbeddedStatement { + + Expression condition; + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + if (!condition.IsNull) condition.Parent = this; + } + } + + public ElseIfSection(Expression condition, Statement embeddedStatement) { + Condition = condition; + EmbeddedStatement = embeddedStatement; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitElseIfSection(this, data); + } + + public override string ToString() { + return string.Format("[ElseIfSection Condition={0} EmbeddedStatement={1}]", Condition, EmbeddedStatement); + } + } + + public class EmptyStatement : Statement { + + public EmptyStatement() { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitEmptyStatement(this, data); + } + + public override string ToString() { + return "[EmptyStatement]"; + } + } + + public class EndStatement : Statement { + + public EndStatement() { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitEndStatement(this, data); + } + + public override string ToString() { + return "[EndStatement]"; + } + } + + public class EraseStatement : Statement { + + List expressions; + + public List Expressions { + get { + return expressions; + } + set { + expressions = value ?? new List(); + } + } + + public EraseStatement() { + expressions = new List(); + } + + public EraseStatement(List expressions) { + Expressions = expressions; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitEraseStatement(this, data); + } + + public override string ToString() { + return string.Format("[EraseStatement Expressions={0}]", GetCollectionString(Expressions)); + } + } + + public class ErrorStatement : Statement { + + Expression expression; + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public ErrorStatement(Expression expression) { + Expression = expression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitErrorStatement(this, data); + } + + public override string ToString() { + return string.Format("[ErrorStatement Expression={0}]", Expression); + } + } + + public class EventAddRegion : EventAddRemoveRegion { + + public EventAddRegion(List attributes) : + base(attributes) { + } + + public static EventAddRegion Null { + get { + return NullEventAddRegion.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitEventAddRegion(this, data); + } + + public override string ToString() { + return string.Format("[EventAddRegion Block={0} Parameters={1} Attributes={2} Modifier={3}]", Block, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + internal sealed class NullEventAddRegion : EventAddRegion { + + private NullEventAddRegion() : + base(null) { + } + + internal static NullEventAddRegion Instance = new NullEventAddRegion(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullEventAddRegion]"; + } + } + + public abstract class EventAddRemoveRegion : AttributedNode, INullable { + + BlockStatement block; + + List parameters; + + public BlockStatement Block { + get { + return block; + } + set { + block = value ?? BlockStatement.Null; + if (!block.IsNull) block.Parent = this; + } + } + + public List Parameters { + get { + return parameters; + } + set { + parameters = value ?? new List(); + } + } + + protected EventAddRemoveRegion(List attributes) { + Attributes = attributes; + block = BlockStatement.Null; + parameters = new List(); + } + + public virtual bool IsNull { + get { + return false; + } + } + } + + public class EventDeclaration : MemberNode { + + EventAddRegion addRegion; + + EventRemoveRegion removeRegion; + + EventRaiseRegion raiseRegion; + + Location bodyStart; + + Location bodyEnd; + + Expression initializer; + + public EventAddRegion AddRegion { + get { + return addRegion; + } + set { + addRegion = value ?? EventAddRegion.Null; + if (!addRegion.IsNull) addRegion.Parent = this; + } + } + + public EventRemoveRegion RemoveRegion { + get { + return removeRegion; + } + set { + removeRegion = value ?? EventRemoveRegion.Null; + if (!removeRegion.IsNull) removeRegion.Parent = this; + } + } + + public EventRaiseRegion RaiseRegion { + get { + return raiseRegion; + } + set { + raiseRegion = value ?? EventRaiseRegion.Null; + if (!raiseRegion.IsNull) raiseRegion.Parent = this; + } + } + + public Location BodyStart { + get { + return bodyStart; + } + set { + bodyStart = value; + } + } + + public Location BodyEnd { + get { + return bodyEnd; + } + set { + bodyEnd = value; + } + } + + public Expression Initializer { + get { + return initializer; + } + set { + initializer = value ?? Expression.Null; + if (!initializer.IsNull) initializer.Parent = this; + } + } + + public EventDeclaration() { + addRegion = EventAddRegion.Null; + removeRegion = EventRemoveRegion.Null; + raiseRegion = EventRaiseRegion.Null; + bodyStart = Location.Empty; + bodyEnd = Location.Empty; + initializer = Expression.Null; + } + + public bool HasRaiseRegion { + get { + return !raiseRegion.IsNull; + } + } + + public bool HasRemoveRegion { + get { + return !removeRegion.IsNull; + } + } + + public bool HasAddRegion { + get { + return !addRegion.IsNull; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitEventDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[EventDeclaration AddRegion={0} RemoveRegion={1} RaiseRegion={2} BodyStart={3} Bo" + + "dyEnd={4} Initializer={5} InterfaceImplementations={6} TypeReference={7} Name={8" + + "} Parameters={9} Attributes={10} Modifier={11}]", AddRegion, RemoveRegion, RaiseRegion, BodyStart, BodyEnd, Initializer, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + public class EventRaiseRegion : EventAddRemoveRegion { + + public EventRaiseRegion(List attributes) : + base(attributes) { + } + + public static EventRaiseRegion Null { + get { + return NullEventRaiseRegion.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitEventRaiseRegion(this, data); + } + + public override string ToString() { + return string.Format("[EventRaiseRegion Block={0} Parameters={1} Attributes={2} Modifier={3}]", Block, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + internal sealed class NullEventRaiseRegion : EventRaiseRegion { + + private NullEventRaiseRegion() : + base(null) { + } + + internal static NullEventRaiseRegion Instance = new NullEventRaiseRegion(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullEventRaiseRegion]"; + } + } + + public class EventRemoveRegion : EventAddRemoveRegion { + + public EventRemoveRegion(List attributes) : + base(attributes) { + } + + public static EventRemoveRegion Null { + get { + return NullEventRemoveRegion.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitEventRemoveRegion(this, data); + } + + public override string ToString() { + return string.Format("[EventRemoveRegion Block={0} Parameters={1} Attributes={2} Modifier={3}]", Block, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + internal sealed class NullEventRemoveRegion : EventRemoveRegion { + + private NullEventRemoveRegion() : + base(null) { + } + + internal static NullEventRemoveRegion Instance = new NullEventRemoveRegion(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullEventRemoveRegion]"; + } + } + + public class ExitStatement : Statement { + + ExitType exitType; + + public ExitType ExitType { + get { + return exitType; + } + set { + exitType = value; + } + } + + public ExitStatement(ExitType exitType) { + ExitType = exitType; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitExitStatement(this, data); + } + + public override string ToString() { + return string.Format("[ExitStatement ExitType={0}]", ExitType); + } + } + + public class ExpressionRangeVariable : AbstractNode, INullable { + + string identifier; + + Expression expression; + + TypeReference type; + + public string Identifier { + get { + return identifier; + } + set { + identifier = value ?? ""; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public TypeReference Type { + get { + return type; + } + set { + type = value ?? TypeReference.Null; + if (!type.IsNull) type.Parent = this; + } + } + + public ExpressionRangeVariable() { + identifier = ""; + expression = Expression.Null; + type = TypeReference.Null; + } + + public virtual bool IsNull { + get { + return false; + } + } + + public static ExpressionRangeVariable Null { + get { + return NullExpressionRangeVariable.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitExpressionRangeVariable(this, data); + } + + public override string ToString() { + return string.Format("[ExpressionRangeVariable Identifier={0} Expression={1} Type={2}]", Identifier, Expression, Type); + } + } + + internal sealed class NullExpressionRangeVariable : ExpressionRangeVariable { + + internal static NullExpressionRangeVariable Instance = new NullExpressionRangeVariable(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullExpressionRangeVariable]"; + } + } + + public class ExpressionStatement : Statement { + + Expression expression; + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public ExpressionStatement(Expression expression) { + Expression = expression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitExpressionStatement(this, data); + } + + public override string ToString() { + return string.Format("[ExpressionStatement Expression={0}]", Expression); + } + } + + public class ExternAliasDirective : AbstractNode { + + string name; + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public ExternAliasDirective() { + name = ""; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitExternAliasDirective(this, data); + } + + public override string ToString() { + return string.Format("[ExternAliasDirective Name={0}]", Name); + } + } + + public class FieldDeclaration : AttributedNode { + + TypeReference typeReference; + + List fields; + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public List Fields { + get { + return fields; + } + set { + fields = value ?? new List(); + } + } + + public FieldDeclaration(List attributes) { + Attributes = attributes; + typeReference = TypeReference.Null; + fields = new List(); + } + + public FieldDeclaration(List attributes, TypeReference typeReference, Modifiers modifier) { + Attributes = attributes; + TypeReference = typeReference; + Modifier = modifier; + fields = new List(); + } + + + public VariableDeclaration GetVariableDeclaration(string variableName) + { + foreach (VariableDeclaration variableDeclaration in Fields) { + if (variableDeclaration.Name == variableName) { + return variableDeclaration; + } + } + return null; + } + + + public TypeReference GetTypeForField(int fieldIndex) + { + if (!typeReference.IsNull) { + return typeReference; + } + return ((VariableDeclaration)Fields[fieldIndex]).TypeReference; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitFieldDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[FieldDeclaration TypeReference={0} Fields={1} Attributes={2} Modifier={3}]", TypeReference, GetCollectionString(Fields), GetCollectionString(Attributes), Modifier); + } + } + + public class FixedStatement : StatementWithEmbeddedStatement { + + Statement pointerDeclaration; + + public Statement PointerDeclaration { + get { + return pointerDeclaration; + } + set { + pointerDeclaration = value ?? Statement.Null; + if (!pointerDeclaration.IsNull) pointerDeclaration.Parent = this; + } + } + + public FixedStatement(Statement pointerDeclaration, Statement embeddedStatement) { + PointerDeclaration = pointerDeclaration; + EmbeddedStatement = embeddedStatement; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitFixedStatement(this, data); + } + + public override string ToString() { + return string.Format("[FixedStatement PointerDeclaration={0} EmbeddedStatement={1}]", PointerDeclaration, EmbeddedStatement); + } + } + + public class ForeachStatement : StatementWithEmbeddedStatement { + + TypeReference typeReference; + + string variableName; + + Expression expression; + + Expression nextExpression; + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public string VariableName { + get { + return variableName; + } + set { + variableName = value ?? ""; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public Expression NextExpression { + get { + return nextExpression; + } + set { + nextExpression = value ?? Expression.Null; + if (!nextExpression.IsNull) nextExpression.Parent = this; + } + } + + public ForeachStatement(TypeReference typeReference, string variableName, Expression expression, Statement embeddedStatement) { + TypeReference = typeReference; + VariableName = variableName; + Expression = expression; + EmbeddedStatement = embeddedStatement; + nextExpression = Expression.Null; + } + + public ForeachStatement(TypeReference typeReference, string variableName, Expression expression, Statement embeddedStatement, Expression nextExpression) { + TypeReference = typeReference; + VariableName = variableName; + Expression = expression; + EmbeddedStatement = embeddedStatement; + NextExpression = nextExpression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitForeachStatement(this, data); + } + + public override string ToString() { + return string.Format("[ForeachStatement TypeReference={0} VariableName={1} Expression={2} NextExpressio" + + "n={3} EmbeddedStatement={4}]", TypeReference, VariableName, Expression, NextExpression, EmbeddedStatement); + } + } + + public class ForNextStatement : StatementWithEmbeddedStatement { + + Expression start; + + Expression end; + + Expression step; + + List nextExpressions; + + TypeReference typeReference; + + string variableName; + + Expression loopVariableExpression; + + public Expression Start { + get { + return start; + } + set { + start = value ?? Expression.Null; + if (!start.IsNull) start.Parent = this; + } + } + + public Expression End { + get { + return end; + } + set { + end = value ?? Expression.Null; + if (!end.IsNull) end.Parent = this; + } + } + + public Expression Step { + get { + return step; + } + set { + step = value ?? Expression.Null; + if (!step.IsNull) step.Parent = this; + } + } + + public List NextExpressions { + get { + return nextExpressions; + } + set { + nextExpressions = value ?? new List(); + } + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public string VariableName { + get { + return variableName; + } + set { + variableName = value ?? ""; + } + } + + public Expression LoopVariableExpression { + get { + return loopVariableExpression; + } + set { + loopVariableExpression = value ?? Expression.Null; + if (!loopVariableExpression.IsNull) loopVariableExpression.Parent = this; + } + } + + public ForNextStatement() { + start = Expression.Null; + end = Expression.Null; + step = Expression.Null; + nextExpressions = new List(); + typeReference = TypeReference.Null; + variableName = ""; + loopVariableExpression = Expression.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitForNextStatement(this, data); + } + + public override string ToString() { + return string.Format("[ForNextStatement Start={0} End={1} Step={2} NextExpressions={3} TypeReference={4" + + "} VariableName={5} LoopVariableExpression={6} EmbeddedStatement={7}]", Start, End, Step, GetCollectionString(NextExpressions), TypeReference, VariableName, LoopVariableExpression, EmbeddedStatement); + } + } + + public class ForStatement : StatementWithEmbeddedStatement { + + List initializers; + + Expression condition; + + List iterator; + + public List Initializers { + get { + return initializers; + } + set { + initializers = value ?? new List(); + } + } + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + if (!condition.IsNull) condition.Parent = this; + } + } + + public List Iterator { + get { + return iterator; + } + set { + iterator = value ?? new List(); + } + } + + public ForStatement(List initializers, Expression condition, List iterator, Statement embeddedStatement) { + Initializers = initializers; + Condition = condition; + Iterator = iterator; + EmbeddedStatement = embeddedStatement; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitForStatement(this, data); + } + + public override string ToString() { + return string.Format("[ForStatement Initializers={0} Condition={1} Iterator={2} EmbeddedStatement={3}]", GetCollectionString(Initializers), Condition, GetCollectionString(Iterator), EmbeddedStatement); + } + } + + public class GotoCaseStatement : Statement { + + Expression expression; + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public GotoCaseStatement(Expression expression) { + Expression = expression; + } + + public bool IsDefaultCase { + get { + return expression.IsNull; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitGotoCaseStatement(this, data); + } + + public override string ToString() { + return string.Format("[GotoCaseStatement Expression={0}]", Expression); + } + } + + public class GotoStatement : Statement { + + string label; + + public string Label { + get { + return label; + } + set { + label = value ?? ""; + } + } + + public GotoStatement(string label) { + Label = label; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitGotoStatement(this, data); + } + + public override string ToString() { + return string.Format("[GotoStatement Label={0}]", Label); + } + } + + public class IdentifierExpression : Expression { + + string identifier; + + List typeArguments; + + public string Identifier { + get { + return identifier; + } + set { + identifier = value ?? ""; + } + } + + public List TypeArguments { + get { + return typeArguments; + } + set { + typeArguments = value ?? new List(); + } + } + + public IdentifierExpression(string identifier) { + Identifier = identifier; + typeArguments = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitIdentifierExpression(this, data); + } + + public override string ToString() { + return string.Format("[IdentifierExpression Identifier={0} TypeArguments={1}]", Identifier, GetCollectionString(TypeArguments)); + } + } + + public class IfElseStatement : Statement { + + Expression condition; + + List trueStatement; + + List falseStatement; + + List elseIfSections; + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + if (!condition.IsNull) condition.Parent = this; + } + } + + public List TrueStatement { + get { + return trueStatement; + } + set { + trueStatement = value ?? new List(); + } + } + + public List FalseStatement { + get { + return falseStatement; + } + set { + falseStatement = value ?? new List(); + } + } + + public List ElseIfSections { + get { + return elseIfSections; + } + set { + elseIfSections = value ?? new List(); + } + } + + public IfElseStatement(Expression condition) { + Condition = condition; + trueStatement = new List(); + falseStatement = new List(); + elseIfSections = new List(); + } + + public bool HasElseStatements { + get { + return falseStatement.Count > 0; + } + } + + + public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement) + : this(condition) { + this.trueStatement.Add(Statement.CheckNull(trueStatement)); + this.falseStatement.Add(Statement.CheckNull(falseStatement)); + if (trueStatement != null) trueStatement.Parent = this; + if (falseStatement != null) falseStatement.Parent = this; + } + + public bool HasElseIfSections { + get { + return elseIfSections.Count > 0; + } + } + + + public IfElseStatement(Expression condition, Statement trueStatement) + : this(condition) { + this.trueStatement.Add(Statement.CheckNull(trueStatement)); + if (trueStatement != null) trueStatement.Parent = this; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitIfElseStatement(this, data); + } + + public override string ToString() { + return string.Format("[IfElseStatement Condition={0} TrueStatement={1} FalseStatement={2} ElseIfSection" + + "s={3}]", Condition, GetCollectionString(TrueStatement), GetCollectionString(FalseStatement), GetCollectionString(ElseIfSections)); + } + } + + public class IndexerExpression : Expression { + + Expression targetObject; + + List indexes; + + public Expression TargetObject { + get { + return targetObject; + } + set { + targetObject = value ?? Expression.Null; + if (!targetObject.IsNull) targetObject.Parent = this; + } + } + + public List Indexes { + get { + return indexes; + } + set { + indexes = value ?? new List(); + } + } + + public IndexerExpression(Expression targetObject, List indexes) { + TargetObject = targetObject; + Indexes = indexes; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitIndexerExpression(this, data); + } + + public override string ToString() { + return string.Format("[IndexerExpression TargetObject={0} Indexes={1}]", TargetObject, GetCollectionString(Indexes)); + } + } + + public class InterfaceImplementation : AbstractNode { + + TypeReference interfaceType; + + string memberName; + + public TypeReference InterfaceType { + get { + return interfaceType; + } + set { + interfaceType = value ?? TypeReference.Null; + if (!interfaceType.IsNull) interfaceType.Parent = this; + } + } + + public string MemberName { + get { + return memberName; + } + set { + memberName = string.IsNullOrEmpty(value) ? "?" : value; + } + } + + public InterfaceImplementation(TypeReference interfaceType, string memberName) { + InterfaceType = interfaceType; + MemberName = memberName; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitInterfaceImplementation(this, data); + } + + public override string ToString() { + return string.Format("[InterfaceImplementation InterfaceType={0} MemberName={1}]", InterfaceType, MemberName); + } + } + + public class InvocationExpression : Expression { + + Expression targetObject; + + List arguments; + + public Expression TargetObject { + get { + return targetObject; + } + set { + targetObject = value ?? Expression.Null; + if (!targetObject.IsNull) targetObject.Parent = this; + } + } + + public List Arguments { + get { + return arguments; + } + set { + arguments = value ?? new List(); + } + } + + public InvocationExpression(Expression targetObject) { + TargetObject = targetObject; + arguments = new List(); + } + + public InvocationExpression(Expression targetObject, List arguments) { + TargetObject = targetObject; + Arguments = arguments; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitInvocationExpression(this, data); + } + + public override string ToString() { + return string.Format("[InvocationExpression TargetObject={0} Arguments={1}]", TargetObject, GetCollectionString(Arguments)); + } + } + + public class LabelStatement : Statement { + + string label; + + public string Label { + get { + return label; + } + set { + label = value ?? ""; + } + } + + public LabelStatement(string label) { + Label = label; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitLabelStatement(this, data); + } + + public override string ToString() { + return string.Format("[LabelStatement Label={0}]", Label); + } + } + + public class LambdaExpression : Expression { + + List parameters; + + Statement statementBody; + + Expression expressionBody; + + TypeReference returnType; + + public List Parameters { + get { + return parameters; + } + set { + parameters = value ?? new List(); + } + } + + public Statement StatementBody { + get { + return statementBody; + } + set { + statementBody = value ?? Statement.Null; + if (!statementBody.IsNull) statementBody.Parent = this; + } + } + + public Expression ExpressionBody { + get { + return expressionBody; + } + set { + expressionBody = value ?? Expression.Null; + if (!expressionBody.IsNull) expressionBody.Parent = this; + } + } + + public TypeReference ReturnType { + get { + return returnType; + } + set { + returnType = value ?? TypeReference.Null; + if (!returnType.IsNull) returnType.Parent = this; + } + } + + public LambdaExpression() { + parameters = new List(); + statementBody = Statement.Null; + expressionBody = Expression.Null; + returnType = TypeReference.Null; + } + +public Location ExtendedEndLocation { get; set; } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitLambdaExpression(this, data); + } + + public override string ToString() { + return string.Format("[LambdaExpression Parameters={0} StatementBody={1} ExpressionBody={2} ReturnType=" + + "{3}]", GetCollectionString(Parameters), StatementBody, ExpressionBody, ReturnType); + } + } + + public class LockStatement : StatementWithEmbeddedStatement { + + Expression lockExpression; + + public Expression LockExpression { + get { + return lockExpression; + } + set { + lockExpression = value ?? Expression.Null; + if (!lockExpression.IsNull) lockExpression.Parent = this; + } + } + + public LockStatement(Expression lockExpression, Statement embeddedStatement) { + LockExpression = lockExpression; + EmbeddedStatement = embeddedStatement; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitLockStatement(this, data); + } + + public override string ToString() { + return string.Format("[LockStatement LockExpression={0} EmbeddedStatement={1}]", LockExpression, EmbeddedStatement); + } + } + + public class MemberInitializerExpression : Expression { + + string name; + + bool isKey; + + Expression expression; + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public bool IsKey { + get { + return isKey; + } + set { + isKey = value; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public MemberInitializerExpression() { + name = ""; + expression = Expression.Null; + } + + public MemberInitializerExpression(string name, Expression expression) { + Name = name; + Expression = expression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitMemberInitializerExpression(this, data); + } + + public override string ToString() { + return string.Format("[MemberInitializerExpression Name={0} IsKey={1} Expression={2}]", Name, IsKey, Expression); + } + } + + public abstract class MemberNode : ParametrizedNode { + + List interfaceImplementations; + + TypeReference typeReference; + + public List InterfaceImplementations { + get { + return interfaceImplementations; + } + set { + interfaceImplementations = value ?? new List(); + } + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + protected MemberNode() { + interfaceImplementations = new List(); + typeReference = TypeReference.Null; + } + + protected MemberNode(Modifiers modifier, List attributes, string name, List parameters) { + Modifier = modifier; + Attributes = attributes; + Name = name; + Parameters = parameters; + interfaceImplementations = new List(); + typeReference = TypeReference.Null; + } + } + + public class MemberReferenceExpression : Expression { + + Expression targetObject; + + string memberName; + + List typeArguments; + + public Expression TargetObject { + get { + return targetObject; + } + set { + targetObject = value ?? Expression.Null; + if (!targetObject.IsNull) targetObject.Parent = this; + } + } + + public string MemberName { + get { + return memberName; + } + set { + memberName = value ?? ""; + } + } + + public List TypeArguments { + get { + return typeArguments; + } + set { + typeArguments = value ?? new List(); + } + } + + public MemberReferenceExpression(Expression targetObject, string memberName) { + TargetObject = targetObject; + MemberName = memberName; + typeArguments = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitMemberReferenceExpression(this, data); + } + + public override string ToString() { + return string.Format("[MemberReferenceExpression TargetObject={0} MemberName={1} TypeArguments={2}]", TargetObject, MemberName, GetCollectionString(TypeArguments)); + } + } + + public class MethodDeclaration : MemberNode { + + BlockStatement body; + + List handlesClause; + + List templates; + + bool isExtensionMethod; + + public BlockStatement Body { + get { + return body; + } + set { + body = value ?? BlockStatement.Null; + if (!body.IsNull) body.Parent = this; + } + } + + public List HandlesClause { + get { + return handlesClause; + } + set { + handlesClause = value ?? new List(); + } + } + + public List Templates { + get { + return templates; + } + set { + templates = value ?? new List(); + } + } + + public bool IsExtensionMethod { + get { + return isExtensionMethod; + } + set { + isExtensionMethod = value; + } + } + + public MethodDeclaration() { + body = BlockStatement.Null; + handlesClause = new List(); + templates = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitMethodDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[MethodDeclaration Body={0} HandlesClause={1} Templates={2} IsExtensionMethod={3}" + + " InterfaceImplementations={4} TypeReference={5} Name={6} Parameters={7} Attribut" + + "es={8} Modifier={9}]", Body, GetCollectionString(HandlesClause), GetCollectionString(Templates), IsExtensionMethod, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + public class NamedArgumentExpression : Expression { + + string name; + + Expression expression; + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public NamedArgumentExpression() { + name = ""; + expression = Expression.Null; + } + + public NamedArgumentExpression(string name, Expression expression) { + Name = name; + Expression = expression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitNamedArgumentExpression(this, data); + } + + public override string ToString() { + return string.Format("[NamedArgumentExpression Name={0} Expression={1}]", Name, Expression); + } + } + + public class NamespaceDeclaration : AbstractNode { + + string name; + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public NamespaceDeclaration(string name) { + Name = name; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitNamespaceDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[NamespaceDeclaration Name={0}]", Name); + } + } + + public class ObjectCreateExpression : Expression { + + TypeReference createType; + + List parameters; + + CollectionInitializerExpression objectInitializer; + + public TypeReference CreateType { + get { + return createType; + } + set { + createType = value ?? TypeReference.Null; + if (!createType.IsNull) createType.Parent = this; + } + } + + public List Parameters { + get { + return parameters; + } + set { + parameters = value ?? new List(); + } + } + + public CollectionInitializerExpression ObjectInitializer { + get { + return objectInitializer; + } + set { + objectInitializer = value ?? CollectionInitializerExpression.Null; + if (!objectInitializer.IsNull) objectInitializer.Parent = this; + } + } + + public ObjectCreateExpression(TypeReference createType, List parameters) { + CreateType = createType; + Parameters = parameters; + objectInitializer = CollectionInitializerExpression.Null; + } + + public bool IsAnonymousType { + get { + return createType.IsNull || string.IsNullOrEmpty(createType.Type); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitObjectCreateExpression(this, data); + } + + public override string ToString() { + return string.Format("[ObjectCreateExpression CreateType={0} Parameters={1} ObjectInitializer={2}]", CreateType, GetCollectionString(Parameters), ObjectInitializer); + } + } + + public class OnErrorStatement : StatementWithEmbeddedStatement { + + public OnErrorStatement(Statement embeddedStatement) { + EmbeddedStatement = embeddedStatement; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitOnErrorStatement(this, data); + } + + public override string ToString() { + return string.Format("[OnErrorStatement EmbeddedStatement={0}]", EmbeddedStatement); + } + } + + public class OperatorDeclaration : MethodDeclaration { + + ConversionType conversionType; + + OverloadableOperatorType overloadableOperator; + + public ConversionType ConversionType { + get { + return conversionType; + } + set { + conversionType = value; + } + } + + public OverloadableOperatorType OverloadableOperator { + get { + return overloadableOperator; + } + set { + overloadableOperator = value; + } + } + + public OperatorDeclaration() { + } + + public bool IsConversionOperator { + get { + return conversionType != ConversionType.None; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitOperatorDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[OperatorDeclaration ConversionType={0} OverloadableOperator={1} Body={2} Handles" + + "Clause={3} Templates={4} IsExtensionMethod={5} InterfaceImplementations={6} Type" + + "Reference={7} Name={8} Parameters={9} Attributes={10} Modifier={11}]", ConversionType, OverloadableOperator, Body, GetCollectionString(HandlesClause), GetCollectionString(Templates), IsExtensionMethod, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + public class OptionDeclaration : AbstractNode { + + OptionType optionType; + + bool optionValue; + + public OptionType OptionType { + get { + return optionType; + } + set { + optionType = value; + } + } + + public bool OptionValue { + get { + return optionValue; + } + set { + optionValue = value; + } + } + + public OptionDeclaration(OptionType optionType, bool optionValue) { + OptionType = optionType; + OptionValue = optionValue; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitOptionDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[OptionDeclaration OptionType={0} OptionValue={1}]", OptionType, OptionValue); + } + } + + public class ParameterDeclarationExpression : Expression { + + List attributes; + + string parameterName; + + TypeReference typeReference; + + ParameterModifiers paramModifier; + + Expression defaultValue; + + public List Attributes { + get { + return attributes; + } + set { + attributes = value ?? new List(); + } + } + + public string ParameterName { + get { + return parameterName; + } + set { + parameterName = string.IsNullOrEmpty(value) ? "?" : value; + } + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public ParameterModifiers ParamModifier { + get { + return paramModifier; + } + set { + paramModifier = value; + } + } + + public Expression DefaultValue { + get { + return defaultValue; + } + set { + defaultValue = value ?? Expression.Null; + if (!defaultValue.IsNull) defaultValue.Parent = this; + } + } + + public ParameterDeclarationExpression(TypeReference typeReference, string parameterName) { + TypeReference = typeReference; + ParameterName = parameterName; + attributes = new List(); + defaultValue = Expression.Null; + } + + public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParameterModifiers paramModifier) { + TypeReference = typeReference; + ParameterName = parameterName; + ParamModifier = paramModifier; + attributes = new List(); + defaultValue = Expression.Null; + } + + public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParameterModifiers paramModifier, Expression defaultValue) { + TypeReference = typeReference; + ParameterName = parameterName; + ParamModifier = paramModifier; + DefaultValue = defaultValue; + attributes = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitParameterDeclarationExpression(this, data); + } + + public override string ToString() { + return string.Format("[ParameterDeclarationExpression Attributes={0} ParameterName={1} TypeReference={2" + + "} ParamModifier={3} DefaultValue={4}]", GetCollectionString(Attributes), ParameterName, TypeReference, ParamModifier, DefaultValue); + } + } + + public abstract class ParametrizedNode : AttributedNode { + + string name; + + List parameters; + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public List Parameters { + get { + return parameters; + } + set { + parameters = value ?? new List(); + } + } + + protected ParametrizedNode() { + name = ""; + parameters = new List(); + } + + protected ParametrizedNode(Modifiers modifier, List attributes, string name, List parameters) { + Modifier = modifier; + Attributes = attributes; + Name = name; + Parameters = parameters; + } + } + + public class ParenthesizedExpression : Expression { + + Expression expression; + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public ParenthesizedExpression(Expression expression) { + Expression = expression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitParenthesizedExpression(this, data); + } + + public override string ToString() { + return string.Format("[ParenthesizedExpression Expression={0}]", Expression); + } + } + + public class PointerReferenceExpression : Expression { + + Expression targetObject; + + string memberName; + + List typeArguments; + + public Expression TargetObject { + get { + return targetObject; + } + set { + targetObject = value ?? Expression.Null; + if (!targetObject.IsNull) targetObject.Parent = this; + } + } + + public string MemberName { + get { + return memberName; + } + set { + memberName = value ?? ""; + } + } + + public List TypeArguments { + get { + return typeArguments; + } + set { + typeArguments = value ?? new List(); + } + } + + public PointerReferenceExpression(Expression targetObject, string memberName) { + TargetObject = targetObject; + MemberName = memberName; + typeArguments = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitPointerReferenceExpression(this, data); + } + + public override string ToString() { + return string.Format("[PointerReferenceExpression TargetObject={0} MemberName={1} TypeArguments={2}]", TargetObject, MemberName, GetCollectionString(TypeArguments)); + } + } + + public class PropertyDeclaration : MemberNode { + + Location bodyStart; + + Location bodyEnd; + + PropertyGetRegion getRegion; + + PropertySetRegion setRegion; + + Expression initializer; + + public Location BodyStart { + get { + return bodyStart; + } + set { + bodyStart = value; + } + } + + public Location BodyEnd { + get { + return bodyEnd; + } + set { + bodyEnd = value; + } + } + + public PropertyGetRegion GetRegion { + get { + return getRegion; + } + set { + getRegion = value ?? PropertyGetRegion.Null; + if (!getRegion.IsNull) getRegion.Parent = this; + } + } + + public PropertySetRegion SetRegion { + get { + return setRegion; + } + set { + setRegion = value ?? PropertySetRegion.Null; + if (!setRegion.IsNull) setRegion.Parent = this; + } + } + + public Expression Initializer { + get { + return initializer; + } + set { + initializer = value ?? Expression.Null; + if (!initializer.IsNull) initializer.Parent = this; + } + } + + public PropertyDeclaration(Modifiers modifier, List attributes, string name, List parameters) { + Modifier = modifier; + Attributes = attributes; + Name = name; + Parameters = parameters; + bodyStart = Location.Empty; + bodyEnd = Location.Empty; + getRegion = PropertyGetRegion.Null; + setRegion = PropertySetRegion.Null; + initializer = Expression.Null; + } + + public bool HasGetRegion { + get { + return !getRegion.IsNull; + } + } + + public bool IsReadOnly { + get { + return HasGetRegion && !HasSetRegion; + } + } + + public bool IsWriteOnly { + get { + return !HasGetRegion && HasSetRegion; + } + } + + public bool IsIndexer { + get { + return (Modifier & Modifiers.Default) != 0; + } + } + + public bool HasSetRegion { + get { + return !setRegion.IsNull; + } + } + + + internal PropertyDeclaration(string name, TypeReference typeReference, Modifiers modifier, List attributes) : this(modifier, attributes, name, null) + { + this.TypeReference = typeReference; + if ((modifier & Modifiers.ReadOnly) != Modifiers.ReadOnly) { + this.SetRegion = new PropertySetRegion(null, null); + } + if ((modifier & Modifiers.WriteOnly) != Modifiers.WriteOnly) { + this.GetRegion = new PropertyGetRegion(null, null); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitPropertyDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[PropertyDeclaration BodyStart={0} BodyEnd={1} GetRegion={2} SetRegion={3} Initia" + + "lizer={4} InterfaceImplementations={5} TypeReference={6} Name={7} Parameters={8}" + + " Attributes={9} Modifier={10}]", BodyStart, BodyEnd, GetRegion, SetRegion, Initializer, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + public class PropertyGetRegion : PropertyGetSetRegion { + + public PropertyGetRegion(BlockStatement block, List attributes) : + base(block, attributes) { + } + + public static PropertyGetRegion Null { + get { + return NullPropertyGetRegion.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitPropertyGetRegion(this, data); + } + + public override string ToString() { + return string.Format("[PropertyGetRegion Block={0} Attributes={1} Modifier={2}]", Block, GetCollectionString(Attributes), Modifier); + } + } + + internal sealed class NullPropertyGetRegion : PropertyGetRegion { + + private NullPropertyGetRegion() : + base(null, null) { + } + + internal static NullPropertyGetRegion Instance = new NullPropertyGetRegion(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullPropertyGetRegion]"; + } + } + + public abstract class PropertyGetSetRegion : AttributedNode, INullable { + + BlockStatement block; + + public BlockStatement Block { + get { + return block; + } + set { + block = value ?? BlockStatement.Null; + if (!block.IsNull) block.Parent = this; + } + } + + protected PropertyGetSetRegion(BlockStatement block, List attributes) { + Block = block; + Attributes = attributes; + } + + public virtual bool IsNull { + get { + return false; + } + } + } + + public class PropertySetRegion : PropertyGetSetRegion { + + List parameters; + + public List Parameters { + get { + return parameters; + } + set { + parameters = value ?? new List(); + } + } + + public PropertySetRegion(BlockStatement block, List attributes) : + base(block, attributes) { + parameters = new List(); + } + + public static PropertySetRegion Null { + get { + return NullPropertySetRegion.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitPropertySetRegion(this, data); + } + + public override string ToString() { + return string.Format("[PropertySetRegion Parameters={0} Block={1} Attributes={2} Modifier={3}]", GetCollectionString(Parameters), Block, GetCollectionString(Attributes), Modifier); + } + } + + internal sealed class NullPropertySetRegion : PropertySetRegion { + + private NullPropertySetRegion() : + base(null, null) { + } + + internal static NullPropertySetRegion Instance = new NullPropertySetRegion(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullPropertySetRegion]"; + } + } + + public class QueryExpression : Expression { + + QueryExpressionFromClause fromClause; + + bool isQueryContinuation; + + List middleClauses; + + QueryExpressionClause selectOrGroupClause; + + public QueryExpressionFromClause FromClause { + get { + return fromClause; + } + set { + fromClause = value ?? QueryExpressionFromClause.Null; + if (!fromClause.IsNull) fromClause.Parent = this; + } + } + + public bool IsQueryContinuation { + get { + return isQueryContinuation; + } + set { + isQueryContinuation = value; + } + } + + public List MiddleClauses { + get { + return middleClauses; + } + set { + middleClauses = value ?? new List(); + } + } + + public QueryExpressionClause SelectOrGroupClause { + get { + return selectOrGroupClause; + } + set { + selectOrGroupClause = value ?? QueryExpressionClause.Null; + if (!selectOrGroupClause.IsNull) selectOrGroupClause.Parent = this; + } + } + + public QueryExpression() { + fromClause = QueryExpressionFromClause.Null; + middleClauses = new List(); + selectOrGroupClause = QueryExpressionClause.Null; + } + + public new static QueryExpression Null { + get { + return NullQueryExpression.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpression(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpression FromClause={0} IsQueryContinuation={1} MiddleClauses={2} SelectO" + + "rGroupClause={3}]", FromClause, IsQueryContinuation, GetCollectionString(MiddleClauses), SelectOrGroupClause); + } + } + + internal sealed class NullQueryExpression : QueryExpression { + + internal static NullQueryExpression Instance = new NullQueryExpression(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullQueryExpression]"; + } + } + + public class QueryExpressionAggregateClause : QueryExpressionClause { + + CollectionRangeVariable source; + + List middleClauses; + + List intoVariables; + + public CollectionRangeVariable Source { + get { + return source; + } + set { + source = value ?? CollectionRangeVariable.Null; + if (!source.IsNull) source.Parent = this; + } + } + + public List MiddleClauses { + get { + return middleClauses; + } + set { + middleClauses = value ?? new List(); + } + } + + public List IntoVariables { + get { + return intoVariables; + } + set { + intoVariables = value ?? new List(); + } + } + + public QueryExpressionAggregateClause() { + source = CollectionRangeVariable.Null; + middleClauses = new List(); + intoVariables = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionAggregateClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionAggregateClause Source={0} MiddleClauses={1} IntoVariables={2}]", Source, GetCollectionString(MiddleClauses), GetCollectionString(IntoVariables)); + } + } + + public abstract class QueryExpressionClause : AbstractNode, INullable { + + protected QueryExpressionClause() { + } + + public virtual bool IsNull { + get { + return false; + } + } + + public static QueryExpressionClause Null { + get { + return NullQueryExpressionClause.Instance; + } + } + } + + internal sealed class NullQueryExpressionClause : QueryExpressionClause { + + internal static NullQueryExpressionClause Instance = new NullQueryExpressionClause(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullQueryExpressionClause]"; + } + } + + public class QueryExpressionDistinctClause : QueryExpressionClause { + + public QueryExpressionDistinctClause() { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionDistinctClause(this, data); + } + + public override string ToString() { + return "[QueryExpressionDistinctClause]"; + } + } + + public class QueryExpressionFromClause : QueryExpressionClause { + + List sources; + + public List Sources { + get { + return sources; + } + set { + sources = value ?? new List(); + } + } + + public QueryExpressionFromClause() { + sources = new List(); + } + + public new static QueryExpressionFromClause Null { + get { + return NullQueryExpressionFromClause.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionFromClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionFromClause Sources={0}]", GetCollectionString(Sources)); + } + } + + internal sealed class NullQueryExpressionFromClause : QueryExpressionFromClause { + + internal static NullQueryExpressionFromClause Instance = new NullQueryExpressionFromClause(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullQueryExpressionFromClause]"; + } + } + + public class QueryExpressionGroupClause : QueryExpressionClause { + + Expression projection; + + Expression groupBy; + + public Expression Projection { + get { + return projection; + } + set { + projection = value ?? Expression.Null; + if (!projection.IsNull) projection.Parent = this; + } + } + + public Expression GroupBy { + get { + return groupBy; + } + set { + groupBy = value ?? Expression.Null; + if (!groupBy.IsNull) groupBy.Parent = this; + } + } + + public QueryExpressionGroupClause() { + projection = Expression.Null; + groupBy = Expression.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionGroupClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionGroupClause Projection={0} GroupBy={1}]", Projection, GroupBy); + } + } + + public class QueryExpressionGroupJoinVBClause : QueryExpressionClause { + + QueryExpressionJoinVBClause joinClause; + + List intoVariables; + + public QueryExpressionJoinVBClause JoinClause { + get { + return joinClause; + } + set { + joinClause = value ?? QueryExpressionJoinVBClause.Null; + if (!joinClause.IsNull) joinClause.Parent = this; + } + } + + public List IntoVariables { + get { + return intoVariables; + } + set { + intoVariables = value ?? new List(); + } + } + + public QueryExpressionGroupJoinVBClause() { + joinClause = QueryExpressionJoinVBClause.Null; + intoVariables = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionGroupJoinVBClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionGroupJoinVBClause JoinClause={0} IntoVariables={1}]", JoinClause, GetCollectionString(IntoVariables)); + } + } + + public class QueryExpressionGroupVBClause : QueryExpressionClause { + + List groupVariables; + + List byVariables; + + List intoVariables; + + public List GroupVariables { + get { + return groupVariables; + } + set { + groupVariables = value ?? new List(); + } + } + + public List ByVariables { + get { + return byVariables; + } + set { + byVariables = value ?? new List(); + } + } + + public List IntoVariables { + get { + return intoVariables; + } + set { + intoVariables = value ?? new List(); + } + } + + public QueryExpressionGroupVBClause() { + groupVariables = new List(); + byVariables = new List(); + intoVariables = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionGroupVBClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionGroupVBClause GroupVariables={0} ByVariables={1} IntoVariables={2" + + "}]", GetCollectionString(GroupVariables), GetCollectionString(ByVariables), GetCollectionString(IntoVariables)); + } + } + + public class QueryExpressionJoinClause : QueryExpressionClause { + + Expression onExpression; + + Expression equalsExpression; + + CollectionRangeVariable source; + + string intoIdentifier; + + public Expression OnExpression { + get { + return onExpression; + } + set { + onExpression = value ?? Expression.Null; + if (!onExpression.IsNull) onExpression.Parent = this; + } + } + + public Expression EqualsExpression { + get { + return equalsExpression; + } + set { + equalsExpression = value ?? Expression.Null; + if (!equalsExpression.IsNull) equalsExpression.Parent = this; + } + } + + public CollectionRangeVariable Source { + get { + return source; + } + set { + source = value ?? CollectionRangeVariable.Null; + if (!source.IsNull) source.Parent = this; + } + } + + public string IntoIdentifier { + get { + return intoIdentifier; + } + set { + intoIdentifier = value ?? ""; + } + } + + public QueryExpressionJoinClause() { + onExpression = Expression.Null; + equalsExpression = Expression.Null; + source = CollectionRangeVariable.Null; + intoIdentifier = ""; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionJoinClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionJoinClause OnExpression={0} EqualsExpression={1} Source={2} IntoI" + + "dentifier={3}]", OnExpression, EqualsExpression, Source, IntoIdentifier); + } + } + + public class QueryExpressionJoinConditionVB : AbstractNode { + + Expression leftSide; + + Expression rightSide; + + public Expression LeftSide { + get { + return leftSide; + } + set { + leftSide = value ?? Expression.Null; + if (!leftSide.IsNull) leftSide.Parent = this; + } + } + + public Expression RightSide { + get { + return rightSide; + } + set { + rightSide = value ?? Expression.Null; + if (!rightSide.IsNull) rightSide.Parent = this; + } + } + + public QueryExpressionJoinConditionVB() { + leftSide = Expression.Null; + rightSide = Expression.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionJoinConditionVB(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionJoinConditionVB LeftSide={0} RightSide={1}]", LeftSide, RightSide); + } + } + + public class QueryExpressionJoinVBClause : QueryExpressionClause { + + CollectionRangeVariable joinVariable; + + QueryExpressionJoinVBClause subJoin; + + List conditions; + + public CollectionRangeVariable JoinVariable { + get { + return joinVariable; + } + set { + joinVariable = value ?? CollectionRangeVariable.Null; + if (!joinVariable.IsNull) joinVariable.Parent = this; + } + } + + public QueryExpressionJoinVBClause SubJoin { + get { + return subJoin; + } + set { + subJoin = value ?? QueryExpressionJoinVBClause.Null; + if (!subJoin.IsNull) subJoin.Parent = this; + } + } + + public List Conditions { + get { + return conditions; + } + set { + conditions = value ?? new List(); + } + } + + public QueryExpressionJoinVBClause() { + joinVariable = CollectionRangeVariable.Null; + subJoin = QueryExpressionJoinVBClause.Null; + conditions = new List(); + } + + public new static QueryExpressionJoinVBClause Null { + get { + return NullQueryExpressionJoinVBClause.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionJoinVBClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionJoinVBClause JoinVariable={0} SubJoin={1} Conditions={2}]", JoinVariable, SubJoin, GetCollectionString(Conditions)); + } + } + + internal sealed class NullQueryExpressionJoinVBClause : QueryExpressionJoinVBClause { + + internal static NullQueryExpressionJoinVBClause Instance = new NullQueryExpressionJoinVBClause(); + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullQueryExpressionJoinVBClause]"; + } + } + + public class QueryExpressionLetClause : QueryExpressionClause { + + string identifier; + + Expression expression; + + public string Identifier { + get { + return identifier; + } + set { + identifier = string.IsNullOrEmpty(value) ? "?" : value; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public QueryExpressionLetClause() { + identifier = "?"; + expression = Expression.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionLetClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionLetClause Identifier={0} Expression={1}]", Identifier, Expression); + } + } + + public class QueryExpressionLetVBClause : QueryExpressionClause { + + List variables; + + public List Variables { + get { + return variables; + } + set { + variables = value ?? new List(); + } + } + + public QueryExpressionLetVBClause() { + variables = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionLetVBClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionLetVBClause Variables={0}]", GetCollectionString(Variables)); + } + } + + public class QueryExpressionOrderClause : QueryExpressionClause { + + List orderings; + + public List Orderings { + get { + return orderings; + } + set { + orderings = value ?? new List(); + } + } + + public QueryExpressionOrderClause() { + orderings = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionOrderClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionOrderClause Orderings={0}]", GetCollectionString(Orderings)); + } + } + + public class QueryExpressionOrdering : AbstractNode { + + Expression criteria; + + QueryExpressionOrderingDirection direction; + + public Expression Criteria { + get { + return criteria; + } + set { + criteria = value ?? Expression.Null; + if (!criteria.IsNull) criteria.Parent = this; + } + } + + public QueryExpressionOrderingDirection Direction { + get { + return direction; + } + set { + direction = value; + } + } + + public QueryExpressionOrdering() { + criteria = Expression.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionOrdering(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionOrdering Criteria={0} Direction={1}]", Criteria, Direction); + } + } + + public class QueryExpressionPartitionVBClause : QueryExpressionClause { + + Expression expression; + + QueryExpressionPartitionType partitionType; + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public QueryExpressionPartitionType PartitionType { + get { + return partitionType; + } + set { + partitionType = value; + } + } + + public QueryExpressionPartitionVBClause() { + expression = Expression.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionPartitionVBClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionPartitionVBClause Expression={0} PartitionType={1}]", Expression, PartitionType); + } + } + + public class QueryExpressionSelectClause : QueryExpressionClause { + + Expression projection; + + public Expression Projection { + get { + return projection; + } + set { + projection = value ?? Expression.Null; + if (!projection.IsNull) projection.Parent = this; + } + } + + public QueryExpressionSelectClause() { + projection = Expression.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionSelectClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionSelectClause Projection={0}]", Projection); + } + } + + public class QueryExpressionSelectVBClause : QueryExpressionClause { + + List variables; + + public List Variables { + get { + return variables; + } + set { + variables = value ?? new List(); + } + } + + public QueryExpressionSelectVBClause() { + variables = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionSelectVBClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionSelectVBClause Variables={0}]", GetCollectionString(Variables)); + } + } + + public class QueryExpressionVB : Expression { + + List clauses; + + public List Clauses { + get { + return clauses; + } + set { + clauses = value ?? new List(); + } + } + + public QueryExpressionVB() { + clauses = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionVB(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionVB Clauses={0}]", GetCollectionString(Clauses)); + } + } + + public class QueryExpressionWhereClause : QueryExpressionClause { + + Expression condition; + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + if (!condition.IsNull) condition.Parent = this; + } + } + + public QueryExpressionWhereClause() { + condition = Expression.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitQueryExpressionWhereClause(this, data); + } + + public override string ToString() { + return string.Format("[QueryExpressionWhereClause Condition={0}]", Condition); + } + } + + public class RaiseEventStatement : Statement { + + string eventName; + + List arguments; + + public string EventName { + get { + return eventName; + } + set { + eventName = value ?? ""; + } + } + + public List Arguments { + get { + return arguments; + } + set { + arguments = value ?? new List(); + } + } + + public RaiseEventStatement(string eventName, List arguments) { + EventName = eventName; + Arguments = arguments; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitRaiseEventStatement(this, data); + } + + public override string ToString() { + return string.Format("[RaiseEventStatement EventName={0} Arguments={1}]", EventName, GetCollectionString(Arguments)); + } + } + + public class ReDimStatement : Statement { + + List reDimClauses; + + bool isPreserve; + + public List ReDimClauses { + get { + return reDimClauses; + } + set { + reDimClauses = value ?? new List(); + } + } + + public bool IsPreserve { + get { + return isPreserve; + } + set { + isPreserve = value; + } + } + + public ReDimStatement(bool isPreserve) { + IsPreserve = isPreserve; + reDimClauses = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitReDimStatement(this, data); + } + + public override string ToString() { + return string.Format("[ReDimStatement ReDimClauses={0} IsPreserve={1}]", GetCollectionString(ReDimClauses), IsPreserve); + } + } + + public class RemoveHandlerStatement : Statement { + + Expression eventExpression; + + Expression handlerExpression; + + public Expression EventExpression { + get { + return eventExpression; + } + set { + eventExpression = value ?? Expression.Null; + if (!eventExpression.IsNull) eventExpression.Parent = this; + } + } + + public Expression HandlerExpression { + get { + return handlerExpression; + } + set { + handlerExpression = value ?? Expression.Null; + if (!handlerExpression.IsNull) handlerExpression.Parent = this; + } + } + + public RemoveHandlerStatement(Expression eventExpression, Expression handlerExpression) { + EventExpression = eventExpression; + HandlerExpression = handlerExpression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitRemoveHandlerStatement(this, data); + } + + public override string ToString() { + return string.Format("[RemoveHandlerStatement EventExpression={0} HandlerExpression={1}]", EventExpression, HandlerExpression); + } + } + + public class ResumeStatement : Statement { + + string labelName; + + bool isResumeNext; + + public string LabelName { + get { + return labelName; + } + set { + labelName = value ?? ""; + } + } + + public bool IsResumeNext { + get { + return isResumeNext; + } + set { + isResumeNext = value; + } + } + + public ResumeStatement(bool isResumeNext) { + IsResumeNext = isResumeNext; + labelName = ""; + } + + public ResumeStatement(string labelName) { + LabelName = labelName; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitResumeStatement(this, data); + } + + public override string ToString() { + return string.Format("[ResumeStatement LabelName={0} IsResumeNext={1}]", LabelName, IsResumeNext); + } + } + + public class ReturnStatement : Statement { + + Expression expression; + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public ReturnStatement(Expression expression) { + Expression = expression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitReturnStatement(this, data); + } + + public override string ToString() { + return string.Format("[ReturnStatement Expression={0}]", Expression); + } + } + + public class SizeOfExpression : Expression { + + TypeReference typeReference; + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public SizeOfExpression(TypeReference typeReference) { + TypeReference = typeReference; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitSizeOfExpression(this, data); + } + + public override string ToString() { + return string.Format("[SizeOfExpression TypeReference={0}]", TypeReference); + } + } + + public class StackAllocExpression : Expression { + + TypeReference typeReference; + + Expression expression; + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public StackAllocExpression(TypeReference typeReference, Expression expression) { + TypeReference = typeReference; + Expression = expression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitStackAllocExpression(this, data); + } + + public override string ToString() { + return string.Format("[StackAllocExpression TypeReference={0} Expression={1}]", TypeReference, Expression); + } + } + + public class StopStatement : Statement { + + public StopStatement() { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitStopStatement(this, data); + } + + public override string ToString() { + return "[StopStatement]"; + } + } + + public class SwitchSection : BlockStatement { + + List switchLabels; + + public List SwitchLabels { + get { + return switchLabels; + } + set { + switchLabels = value ?? new List(); + } + } + + public SwitchSection() { + switchLabels = new List(); + } + + public SwitchSection(List switchLabels) { + SwitchLabels = switchLabels; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitSwitchSection(this, data); + } + + public override string ToString() { + return string.Format("[SwitchSection SwitchLabels={0}]", GetCollectionString(SwitchLabels)); + } + } + + public class SwitchStatement : Statement { + + Expression switchExpression; + + List switchSections; + + public Expression SwitchExpression { + get { + return switchExpression; + } + set { + switchExpression = value ?? Expression.Null; + if (!switchExpression.IsNull) switchExpression.Parent = this; + } + } + + public List SwitchSections { + get { + return switchSections; + } + set { + switchSections = value ?? new List(); + } + } + + public SwitchStatement(Expression switchExpression, List switchSections) { + SwitchExpression = switchExpression; + SwitchSections = switchSections; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitSwitchStatement(this, data); + } + + public override string ToString() { + return string.Format("[SwitchStatement SwitchExpression={0} SwitchSections={1}]", SwitchExpression, GetCollectionString(SwitchSections)); + } + } + + public class TemplateDefinition : AttributedNode { + + string name; + + VarianceModifier varianceModifier; + + List bases; + + public string Name { + get { + return name; + } + set { + name = string.IsNullOrEmpty(value) ? "?" : value; + } + } + + public VarianceModifier VarianceModifier { + get { + return varianceModifier; + } + set { + varianceModifier = value; + } + } + + public List Bases { + get { + return bases; + } + set { + bases = value ?? new List(); + } + } + + public TemplateDefinition() { + name = "?"; + bases = new List(); + } + + public TemplateDefinition(string name, List attributes) { + Name = name; + Attributes = attributes; + bases = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitTemplateDefinition(this, data); + } + + public override string ToString() { + return string.Format("[TemplateDefinition Name={0} VarianceModifier={1} Bases={2} Attributes={3} Modifi" + + "er={4}]", Name, VarianceModifier, GetCollectionString(Bases), GetCollectionString(Attributes), Modifier); + } + } + + public class ThisReferenceExpression : Expression { + + public ThisReferenceExpression() { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitThisReferenceExpression(this, data); + } + + public override string ToString() { + return "[ThisReferenceExpression]"; + } + } + + public class ThrowStatement : Statement { + + Expression expression; + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public ThrowStatement(Expression expression) { + Expression = expression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitThrowStatement(this, data); + } + + public override string ToString() { + return string.Format("[ThrowStatement Expression={0}]", Expression); + } + } + + public class TryCatchStatement : Statement { + + Statement statementBlock; + + List catchClauses; + + Statement finallyBlock; + + public Statement StatementBlock { + get { + return statementBlock; + } + set { + statementBlock = value ?? Statement.Null; + if (!statementBlock.IsNull) statementBlock.Parent = this; + } + } + + public List CatchClauses { + get { + return catchClauses; + } + set { + catchClauses = value ?? new List(); + } + } + + public Statement FinallyBlock { + get { + return finallyBlock; + } + set { + finallyBlock = value ?? Statement.Null; + if (!finallyBlock.IsNull) finallyBlock.Parent = this; + } + } + + public TryCatchStatement(Statement statementBlock, List catchClauses, Statement finallyBlock) { + StatementBlock = statementBlock; + CatchClauses = catchClauses; + FinallyBlock = finallyBlock; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitTryCatchStatement(this, data); + } + + public override string ToString() { + return string.Format("[TryCatchStatement StatementBlock={0} CatchClauses={1} FinallyBlock={2}]", StatementBlock, GetCollectionString(CatchClauses), FinallyBlock); + } + } + + public class TypeDeclaration : AttributedNode { + + string name; + + ClassType type; + + List baseTypes; + + List templates; + + Location bodyStartLocation; + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public ClassType Type { + get { + return type; + } + set { + type = value; + } + } + + public List BaseTypes { + get { + return baseTypes; + } + set { + baseTypes = value ?? new List(); + } + } + + public List Templates { + get { + return templates; + } + set { + templates = value ?? new List(); + } + } + + public Location BodyStartLocation { + get { + return bodyStartLocation; + } + set { + bodyStartLocation = value; + } + } + + public TypeDeclaration(Modifiers modifier, List attributes) { + Modifier = modifier; + Attributes = attributes; + name = ""; + baseTypes = new List(); + templates = new List(); + bodyStartLocation = Location.Empty; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitTypeDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[TypeDeclaration Name={0} Type={1} BaseTypes={2} Templates={3} BodyStartLocation=" + + "{4} Attributes={5} Modifier={6}]", Name, Type, GetCollectionString(BaseTypes), GetCollectionString(Templates), BodyStartLocation, GetCollectionString(Attributes), Modifier); + } + } + + public class TypeOfExpression : Expression { + + TypeReference typeReference; + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public TypeOfExpression(TypeReference typeReference) { + TypeReference = typeReference; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitTypeOfExpression(this, data); + } + + public override string ToString() { + return string.Format("[TypeOfExpression TypeReference={0}]", TypeReference); + } + } + + public class TypeOfIsExpression : Expression { + + Expression expression; + + TypeReference typeReference; + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public TypeOfIsExpression(Expression expression, TypeReference typeReference) { + Expression = expression; + TypeReference = typeReference; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitTypeOfIsExpression(this, data); + } + + public override string ToString() { + return string.Format("[TypeOfIsExpression Expression={0} TypeReference={1}]", Expression, TypeReference); + } + } + + public class TypeReferenceExpression : Expression { + + TypeReference typeReference; + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public TypeReferenceExpression(TypeReference typeReference) { + TypeReference = typeReference; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitTypeReferenceExpression(this, data); + } + + public override string ToString() { + return string.Format("[TypeReferenceExpression TypeReference={0}]", TypeReference); + } + } + + public class UnaryOperatorExpression : Expression { + + UnaryOperatorType op; + + Expression expression; + + public UnaryOperatorType Op { + get { + return op; + } + set { + op = value; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public UnaryOperatorExpression(UnaryOperatorType op) { + Op = op; + expression = Expression.Null; + } + + public UnaryOperatorExpression(Expression expression, UnaryOperatorType op) { + Expression = expression; + Op = op; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitUnaryOperatorExpression(this, data); + } + + public override string ToString() { + return string.Format("[UnaryOperatorExpression Op={0} Expression={1}]", Op, Expression); + } + } + + public class UncheckedExpression : Expression { + + Expression expression; + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public UncheckedExpression(Expression expression) { + Expression = expression; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitUncheckedExpression(this, data); + } + + public override string ToString() { + return string.Format("[UncheckedExpression Expression={0}]", Expression); + } + } + + public class UncheckedStatement : Statement { + + Statement block; + + public Statement Block { + get { + return block; + } + set { + block = value ?? Statement.Null; + if (!block.IsNull) block.Parent = this; + } + } + + public UncheckedStatement(Statement block) { + Block = block; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitUncheckedStatement(this, data); + } + + public override string ToString() { + return string.Format("[UncheckedStatement Block={0}]", Block); + } + } + + public class UnsafeStatement : Statement { + + Statement block; + + public Statement Block { + get { + return block; + } + set { + block = value ?? Statement.Null; + if (!block.IsNull) block.Parent = this; + } + } + + public UnsafeStatement(Statement block) { + Block = block; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitUnsafeStatement(this, data); + } + + public override string ToString() { + return string.Format("[UnsafeStatement Block={0}]", Block); + } + } + + public class Using : AbstractNode { + + string name; + + TypeReference alias; + + string xmlPrefix; + + public string Name { + get { + return name; + } + set { + name = string.IsNullOrEmpty(value) ? "?" : value; + } + } + + public TypeReference Alias { + get { + return alias; + } + set { + alias = value ?? TypeReference.Null; + if (!alias.IsNull) alias.Parent = this; + } + } + + public string XmlPrefix { + get { + return xmlPrefix; + } + set { + xmlPrefix = value ?? ""; + } + } + + public Using(string name) { + Name = name; + alias = TypeReference.Null; + xmlPrefix = ""; + } + + public Using(string name, TypeReference alias) { + Name = name; + Alias = alias; + xmlPrefix = ""; + } + + public Using(string name, string xmlPrefix) { + Name = name; + XmlPrefix = xmlPrefix; + alias = TypeReference.Null; + } + + public bool IsXml { + get { + return xmlPrefix != null; + } + } + + public bool IsAlias { + get { + return !alias.IsNull; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitUsing(this, data); + } + + public override string ToString() { + return string.Format("[Using Name={0} Alias={1} XmlPrefix={2}]", Name, Alias, XmlPrefix); + } + } + + public class UsingDeclaration : AbstractNode { + + List usings; + + public List Usings { + get { + return usings; + } + set { + usings = value ?? new List(); + } + } + + public UsingDeclaration(List usings) { + Usings = usings; + } + +public UsingDeclaration(string @namespace) : this(@namespace, TypeReference.Null) {} + +public UsingDeclaration(string xmlNamespace, string prefix) { usings = new List(1); usings.Add(new Using(xmlNamespace, prefix)); } + +public UsingDeclaration(string @namespace, TypeReference alias) { usings = new List(1); usings.Add(new Using(@namespace, alias)); } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitUsingDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[UsingDeclaration Usings={0}]", GetCollectionString(Usings)); + } + } + + public class UsingStatement : StatementWithEmbeddedStatement { + + Statement resourceAcquisition; + + public Statement ResourceAcquisition { + get { + return resourceAcquisition; + } + set { + resourceAcquisition = value ?? Statement.Null; + if (!resourceAcquisition.IsNull) resourceAcquisition.Parent = this; + } + } + + public UsingStatement(Statement resourceAcquisition, Statement embeddedStatement) { + ResourceAcquisition = resourceAcquisition; + EmbeddedStatement = embeddedStatement; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitUsingStatement(this, data); + } + + public override string ToString() { + return string.Format("[UsingStatement ResourceAcquisition={0} EmbeddedStatement={1}]", ResourceAcquisition, EmbeddedStatement); + } + } + + public class VariableDeclaration : AbstractNode { + + string name; + + Expression initializer; + + TypeReference typeReference; + + Expression fixedArrayInitialization; + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public Expression Initializer { + get { + return initializer; + } + set { + initializer = value ?? Expression.Null; + if (!initializer.IsNull) initializer.Parent = this; + } + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; + } + } + + public Expression FixedArrayInitialization { + get { + return fixedArrayInitialization; + } + set { + fixedArrayInitialization = value ?? Expression.Null; + if (!fixedArrayInitialization.IsNull) fixedArrayInitialization.Parent = this; + } + } + + public VariableDeclaration(string name) { + Name = name; + initializer = Expression.Null; + typeReference = TypeReference.Null; + fixedArrayInitialization = Expression.Null; + } + + public VariableDeclaration(string name, Expression initializer) { + Name = name; + Initializer = initializer; + typeReference = TypeReference.Null; + fixedArrayInitialization = Expression.Null; + } + + public VariableDeclaration(string name, Expression initializer, TypeReference typeReference) { + Name = name; + Initializer = initializer; + TypeReference = typeReference; + fixedArrayInitialization = Expression.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitVariableDeclaration(this, data); + } + + public override string ToString() { + return string.Format("[VariableDeclaration Name={0} Initializer={1} TypeReference={2} FixedArrayInitial" + + "ization={3}]", Name, Initializer, TypeReference, FixedArrayInitialization); + } + } + + public class WithStatement : Statement { + + Expression expression; + + BlockStatement body; + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + if (!expression.IsNull) expression.Parent = this; + } + } + + public BlockStatement Body { + get { + return body; + } + set { + body = value ?? BlockStatement.Null; + if (!body.IsNull) body.Parent = this; + } + } + + public WithStatement(Expression expression) { + Expression = expression; + body = BlockStatement.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitWithStatement(this, data); + } + + public override string ToString() { + return string.Format("[WithStatement Expression={0} Body={1}]", Expression, Body); + } + } + + public class XmlAttributeExpression : XmlExpression { + + string name; + + string literalValue; + + bool useDoubleQuotes; + + Expression expressionValue; + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public string LiteralValue { + get { + return literalValue; + } + set { + literalValue = value ?? ""; + } + } + + public bool UseDoubleQuotes { + get { + return useDoubleQuotes; + } + set { + useDoubleQuotes = value; + } + } + + public Expression ExpressionValue { + get { + return expressionValue; + } + set { + expressionValue = value ?? Expression.Null; + if (!expressionValue.IsNull) expressionValue.Parent = this; + } + } + + public XmlAttributeExpression() { + name = ""; + literalValue = ""; + expressionValue = Expression.Null; + } + + public bool IsLiteralValue { + get { + return expressionValue.IsNull; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitXmlAttributeExpression(this, data); + } + + public override string ToString() { + return string.Format("[XmlAttributeExpression Name={0} LiteralValue={1} UseDoubleQuotes={2} ExpressionV" + + "alue={3}]", Name, LiteralValue, UseDoubleQuotes, ExpressionValue); + } + } + + public class XmlContentExpression : XmlExpression { + + string content; + + XmlContentType type; + + public string Content { + get { + return content; + } + set { + content = value ?? ""; + } + } + + public XmlContentType Type { + get { + return type; + } + set { + type = value; + } + } + + public XmlContentExpression(string content, XmlContentType type) { + Content = content; + Type = type; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitXmlContentExpression(this, data); + } + + public override string ToString() { + return string.Format("[XmlContentExpression Content={0} Type={1}]", Content, Type); + } + } + + public class XmlDocumentExpression : XmlExpression { + + List expressions; + + public List Expressions { + get { + return expressions; + } + set { + expressions = value ?? new List(); + } + } + + public XmlDocumentExpression() { + expressions = new List(); + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitXmlDocumentExpression(this, data); + } + + public override string ToString() { + return string.Format("[XmlDocumentExpression Expressions={0}]", GetCollectionString(Expressions)); + } + } + + public class XmlElementExpression : XmlExpression { + + Expression content; + + Expression nameExpression; + + string xmlName; + + List attributes; + + public Expression Content { + get { + return content; + } + set { + content = value ?? Expression.Null; + if (!content.IsNull) content.Parent = this; + } + } + + public Expression NameExpression { + get { + return nameExpression; + } + set { + nameExpression = value ?? Expression.Null; + if (!nameExpression.IsNull) nameExpression.Parent = this; + } + } + + public string XmlName { + get { + return xmlName; + } + set { + xmlName = value ?? ""; + } + } + + public List Attributes { + get { + return attributes; + } + set { + attributes = value ?? new List(); + } + } + + public XmlElementExpression() { + content = Expression.Null; + nameExpression = Expression.Null; + xmlName = ""; + attributes = new List(); + } + + public bool NameIsExpression { + get { + return !nameExpression.IsNull; + } + } + + public bool IsExpression { + get { + return !content.IsNull; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitXmlElementExpression(this, data); + } + + public override string ToString() { + return string.Format("[XmlElementExpression Content={0} NameExpression={1} XmlName={2} Attributes={3}]", Content, NameExpression, XmlName, GetCollectionString(Attributes)); + } + } + + public class XmlEmbeddedExpression : XmlExpression { + + Expression inlineVBExpression; + + public Expression InlineVBExpression { + get { + return inlineVBExpression; + } + set { + inlineVBExpression = value ?? Expression.Null; + if (!inlineVBExpression.IsNull) inlineVBExpression.Parent = this; + } + } + + public XmlEmbeddedExpression() { + inlineVBExpression = Expression.Null; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitXmlEmbeddedExpression(this, data); + } + + public override string ToString() { + return string.Format("[XmlEmbeddedExpression InlineVBExpression={0}]", InlineVBExpression); + } + } + + public abstract class XmlExpression : Expression { + + protected XmlExpression() { + } + } + + public class XmlMemberAccessExpression : Expression { + + Expression targetObject; + + XmlAxisType axisType; + + bool isXmlIdentifier; + + string identifier; + + public Expression TargetObject { + get { + return targetObject; + } + set { + targetObject = value ?? Expression.Null; + if (!targetObject.IsNull) targetObject.Parent = this; + } + } + + public XmlAxisType AxisType { + get { + return axisType; + } + set { + axisType = value; + } + } + + public bool IsXmlIdentifier { + get { + return isXmlIdentifier; + } + set { + isXmlIdentifier = value; + } + } + + public string Identifier { + get { + return identifier; + } + set { + identifier = value ?? ""; + } + } + + public XmlMemberAccessExpression(Expression targetObject, XmlAxisType axisType, string identifier, bool isXmlIdentifier) { + TargetObject = targetObject; + AxisType = axisType; + Identifier = identifier; + IsXmlIdentifier = isXmlIdentifier; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitXmlMemberAccessExpression(this, data); + } + + public override string ToString() { + return string.Format("[XmlMemberAccessExpression TargetObject={0} AxisType={1} IsXmlIdentifier={2} Iden" + + "tifier={3}]", TargetObject, AxisType, IsXmlIdentifier, Identifier); + } + } + + public class YieldStatement : Statement { + + Statement statement; + + public Statement Statement { + get { + return statement; + } + set { + statement = value ?? Statement.Null; + if (!statement.IsNull) statement.Parent = this; + } + } + + public YieldStatement(Statement statement) { + Statement = statement; + } + + public bool IsYieldReturn { + get { + return statement is ReturnStatement; + } + } + + public bool IsYieldBreak { + get { + return statement is BreakStatement; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.VisitYieldStatement(this, data); + } + + public override string ToString() { + return string.Format("[YieldStatement Statement={0}]", Statement); + } + } +} diff --git a/Project/Src/Ast/INode.cs b/Project/Src/Ast/INode.cs new file mode 100644 index 0000000000..766cc88a41 --- /dev/null +++ b/Project/Src/Ast/INode.cs @@ -0,0 +1,51 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.Ast +{ + public interface INode + { + INode Parent { + get; + set; + } + + List Children { + get; + } + + Location StartLocation { + get; + set; + } + + Location EndLocation { + get; + set; + } + + object UserData { + get; + set; + } + + /// + /// Visits all children + /// + /// The visitor to accept + /// Additional data for the visitor + /// The paremeter + object AcceptChildren(IAstVisitor visitor, object data); + + /// + /// Accept the visitor + /// + /// The visitor to accept + /// Additional data for the visitor + /// The value the visitor returns after the visit + object AcceptVisitor(IAstVisitor visitor, object data); + } +} diff --git a/Project/Src/Ast/INullable.cs b/Project/Src/Ast/INullable.cs new file mode 100644 index 0000000000..0c88a1b373 --- /dev/null +++ b/Project/Src/Ast/INullable.cs @@ -0,0 +1,12 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +namespace ICSharpCode.NRefactory.Ast +{ + public interface INullable + { + bool IsNull { + get; + } + } +} diff --git a/Project/Src/Ast/TypeReference.cs b/Project/Src/Ast/TypeReference.cs new file mode 100644 index 0000000000..84a01abb35 --- /dev/null +++ b/Project/Src/Ast/TypeReference.cs @@ -0,0 +1,427 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Runtime.InteropServices; +using System.Text; + +namespace ICSharpCode.NRefactory.Ast +{ + public class TypeReference : AbstractNode, INullable, ICloneable + { + public static readonly TypeReference StructConstraint = new TypeReference("constraint: struct"); + public static readonly TypeReference ClassConstraint = new TypeReference("constraint: class"); + public static readonly TypeReference NewConstraint = new TypeReference("constraint: new"); + + string type = ""; + int pointerNestingLevel; + int[] rankSpecifier; + List genericTypes = new List(); + + #region Static primitive type list + static Dictionary types = new Dictionary(); + static Dictionary vbtypes = new Dictionary(StringComparer.InvariantCultureIgnoreCase); + static Dictionary typesReverse = new Dictionary(); + static Dictionary vbtypesReverse = new Dictionary(); + + static TypeReference() + { + // C# types + types.Add("bool", "System.Boolean"); + types.Add("byte", "System.Byte"); + types.Add("char", "System.Char"); + types.Add("decimal", "System.Decimal"); + types.Add("double", "System.Double"); + types.Add("float", "System.Single"); + types.Add("int", "System.Int32"); + types.Add("long", "System.Int64"); + types.Add("object", "System.Object"); + types.Add("sbyte", "System.SByte"); + types.Add("short", "System.Int16"); + types.Add("string", "System.String"); + types.Add("uint", "System.UInt32"); + types.Add("ulong", "System.UInt64"); + types.Add("ushort", "System.UInt16"); + types.Add("void", "System.Void"); + + // VB.NET types + vbtypes.Add("Boolean", "System.Boolean"); + vbtypes.Add("Byte", "System.Byte"); + vbtypes.Add("SByte", "System.SByte"); + vbtypes.Add("Date", "System.DateTime"); + vbtypes.Add("Char", "System.Char"); + vbtypes.Add("Decimal", "System.Decimal"); + vbtypes.Add("Double", "System.Double"); + vbtypes.Add("Single", "System.Single"); + vbtypes.Add("Integer", "System.Int32"); + vbtypes.Add("Long", "System.Int64"); + vbtypes.Add("UInteger","System.UInt32"); + vbtypes.Add("ULong", "System.UInt64"); + vbtypes.Add("Object", "System.Object"); + vbtypes.Add("Short", "System.Int16"); + vbtypes.Add("UShort", "System.UInt16"); + vbtypes.Add("String", "System.String"); + + foreach (KeyValuePair pair in types) { + typesReverse.Add(pair.Value, pair.Key); + } + foreach (KeyValuePair pair in vbtypes) { + vbtypesReverse.Add(pair.Value, pair.Key); + } + } + + /// + /// Gets a shortname=>full name dictionary of C# types. + /// + public static IDictionary PrimitiveTypesCSharp { + get { return types; } + } + + /// + /// Gets a shortname=>full name dictionary of VB types. + /// + public static IDictionary PrimitiveTypesVB { + get { return vbtypes; } + } + + /// + /// Gets a full name=>shortname dictionary of C# types. + /// + public static IDictionary PrimitiveTypesCSharpReverse { + get { return typesReverse; } + } + + /// + /// Gets a full name=>shortname dictionary of VB types. + /// + public static IDictionary PrimitiveTypesVBReverse { + get { return vbtypesReverse; } + } + + + static string GetSystemType(string type) + { + if (types == null) return type; + + string systemType; + if (types.TryGetValue(type, out systemType)) { + return systemType; + } + if (vbtypes.TryGetValue(type, out systemType)) { + return systemType; + } + return type; + } + #endregion + + object ICloneable.Clone() + { + return this.Clone(); + } + + public virtual TypeReference Clone() + { + TypeReference c = new TypeReference(type); + CopyFields(this, c); + return c; + } + + /// + /// Copies the pointerNestingLevel, RankSpecifier, GenericTypes and IsGlobal flag + /// from to . + /// + /// + /// If already contains generics, the new generics are appended to the list. + /// + protected static void CopyFields(TypeReference from, TypeReference to) + { + to.pointerNestingLevel = from.pointerNestingLevel; + if (from.rankSpecifier != null) { + to.rankSpecifier = (int[])from.rankSpecifier.Clone(); + } + foreach (TypeReference r in from.genericTypes) { + to.genericTypes.Add(r.Clone()); + } + to.IsGlobal = from.IsGlobal; + to.IsKeyword = from.IsKeyword; + } + + public string Type { + get { + return type; + } + set { + Debug.Assert(value != null); + type = value ?? "?"; + } + } + + /// + /// Removes the last identifier from the type. + /// e.g. "System.String.Length" becomes "System.String" or + /// "System.Collections.IEnumerable(of string).Current" becomes "System.Collections.IEnumerable(of string)" + /// This is used for explicit interface implementation in VB. + /// + public static string StripLastIdentifierFromType(ref TypeReference tr) + { + if (tr is InnerClassTypeReference && ((InnerClassTypeReference)tr).Type.IndexOf('.') < 0) { + string ident = ((InnerClassTypeReference)tr).Type; + tr = ((InnerClassTypeReference)tr).BaseType; + return ident; + } else { + int pos = tr.Type.LastIndexOf('.'); + if (pos < 0) + return tr.Type; + string ident = tr.Type.Substring(pos + 1); + tr.Type = tr.Type.Substring(0, pos); + return ident; + } + } + + public int PointerNestingLevel { + get { + return pointerNestingLevel; + } + set { + Debug.Assert(this.IsNull == false); + pointerNestingLevel = value; + } + } + + /// + /// The rank of the array type. + /// For "object[]", this is { 0 }; for "object[,]", it is {1}. + /// For "object[,][,,][]", it is {1, 2, 0}. + /// For non-array types, this property is null or {}. + /// + public int[] RankSpecifier { + get { + return rankSpecifier; + } + set { + Debug.Assert(this.IsNull == false); + rankSpecifier = value; + } + } + + public List GenericTypes { + get { + return genericTypes; + } + } + + public bool IsArrayType { + get { + return rankSpecifier != null && rankSpecifier.Length > 0; + } + } + + public static TypeReference CheckNull(TypeReference typeReference) + { + return typeReference ?? NullTypeReference.Instance; + } + + public static TypeReference Null { + get { + return NullTypeReference.Instance; + } + } + + public virtual bool IsNull { + get { + return false; + } + } + + /// + /// Gets/Sets if the type reference had a "global::" prefix. + /// + public bool IsGlobal { + get; set; + } + + /// + /// Gets/Sets if the type reference was using a language keyword. + /// + public bool IsKeyword { + get; set; + } + + public TypeReference(string type) + { + this.Type = type; + } + + public TypeReference(string type, bool isKeyword) + { + this.Type = type; + this.IsKeyword = isKeyword; + } + + public TypeReference(string type, List genericTypes) : this(type) + { + if (genericTypes != null) { + this.genericTypes = genericTypes; + } + } + + public TypeReference(string type, int[] rankSpecifier) : this(type, 0, rankSpecifier) + { + } + + public TypeReference(string type, int pointerNestingLevel, int[] rankSpecifier) : this(type, pointerNestingLevel, rankSpecifier, null) + { + } + + public TypeReference(string type, int pointerNestingLevel, int[] rankSpecifier, List genericTypes) + { + Debug.Assert(type != null); + this.type = type; + this.pointerNestingLevel = pointerNestingLevel; + this.rankSpecifier = rankSpecifier; + if (genericTypes != null) { + this.genericTypes = genericTypes; + } + } + + protected TypeReference() + {} + + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return visitor.VisitTypeReference(this, data); + } + + public override string ToString() + { + StringBuilder b = new StringBuilder(type); + if (genericTypes != null && genericTypes.Count > 0) { + b.Append('<'); + for (int i = 0; i < genericTypes.Count; i++) { + if (i > 0) b.Append(','); + b.Append(genericTypes[i].ToString()); + } + b.Append('>'); + } + if (pointerNestingLevel > 0) { + b.Append('*', pointerNestingLevel); + } + if (IsArrayType) { + foreach (int rank in rankSpecifier) { + b.Append('['); + if (rank < 0) + b.Append('`', -rank); + else + b.Append(',', rank); + b.Append(']'); + } + } + return b.ToString(); + } + + public static bool AreEqualReferences(TypeReference a, TypeReference b) + { + if (a == b) return true; + if (a == null || b == null) return false; + if (a is InnerClassTypeReference) a = ((InnerClassTypeReference)a).CombineToNormalTypeReference(); + if (b is InnerClassTypeReference) b = ((InnerClassTypeReference)b).CombineToNormalTypeReference(); + if (a.type != b.type) return false; + if (a.IsKeyword != b.IsKeyword) return false; + if (a.IsGlobal != b.IsGlobal) return false; + if (a.pointerNestingLevel != b.pointerNestingLevel) return false; + if (a.IsArrayType != b.IsArrayType) return false; + if (a.IsArrayType) { + if (a.rankSpecifier.Length != b.rankSpecifier.Length) return false; + for (int i = 0; i < a.rankSpecifier.Length; i++) { + if (a.rankSpecifier[i] != b.rankSpecifier[i]) return false; + } + } + if (a.genericTypes.Count != b.genericTypes.Count) return false; + for (int i = 0; i < a.genericTypes.Count; i++) { + if (!AreEqualReferences(a.genericTypes[i], b.genericTypes[i])) + return false; + } + return true; + } + } + + internal sealed class NullTypeReference : TypeReference + { + public static readonly NullTypeReference Instance = new NullTypeReference(); + public override bool IsNull { + get { + return true; + } + } + public override TypeReference Clone() + { + return this; + } + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return null; + } + + public override string ToString() + { + return String.Format("[NullTypeReference]"); + } + } + + /// + /// We need this special type reference for cases like + /// OuterClass(Of T1).InnerClass(Of T2) (in expression or type context) + /// or Dictionary(Of String, NamespaceStruct).KeyCollection (in type context, otherwise it's a + /// MemberReferenceExpression) + /// + public class InnerClassTypeReference: TypeReference + { + TypeReference baseType; + + public TypeReference BaseType { + get { return baseType; } + set { baseType = value; } + } + + public override TypeReference Clone() + { + InnerClassTypeReference c = new InnerClassTypeReference(baseType.Clone(), Type, new List()); + CopyFields(this, c); + return c; + } + + public InnerClassTypeReference(TypeReference outerClass, string innerType, List innerGenericTypes) + : base(innerType, innerGenericTypes) + { + this.baseType = outerClass; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return visitor.VisitInnerClassTypeReference(this, data); + } + + /// + /// Creates a type reference where all type parameters are specified for the innermost class. + /// Namespace.OuterClass(of string).InnerClass(of integer).InnerInnerClass + /// becomes Namespace.OuterClass.InnerClass.InnerInnerClass(of string, integer) + /// + public TypeReference CombineToNormalTypeReference() + { + TypeReference tr = (baseType is InnerClassTypeReference) + ? ((InnerClassTypeReference)baseType).CombineToNormalTypeReference() + : baseType.Clone(); + CopyFields(this, tr); + tr.Type += "." + Type; + return tr; + } + + public override string ToString() + { + return baseType.ToString() + "+" + base.ToString(); + } + } +} diff --git a/Project/Src/AstBuilder/ExpressionBuilder.cs b/Project/Src/AstBuilder/ExpressionBuilder.cs new file mode 100644 index 0000000000..095e2173bb --- /dev/null +++ b/Project/Src/AstBuilder/ExpressionBuilder.cs @@ -0,0 +1,92 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using ICSharpCode.NRefactory.Ast; + +namespace ICSharpCode.NRefactory.AstBuilder +{ + /// + /// Extension methods for NRefactory.Ast.Expression. + /// + public static class ExpressionBuilder + { + public static IdentifierExpression Identifier(string identifier) + { + return new IdentifierExpression(identifier); + } + + public static MemberReferenceExpression Member(this Expression targetObject, string memberName) + { + if (targetObject == null) + throw new ArgumentNullException("targetObject"); + return new MemberReferenceExpression(targetObject, memberName); + } + + public static InvocationExpression Call(this Expression callTarget, string methodName, params Expression[] arguments) + { + if (callTarget == null) + throw new ArgumentNullException("callTarget"); + return Call(Member(callTarget, methodName), arguments); + } + + public static InvocationExpression Call(this Expression callTarget, params Expression[] arguments) + { + if (callTarget == null) + throw new ArgumentNullException("callTarget"); + if (arguments == null) + throw new ArgumentNullException("arguments"); + return new InvocationExpression(callTarget, new List(arguments)); + } + + public static ObjectCreateExpression New(this TypeReference createType, params Expression[] arguments) + { + if (createType == null) + throw new ArgumentNullException("createType"); + if (arguments == null) + throw new ArgumentNullException("arguments"); + return new ObjectCreateExpression(createType, new List(arguments)); + } + + public static Expression CreateDefaultValueForType(TypeReference type) + { + if (type != null && !type.IsArrayType) { + switch (type.Type) { + case "System.SByte": + case "System.Byte": + case "System.Int16": + case "System.UInt16": + case "System.Int32": + case "System.UInt32": + case "System.Int64": + case "System.UInt64": + case "System.Single": + case "System.Double": + return new PrimitiveExpression(0, "0"); + case "System.Char": + return new PrimitiveExpression('\0', "'\\0'"); + case "System.Object": + case "System.String": + return new PrimitiveExpression(null, "null"); + case "System.Boolean": + return new PrimitiveExpression(false, "false"); + default: + return new DefaultValueExpression(type); + } + } else { + return new PrimitiveExpression(null, "null"); + } + } + + /// + /// Just calls the BinaryOperatorExpression constructor, + /// but being an extension method; this allows for a nicer + /// infix syntax in some cases. + /// + public static BinaryOperatorExpression Operator(this Expression left, BinaryOperatorType op, Expression right) + { + return new BinaryOperatorExpression(left, op, right); + } + } +} diff --git a/Project/Src/AstBuilder/StatementBuilder.cs b/Project/Src/AstBuilder/StatementBuilder.cs new file mode 100644 index 0000000000..4619a098d0 --- /dev/null +++ b/Project/Src/AstBuilder/StatementBuilder.cs @@ -0,0 +1,55 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using ICSharpCode.NRefactory.Ast; + +namespace ICSharpCode.NRefactory.AstBuilder +{ + /// + /// Extension methods for NRefactory.Ast.Expression. + /// + public static class StatementBuilder + { + public static void AddStatement(this BlockStatement block, Statement statement) + { + if (block == null) + throw new ArgumentNullException("block"); + if (statement == null) + throw new ArgumentNullException("statement"); + block.AddChild(statement); + statement.Parent = block; + } + + public static void AddStatement(this BlockStatement block, Expression expressionStatement) + { + if (expressionStatement == null) + throw new ArgumentNullException("expressionStatement"); + AddStatement(block, new ExpressionStatement(expressionStatement)); + } + + public static void Throw(this BlockStatement block, Expression expression) + { + if (expression == null) + throw new ArgumentNullException("expression"); + AddStatement(block, new ThrowStatement(expression)); + } + + public static void Return(this BlockStatement block, Expression expression) + { + if (expression == null) + throw new ArgumentNullException("expression"); + AddStatement(block, new ReturnStatement(expression)); + } + + public static void Assign(this BlockStatement block, Expression left, Expression right) + { + if (left == null) + throw new ArgumentNullException("left"); + if (right == null) + throw new ArgumentNullException("right"); + AddStatement(block, new AssignmentExpression(left, AssignmentOperatorType.Assign, right)); + } + } +} diff --git a/Project/Src/EnvironmentInformationProvider.cs b/Project/Src/EnvironmentInformationProvider.cs new file mode 100644 index 0000000000..0aa9f993e7 --- /dev/null +++ b/Project/Src/EnvironmentInformationProvider.cs @@ -0,0 +1,22 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory +{ + public interface IEnvironmentInformationProvider + { + bool HasField(string reflectionTypeName, int typeParameterCount, string fieldName); + } + + sealed class DummyEnvironmentInformationProvider : IEnvironmentInformationProvider + { + internal static readonly IEnvironmentInformationProvider Instance = new DummyEnvironmentInformationProvider(); + + public bool HasField(string reflectionTypeName, int typeParameterCount, string fieldName) + { + return false; + } + } +} diff --git a/Project/Src/IAstVisitor.cs b/Project/Src/IAstVisitor.cs new file mode 100644 index 0000000000..b0bc662112 --- /dev/null +++ b/Project/Src/IAstVisitor.cs @@ -0,0 +1,278 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ICSharpCode.NRefactory { + using System; + using ICSharpCode.NRefactory.Ast; + + + public interface IAstVisitor { + + object VisitAddHandlerStatement(AddHandlerStatement addHandlerStatement, object data); + + object VisitAddressOfExpression(AddressOfExpression addressOfExpression, object data); + + object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data); + + object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data); + + object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data); + + object VisitAttribute(ICSharpCode.NRefactory.Ast.Attribute attribute, object data); + + object VisitAttributeSection(AttributeSection attributeSection, object data); + + object VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data); + + object VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data); + + object VisitBlockStatement(BlockStatement blockStatement, object data); + + object VisitBreakStatement(BreakStatement breakStatement, object data); + + object VisitCaseLabel(CaseLabel caseLabel, object data); + + object VisitCastExpression(CastExpression castExpression, object data); + + object VisitCatchClause(CatchClause catchClause, object data); + + object VisitCheckedExpression(CheckedExpression checkedExpression, object data); + + object VisitCheckedStatement(CheckedStatement checkedStatement, object data); + + object VisitClassReferenceExpression(ClassReferenceExpression classReferenceExpression, object data); + + object VisitCollectionInitializerExpression(CollectionInitializerExpression collectionInitializerExpression, object data); + + object VisitCollectionRangeVariable(CollectionRangeVariable collectionRangeVariable, object data); + + object VisitCompilationUnit(CompilationUnit compilationUnit, object data); + + object VisitConditionalExpression(ConditionalExpression conditionalExpression, object data); + + object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data); + + object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data); + + object VisitContinueStatement(ContinueStatement continueStatement, object data); + + object VisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data); + + object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data); + + object VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data); + + object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data); + + object VisitDirectionExpression(DirectionExpression directionExpression, object data); + + object VisitDoLoopStatement(DoLoopStatement doLoopStatement, object data); + + object VisitElseIfSection(ElseIfSection elseIfSection, object data); + + object VisitEmptyStatement(EmptyStatement emptyStatement, object data); + + object VisitEndStatement(EndStatement endStatement, object data); + + object VisitEraseStatement(EraseStatement eraseStatement, object data); + + object VisitErrorStatement(ErrorStatement errorStatement, object data); + + object VisitEventAddRegion(EventAddRegion eventAddRegion, object data); + + object VisitEventDeclaration(EventDeclaration eventDeclaration, object data); + + object VisitEventRaiseRegion(EventRaiseRegion eventRaiseRegion, object data); + + object VisitEventRemoveRegion(EventRemoveRegion eventRemoveRegion, object data); + + object VisitExitStatement(ExitStatement exitStatement, object data); + + object VisitExpressionRangeVariable(ExpressionRangeVariable expressionRangeVariable, object data); + + object VisitExpressionStatement(ExpressionStatement expressionStatement, object data); + + object VisitExternAliasDirective(ExternAliasDirective externAliasDirective, object data); + + object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data); + + object VisitFixedStatement(FixedStatement fixedStatement, object data); + + object VisitForeachStatement(ForeachStatement foreachStatement, object data); + + object VisitForNextStatement(ForNextStatement forNextStatement, object data); + + object VisitForStatement(ForStatement forStatement, object data); + + object VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, object data); + + object VisitGotoStatement(GotoStatement gotoStatement, object data); + + object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data); + + object VisitIfElseStatement(IfElseStatement ifElseStatement, object data); + + object VisitIndexerExpression(IndexerExpression indexerExpression, object data); + + object VisitInnerClassTypeReference(InnerClassTypeReference innerClassTypeReference, object data); + + object VisitInterfaceImplementation(InterfaceImplementation interfaceImplementation, object data); + + object VisitInvocationExpression(InvocationExpression invocationExpression, object data); + + object VisitLabelStatement(LabelStatement labelStatement, object data); + + object VisitLambdaExpression(LambdaExpression lambdaExpression, object data); + + object VisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data); + + object VisitLockStatement(LockStatement lockStatement, object data); + + object VisitMemberInitializerExpression(MemberInitializerExpression memberInitializerExpression, object data); + + object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data); + + object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data); + + object VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, object data); + + object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data); + + object VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data); + + object VisitOnErrorStatement(OnErrorStatement onErrorStatement, object data); + + object VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data); + + object VisitOptionDeclaration(OptionDeclaration optionDeclaration, object data); + + object VisitParameterDeclarationExpression(ParameterDeclarationExpression parameterDeclarationExpression, object data); + + object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data); + + object VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, object data); + + object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data); + + object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data); + + object VisitPropertyGetRegion(PropertyGetRegion propertyGetRegion, object data); + + object VisitPropertySetRegion(PropertySetRegion propertySetRegion, object data); + + object VisitQueryExpression(QueryExpression queryExpression, object data); + + object VisitQueryExpressionAggregateClause(QueryExpressionAggregateClause queryExpressionAggregateClause, object data); + + object VisitQueryExpressionDistinctClause(QueryExpressionDistinctClause queryExpressionDistinctClause, object data); + + object VisitQueryExpressionFromClause(QueryExpressionFromClause queryExpressionFromClause, object data); + + object VisitQueryExpressionGroupClause(QueryExpressionGroupClause queryExpressionGroupClause, object data); + + object VisitQueryExpressionGroupJoinVBClause(QueryExpressionGroupJoinVBClause queryExpressionGroupJoinVBClause, object data); + + object VisitQueryExpressionGroupVBClause(QueryExpressionGroupVBClause queryExpressionGroupVBClause, object data); + + object VisitQueryExpressionJoinClause(QueryExpressionJoinClause queryExpressionJoinClause, object data); + + object VisitQueryExpressionJoinConditionVB(QueryExpressionJoinConditionVB queryExpressionJoinConditionVB, object data); + + object VisitQueryExpressionJoinVBClause(QueryExpressionJoinVBClause queryExpressionJoinVBClause, object data); + + object VisitQueryExpressionLetClause(QueryExpressionLetClause queryExpressionLetClause, object data); + + object VisitQueryExpressionLetVBClause(QueryExpressionLetVBClause queryExpressionLetVBClause, object data); + + object VisitQueryExpressionOrderClause(QueryExpressionOrderClause queryExpressionOrderClause, object data); + + object VisitQueryExpressionOrdering(QueryExpressionOrdering queryExpressionOrdering, object data); + + object VisitQueryExpressionPartitionVBClause(QueryExpressionPartitionVBClause queryExpressionPartitionVBClause, object data); + + object VisitQueryExpressionSelectClause(QueryExpressionSelectClause queryExpressionSelectClause, object data); + + object VisitQueryExpressionSelectVBClause(QueryExpressionSelectVBClause queryExpressionSelectVBClause, object data); + + object VisitQueryExpressionVB(QueryExpressionVB queryExpressionVB, object data); + + object VisitQueryExpressionWhereClause(QueryExpressionWhereClause queryExpressionWhereClause, object data); + + object VisitRaiseEventStatement(RaiseEventStatement raiseEventStatement, object data); + + object VisitReDimStatement(ReDimStatement reDimStatement, object data); + + object VisitRemoveHandlerStatement(RemoveHandlerStatement removeHandlerStatement, object data); + + object VisitResumeStatement(ResumeStatement resumeStatement, object data); + + object VisitReturnStatement(ReturnStatement returnStatement, object data); + + object VisitSizeOfExpression(SizeOfExpression sizeOfExpression, object data); + + object VisitStackAllocExpression(StackAllocExpression stackAllocExpression, object data); + + object VisitStopStatement(StopStatement stopStatement, object data); + + object VisitSwitchSection(SwitchSection switchSection, object data); + + object VisitSwitchStatement(SwitchStatement switchStatement, object data); + + object VisitTemplateDefinition(TemplateDefinition templateDefinition, object data); + + object VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data); + + object VisitThrowStatement(ThrowStatement throwStatement, object data); + + object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data); + + object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data); + + object VisitTypeOfExpression(TypeOfExpression typeOfExpression, object data); + + object VisitTypeOfIsExpression(TypeOfIsExpression typeOfIsExpression, object data); + + object VisitTypeReference(TypeReference typeReference, object data); + + object VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data); + + object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data); + + object VisitUncheckedExpression(UncheckedExpression uncheckedExpression, object data); + + object VisitUncheckedStatement(UncheckedStatement uncheckedStatement, object data); + + object VisitUnsafeStatement(UnsafeStatement unsafeStatement, object data); + + object VisitUsing(Using @using, object data); + + object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data); + + object VisitUsingStatement(UsingStatement usingStatement, object data); + + object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data); + + object VisitWithStatement(WithStatement withStatement, object data); + + object VisitXmlAttributeExpression(XmlAttributeExpression xmlAttributeExpression, object data); + + object VisitXmlContentExpression(XmlContentExpression xmlContentExpression, object data); + + object VisitXmlDocumentExpression(XmlDocumentExpression xmlDocumentExpression, object data); + + object VisitXmlElementExpression(XmlElementExpression xmlElementExpression, object data); + + object VisitXmlEmbeddedExpression(XmlEmbeddedExpression xmlEmbeddedExpression, object data); + + object VisitXmlMemberAccessExpression(XmlMemberAccessExpression xmlMemberAccessExpression, object data); + + object VisitYieldStatement(YieldStatement yieldStatement, object data); + } +} diff --git a/Project/Src/Lexer/AbstractLexer.cs b/Project/Src/Lexer/AbstractLexer.cs new file mode 100644 index 0000000000..2d332c4934 --- /dev/null +++ b/Project/Src/Lexer/AbstractLexer.cs @@ -0,0 +1,386 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace ICSharpCode.NRefactory.Parser +{ + /// + /// This is the base class for the C# and VB.NET lexer + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1708:IdentifiersShouldDifferByMoreThanCase")] + internal abstract class AbstractLexer : ILexer + { + LATextReader reader; + int col = 1; + int line = 1; + + protected Errors errors = new Errors(); + + protected Token lastToken = null; + protected Token curToken = null; + protected Token peekToken = null; + + string[] specialCommentTags = null; + protected Hashtable specialCommentHash = null; + List tagComments = new List(); + protected StringBuilder sb = new StringBuilder(); + protected SpecialTracker specialTracker = new SpecialTracker(); + + // used for the original value of strings (with escape sequences). + protected StringBuilder originalValue = new StringBuilder(); + + public bool SkipAllComments { get; set; } + public bool EvaluateConditionalCompilation { get; set; } + public virtual IDictionary ConditionalCompilationSymbols { + get { throw new NotSupportedException(); } + } + + protected static IEnumerable GetSymbols (string symbols) + { + if (!string.IsNullOrEmpty(symbols)) { + foreach (string symbol in symbols.Split (';', ' ', '\t')) { + string s = symbol.Trim (); + if (s.Length == 0) + continue; + yield return s; + } + } + } + + public virtual void SetConditionalCompilationSymbols (string symbols) + { + throw new NotSupportedException (); + } + + protected int Line { + get { + return line; + } + } + protected int Col { + get { + return col; + } + } + + protected bool recordRead = false; + protected StringBuilder recordedText = new StringBuilder (); + + protected int ReaderRead() + { + int val = reader.Read(); + if (recordRead && val >= 0) + recordedText.Append ((char)val); + if ((val == '\r' && reader.Peek() != '\n') || val == '\n') { + ++line; + col = 1; + LineBreak(); + } else if (val >= 0) { + col++; + } + return val; + } + + protected int ReaderPeek() + { + return reader.Peek(); + } + + protected int ReaderPeek(int step) + { + return reader.Peek(step); + } + + protected void ReaderSkip(int steps) + { + for (int i = 0; i < steps; i++) { + ReaderRead(); + } + } + + protected string ReaderPeekString(int length) + { + StringBuilder builder = new StringBuilder(); + + for (int i = 0; i < length; i++) { + int peek = ReaderPeek(i); + if (peek != -1) + builder.Append((char)peek); + } + + return builder.ToString(); + } + + public void SetInitialLocation(Location location) + { + if (lastToken != null || curToken != null || peekToken != null) + throw new InvalidOperationException(); + this.line = location.Line; + this.col = location.Column; + } + + public Errors Errors { + get { + return errors; + } + } + + /// + /// Returns the comments that had been read and containing tag key words. + /// + public List TagComments { + get { + return tagComments; + } + } + + public SpecialTracker SpecialTracker { + get { + return specialTracker; + } + } + + /// + /// Special comment tags are tags like TODO, HACK or UNDONE which are read by the lexer and stored in . + /// + public string[] SpecialCommentTags { + get { + return specialCommentTags; + } + set { + specialCommentTags = value; + specialCommentHash = null; + if (specialCommentTags != null && specialCommentTags.Length > 0) { + specialCommentHash = new Hashtable(); + foreach (string str in specialCommentTags) { + specialCommentHash.Add(str, null); + } + } + } + } + + /// + /// The current Token. + /// + public Token Token { + get { +// Console.WriteLine("Call to Token"); + return lastToken; + } + } + + /// + /// The next Token (The after call) . + /// + public Token LookAhead { + get { +// Console.WriteLine("Call to LookAhead"); + return curToken; + } + } + + /// + /// Constructor for the abstract lexer class. + /// + protected AbstractLexer(TextReader reader) + { + this.reader = new LATextReader(reader); + } + + protected AbstractLexer(TextReader reader, LexerMemento state) + : this(reader) + { + SetInitialLocation(new Location(state.Column, state.Line)); + lastToken = new Token(state.PrevTokenKind, 0, 0); + } + + #region System.IDisposable interface implementation + public virtual void Dispose() + { + reader.Close(); + reader = null; + errors = null; + lastToken = curToken = peekToken = null; + specialCommentHash = null; + tagComments = null; + sb = originalValue = null; + } + #endregion + + /// + /// Must be called before a peek operation. + /// + public void StartPeek() + { + peekToken = curToken; + } + + /// + /// Gives back the next token. A second call to Peek() gives the next token after the last call for Peek() and so on. + /// + /// An object. + public Token Peek() + { +// Console.WriteLine("Call to Peek"); + if (peekToken.next == null) { + peekToken.next = Next(); + } + peekToken = peekToken.next; + return peekToken; + } + + /// + /// Reads the next token and gives it back. + /// + /// An object. + public virtual Token NextToken() + { + if (curToken == null) { + curToken = Next(); + //Console.WriteLine(ICSharpCode.NRefactory.Parser.CSharp.Tokens.GetTokenString(curToken.kind) + " -- " + curToken.val + "(" + curToken.kind + ")"); + return curToken; + } + + lastToken = curToken; + + if (curToken.next == null) { + curToken.next = Next(); + } + + curToken = curToken.next; + //Console.WriteLine(ICSharpCode.NRefactory.Parser.CSharp.Tokens.GetTokenString(curToken.kind) + " -- " + curToken.val + "(" + curToken.kind + ")"); + return curToken; + } + + protected abstract Token Next(); + + protected static bool IsIdentifierPart(int ch) + { + if (ch == 95) return true; // 95 = '_' + if (ch == -1) return false; + return char.IsLetterOrDigit((char)ch); // accept unicode letters + } + + protected static bool IsHex(char digit) + { + return Char.IsDigit(digit) || ('A' <= digit && digit <= 'F') || ('a' <= digit && digit <= 'f'); + } + + protected int GetHexNumber(char digit) + { + if (Char.IsDigit(digit)) { + return digit - '0'; + } + if ('A' <= digit && digit <= 'F') { + return digit - 'A' + 0xA; + } + if ('a' <= digit && digit <= 'f') { + return digit - 'a' + 0xA; + } + errors.Error(line, col, String.Format("Invalid hex number '" + digit + "'")); + return 0; + } + protected Location lastLineEnd = new Location (1, 1); + protected Location curLineEnd = new Location (1, 1); + protected void LineBreak () + { + lastLineEnd = curLineEnd; + curLineEnd = new Location (col - 1, line); + } + protected bool HandleLineEnd(char ch) + { + // Handle MS-DOS or MacOS line ends. + if (ch == '\r') { + if (reader.Peek() == '\n') { // MS-DOS line end '\r\n' + ReaderRead(); // LineBreak (); called by ReaderRead (); + return true; + } else { // assume MacOS line end which is '\r' + LineBreak (); + return true; + } + } + if (ch == '\n') { + LineBreak (); + return true; + } + return false; + } + + protected void SkipToEndOfLine() + { + int nextChar; + while ((nextChar = reader.Read()) != -1) { + if (nextChar == '\r') { + if (reader.Peek() == '\n') + reader.Read(); + nextChar = '\n'; + } + if (nextChar == '\n') { + ++line; + col = 1; + break; + } + } + } + + protected string ReadToEndOfLine() + { + sb.Length = 0; + int nextChar; + while ((nextChar = reader.Read()) != -1) { + char ch = (char)nextChar; + + if (nextChar == '\r') { + if (reader.Peek() == '\n') + reader.Read(); + nextChar = '\n'; + } + // Return read string, if EOL is reached + if (nextChar == '\n') { + ++line; + col = 1; + return sb.ToString(); + } + + sb.Append(ch); + } + + // Got EOF before EOL + string retStr = sb.ToString(); + col += retStr.Length; + return retStr; + } + + /// + /// Skips to the end of the current code block. + /// For this, the lexer must have read the next token AFTER the token opening the + /// block (so that Lexer.Token is the block-opening token, not Lexer.LookAhead). + /// After the call, Lexer.LookAhead will be the block-closing token. + /// + public abstract void SkipCurrentBlock(int targetToken); + + public event EventHandler SavepointReached; + + protected virtual void OnSavepointReached(SavepointEventArgs e) + { + if (SavepointReached != null) { + SavepointReached(this, e); + } + } + + public virtual LexerMemento Export() + { + throw new NotSupportedException(); + } + + public virtual void SetInitialContext(SnippetType context) + { + throw new NotSupportedException(); + } + } +} diff --git a/Project/Src/Lexer/CSharp/ConditionalCompilation.cs b/Project/Src/Lexer/CSharp/ConditionalCompilation.cs new file mode 100644 index 0000000000..da74a12182 --- /dev/null +++ b/Project/Src/Lexer/CSharp/ConditionalCompilation.cs @@ -0,0 +1,86 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using ICSharpCode.NRefactory.Ast; +using ICSharpCode.NRefactory.Visitors; + +namespace ICSharpCode.NRefactory.Parser.CSharp +{ + public sealed class ConditionalCompilation : AbstractAstVisitor + { + static readonly object SymbolDefined = new object(); + Dictionary symbols = new Dictionary(); + + public IDictionary Symbols { + get { return symbols; } + } + + public void Define(string symbol) + { + symbols[symbol] = SymbolDefined; + } + + public void Undefine(string symbol) + { + symbols.Remove(symbol); + } + + public bool Evaluate(Expression condition) + { + return condition.AcceptVisitor(this, null) == SymbolDefined; + } + + public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) + { + if (primitiveExpression.Value is bool) + return (bool)primitiveExpression.Value ? SymbolDefined : null; + else + return null; + } + + public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) + { + return symbols.ContainsKey(identifierExpression.Identifier) ? SymbolDefined : null; + } + + public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) + { + if (unaryOperatorExpression.Op == UnaryOperatorType.Not) { + return unaryOperatorExpression.Expression.AcceptVisitor(this, data) == SymbolDefined ? null : SymbolDefined; + } else { + return null; + } + } + + public override object VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data) + { + bool lhs = binaryOperatorExpression.Left.AcceptVisitor(this, data) == SymbolDefined; + bool rhs = binaryOperatorExpression.Right.AcceptVisitor(this, data) == SymbolDefined; + bool result; + switch (binaryOperatorExpression.Op) { + case BinaryOperatorType.LogicalAnd: + result = lhs && rhs; + break; + case BinaryOperatorType.LogicalOr: + result = lhs || rhs; + break; + case BinaryOperatorType.Equality: + result = lhs == rhs; + break; + case BinaryOperatorType.InEquality: + result = lhs != rhs; + break; + default: + return null; + } + return result ? SymbolDefined : null; + } + + public override object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) + { + return parenthesizedExpression.Expression.AcceptVisitor(this, data); + } + } +} diff --git a/Project/Src/Lexer/CSharp/KeywordList.txt b/Project/Src/Lexer/CSharp/KeywordList.txt new file mode 100644 index 0000000000..238b175542 --- /dev/null +++ b/Project/Src/Lexer/CSharp/KeywordList.txt @@ -0,0 +1,215 @@ +# this list is used for autogeneration of: +# - Keywords.cs +# - Tokens.cs +# - ATGTokensSection.txt - the TOKENS section of the ATG file + +# use BuildKeywords to generate the different lists. + +$Namespace=ICSharpCode.NRefactory.Parser.CSharp +$UpperCaseKeywords=False + +# TERMINAL_CLASSES +EOF +Identifier +Literal + +# SPECIAL_CHARACTERS +Assign = "=" +Plus = "+" +Minus = "-" +Times = "*" +Div = "/" +Mod = "%" + +Colon = ":" +DoubleColon = "::" +Semicolon = ";" +Question = "?" +DoubleQuestion = "??" +Comma = "," +Dot = "." + +OpenCurlyBrace = "{" +CloseCurlyBrace = "}" + +OpenSquareBracket = "[" +CloseSquareBracket = "]" + +OpenParenthesis = "(" +CloseParenthesis = ")" + +GreaterThan = ">" +LessThan = "<" + +Not = "!" +LogicalAnd = "&&" +LogicalOr = "||" + +BitwiseComplement = "~" +BitwiseAnd = "&" +BitwiseOr = "|" +Xor = "^" + +Increment = "++" +Decrement = "--" +Equal = "==" +NotEqual = "!=" +GreaterEqual = ">=" +LessEqual = "<=" + +ShiftLeft = "<<" +#Removed because of generics +#ShiftRight = ">>" + +PlusAssign = "+=" +MinusAssign = "-=" +TimesAssign = "*=" +DivAssign = "/=" +ModAssign = "%=" +BitwiseAndAssign = "&=" +BitwiseOrAssign = "|=" +XorAssign = "^=" +ShiftLeftAssign = "<<=" +#Removed because of generics +#ShiftRightAssign = ">>=" +Pointer = "->" +LambdaArrow = "=>" + +# Keywordlist +"abstract" +"as" +"base" +"bool" +"break" +"byte" +"case" +"catch" +"char" +"checked" +"class" +"const" +"continue" +"decimal" +"default" +"delegate" +"do" +"double" +"else" +"enum" +"event" +"explicit" +"extern" +"false" +"finally" +"fixed" +"float" +"for" +"foreach" +"goto" +"if" +"implicit" +"in" +"int" +"interface" +"internal" +"is" +"lock" +"long" +"namespace" +"new" +"null" +"object" +"operator" +"out" +"override" +"params" +"private" +"protected" +"public" +"readonly" +"ref" +"return" +"sbyte" +"sealed" +"short" +"sizeof" +"stackalloc" +"static" +"string" +"struct" +"switch" +"this" +"throw" +"true" +"try" +"typeof" +"uint" +"ulong" +"unchecked" +"unsafe" +"ushort" +"using" +"virtual" +"void" +"volatile" +"while" + +# Context dependent keywords. +"partial" +"where" +"get" +"set" +"add" +"remove" +"yield" +"select" +"group" +"by" +"into" +"from" +"ascending" +"descending" +"orderby" +"let" +"join" +"on" +"equals" + +#Sets + +# When changing IdentifierTokens, ensure you also change the "Identifier" production in cs.ATG +IdentifierTokens(Identifier, "partial", "where", "get", "set", "add", "remove", "yield", "select", "group", "by", "into", "from", "ascending", "descending", "orderby", "let", "join", "on", "equals") + +OverloadableUnaryOp("-", "!", "~", "++", "--", "true", "false") +OverloadableBinaryOp("+", "-", "*", "/", "%", "&", "|", "^", "<<", "==", "!=", ">", "<", ">=", "<=") + +TypeKW("char", "bool", "object", "string", "sbyte", "byte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double", "decimal") +UnaryHead("+", "-", "!", "~", "*", "++", "--", "&") +AssnStartOp("+", "-", "!", "~", "*") +CastFollower(@SimpleTypeName, Literal, "(", "~", "!", @ExpressionStart) +AssgnOps("=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "<<=") +UnaryOp("+", "-", "!", "~", "*", "++", "--", "&") +TypeDeclarationKW("class", "interface", "struct", "enum", "delegate") +# for §7.5.4.2 "Grammar ambiguities" disambiguation for F(G(7)) +GenericFollower("(", ")", "]", "}", ":", ";", Comma, ".", "?", "==", "!=") + +ValidInsideTypeName(@IdentifierTokens, @TypeKW, "<", ">", ".", "?", "[", Comma, "]", "*", "::") + +# Keywords for keyword-code-completion +KCCClassModifiers("abstract", "sealed", "static", "unsafe", "partial") +KCCTypeDeclarationStart("public", "internal", @TypeDeclarationKW, @KCCClassModifiers) +KCCMemberVisibilityModifiers("protected", "private", "public", "internal") +SimpleTypeName(@TypeKW, @IdentifierTokens, "void") +GlobalLevel("namespace", "using", "extern", @KCCTypeDeclarationStart) +ExpressionStart("base", "delegate", "false", "new", "null", "sizeof", "this", "true", "typeof", "checked", "unchecked", "from", "default") +ExpressionContent("as", "is", "out", "ref", "in") +# interfaces cannot have inner classes etc., the only keyword (expect for type names) that may appear in them is "event" +InterfaceLevel("event") +TypeLevel(@KCCTypeDeclarationStart, @KCCMemberVisibilityModifiers, "const", "event", "explicit", "extern", "fixed", "implicit", "new", "operator", "override", "readonly", "virtual", "volatile") +StatementStart(@ExpressionStart, @ExpressionContent, "break", "case", "catch", "checked", "unchecked", "const", "continue", "default", "do", "else", "finally", "fixed", "for", "foreach", "goto", "if", "lock", "return", "stackalloc", "switch", "throw", "try", "unsafe", "using", "while", "yield") +QueryExpressionClauseStart("from", "let", "where", "join", "orderby", "group", "select") +InPropertyDeclaration(@KCCMemberVisibilityModifiers, "get", "set") +InEventDeclaration("add", "remove") + +# unused: where +# "by", "into", "ascending", "descending", "on", "equals" diff --git a/Project/Src/Lexer/CSharp/Keywords.cs b/Project/Src/Lexer/CSharp/Keywords.cs new file mode 100644 index 0000000000..3f28c5e735 --- /dev/null +++ b/Project/Src/Lexer/CSharp/Keywords.cs @@ -0,0 +1,132 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +// this file was autogenerated by a tool. +using System; + +namespace ICSharpCode.NRefactory.Parser.CSharp +{ + public static class Keywords + { + static readonly string[] keywordList = { + "abstract", + "as", + "base", + "bool", + "break", + "byte", + "case", + "catch", + "char", + "checked", + "class", + "const", + "continue", + "decimal", + "default", + "delegate", + "do", + "double", + "else", + "enum", + "event", + "explicit", + "extern", + "false", + "finally", + "fixed", + "float", + "for", + "foreach", + "goto", + "if", + "implicit", + "in", + "int", + "interface", + "internal", + "is", + "lock", + "long", + "namespace", + "new", + "null", + "object", + "operator", + "out", + "override", + "params", + "private", + "protected", + "public", + "readonly", + "ref", + "return", + "sbyte", + "sealed", + "short", + "sizeof", + "stackalloc", + "static", + "string", + "struct", + "switch", + "this", + "throw", + "true", + "try", + "typeof", + "uint", + "ulong", + "unchecked", + "unsafe", + "ushort", + "using", + "virtual", + "void", + "volatile", + "while", + "partial", + "where", + "get", + "set", + "add", + "remove", + "yield", + "select", + "group", + "by", + "into", + "from", + "ascending", + "descending", + "orderby", + "let", + "join", + "on", + "equals" + }; + + static LookupTable keywords = new LookupTable(true); + + static Keywords() + { + for (int i = 0; i < keywordList.Length; ++i) { + keywords[keywordList[i]] = i + Tokens.Abstract; + } + } + + public static int GetToken(string keyword) + { + return keywords[keyword]; + } + + public static bool IsNonIdentifierKeyword(string word) + { + int token = GetToken(word); + if (token < 0) + return false; + return !Tokens.IdentifierTokens[token]; + } + } +} diff --git a/Project/Src/Lexer/CSharp/Lexer.cs b/Project/Src/Lexer/CSharp/Lexer.cs new file mode 100644 index 0000000000..babd26c85f --- /dev/null +++ b/Project/Src/Lexer/CSharp/Lexer.cs @@ -0,0 +1,1213 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text; + +namespace ICSharpCode.NRefactory.Parser.CSharp +{ + internal sealed class Lexer : AbstractLexer + { + bool isAtLineBegin = true; + + public Lexer(TextReader reader) : base(reader) + { + } + + protected override Token Next() + { + char ch; + bool hadLineEnd = false; + if (Line == 1 && Col == 1) { + isAtLineBegin = true; + hadLineEnd = true; // beginning of document + } + + while (true) { + Location startLocation = new Location(Col, Line); + int nextChar = ReaderRead(); + if (nextChar == -1) + break; + + Token token; + + switch (nextChar) { + case ' ': + case '\t': + continue; + case '\r': + case '\n': + HandleLineEnd((char)nextChar); + if (hadLineEnd) { + // second line end before getting to a token + // -> here was a blank line + specialTracker.AddEndOfLine(startLocation); + } + hadLineEnd = true; + isAtLineBegin = true; + continue; + case '/': + int peek = ReaderPeek(); + if (peek == '/' || peek == '*') { + ReadComment(); + continue; + } else { + isAtLineBegin = false; + token = ReadOperator('/'); + } + break; + case '#': + ReadPreProcessingDirective(); + isAtLineBegin = false; + continue; + case '"': + token = ReadString(); + isAtLineBegin = false; + break; + case '\'': + token = ReadChar(); + isAtLineBegin = false; + break; + case '@': + isAtLineBegin = false; + int next = ReaderRead(); + if (next == -1) { + errors.Error(Line, Col, String.Format("EOF after @")); + continue; + } else { + int x = Col - 1; + int y = Line; + ch = (char)next; + if (ch == '"') { + token = ReadVerbatimString(); + } else if (Char.IsLetterOrDigit(ch) || ch == '_') { + bool canBeKeyword; + token = new Token(Tokens.Identifier, x - 1, y, ReadIdent(ch, out canBeKeyword)); + } else { + HandleLineEnd(ch); + errors.Error(y, x, String.Format("Unexpected char in Lexer.Next() : {0}", ch)); + continue; + } + } + break; + default: + isAtLineBegin = false; // non-ws chars are handled here + ch = (char)nextChar; + if (Char.IsLetter(ch) || ch == '_' || ch == '\\') { + int x = Col - 1; // Col was incremented above, but we want the start of the identifier + int y = Line; + bool canBeKeyword; + string s = ReadIdent(ch, out canBeKeyword); + if (canBeKeyword) { + int keyWordToken = Keywords.GetToken(s); + if (keyWordToken >= 0) { + return new Token(keyWordToken, x, y, s); + } + } + return new Token(Tokens.Identifier, x, y, s); + } else if (Char.IsDigit(ch)) { + token = ReadDigit(ch, Col - 1); + } else { + token = ReadOperator(ch); + } + break; + } + + // try error recovery (token = null -> continue with next char) + if (token != null) { + return token; + } + } + + return new Token(Tokens.EOF, Col, Line, String.Empty); + } + + // The C# compiler has a fixed size length therefore we'll use a fixed size char array for identifiers + // it's also faster than using a string builder. + const int MAX_IDENTIFIER_LENGTH = 512; + char[] identBuffer = new char[MAX_IDENTIFIER_LENGTH]; + + string ReadIdent(char ch, out bool canBeKeyword) + { + int peek; + int curPos = 0; + canBeKeyword = true; + while (true) { + if (ch == '\\') { + peek = ReaderPeek(); + if (peek != 'u' && peek != 'U') { + errors.Error(Line, Col, "Identifiers can only contain unicode escape sequences"); + } + canBeKeyword = false; + string surrogatePair; + ReadEscapeSequence(out ch, out surrogatePair); + if (surrogatePair != null) { + if (!char.IsLetterOrDigit(surrogatePair, 0)) { + errors.Error(Line, Col, "Unicode escape sequences in identifiers cannot be used to represent characters that are invalid in identifiers"); + } + for (int i = 0; i < surrogatePair.Length - 1; i++) { + if (curPos < MAX_IDENTIFIER_LENGTH) { + identBuffer[curPos++] = surrogatePair[i]; + } + } + ch = surrogatePair[surrogatePair.Length - 1]; + } else { + if (!IsIdentifierPart(ch)) { + errors.Error(Line, Col, "Unicode escape sequences in identifiers cannot be used to represent characters that are invalid in identifiers"); + } + } + } + + if (curPos < MAX_IDENTIFIER_LENGTH) { + if (ch != '\0') // only add character, if it is valid + // prevents \ from being added + identBuffer[curPos++] = ch; + } else { + errors.Error(Line, Col, String.Format("Identifier too long")); + while (IsIdentifierPart(ReaderPeek())) { + ReaderRead(); + } + break; + } + peek = ReaderPeek(); + if (IsIdentifierPart(peek) || peek == '\\') { + ch = (char)ReaderRead(); + } else { + break; + } + } + return new String(identBuffer, 0, curPos); + } + + Token ReadDigit(char ch, int x) + { + unchecked { // prevent exception when ReaderPeek() = -1 is cast to char + int y = Line; + sb.Length = 0; + sb.Append(ch); + string prefix = null; + string suffix = null; + + bool ishex = false; + bool isunsigned = false; + bool islong = false; + bool isfloat = false; + bool isdouble = false; + bool isdecimal = false; + + char peek = (char)ReaderPeek(); + + if (ch == '.') { + isdouble = true; + + while (Char.IsDigit((char)ReaderPeek())) { // read decimal digits beyond the dot + sb.Append((char)ReaderRead()); + } + peek = (char)ReaderPeek(); + } else if (ch == '0' && (peek == 'x' || peek == 'X')) { + ReaderRead(); // skip 'x' + sb.Length = 0; // Remove '0' from 0x prefix from the stringvalue + while (IsHex((char)ReaderPeek())) { + sb.Append((char)ReaderRead()); + } + if (sb.Length == 0) { + sb.Append('0'); // dummy value to prevent exception + errors.Error(y, x, "Invalid hexadecimal integer literal"); + } + ishex = true; + prefix = "0x"; + peek = (char)ReaderPeek(); + } else { + while (Char.IsDigit((char)ReaderPeek())) { + sb.Append((char)ReaderRead()); + } + peek = (char)ReaderPeek(); + } + + Token nextToken = null; // if we accidently read a 'dot' + if (peek == '.') { // read floating point number + ReaderRead(); + peek = (char)ReaderPeek(); + if (!Char.IsDigit(peek)) { + nextToken = new Token(Tokens.Dot, Col - 1, Line); + peek = '.'; + } else { + isdouble = true; // double is default + if (ishex) { + errors.Error(y, x, String.Format("No hexadecimal floating point values allowed")); + } + sb.Append('.'); + + while (Char.IsDigit((char)ReaderPeek())) { // read decimal digits beyond the dot + sb.Append((char)ReaderRead()); + } + peek = (char)ReaderPeek(); + } + } + + if (peek == 'e' || peek == 'E') { // read exponent + isdouble = true; + sb.Append((char)ReaderRead()); + peek = (char)ReaderPeek(); + if (peek == '-' || peek == '+') { + sb.Append((char)ReaderRead()); + } + while (Char.IsDigit((char)ReaderPeek())) { // read exponent value + sb.Append((char)ReaderRead()); + } + isunsigned = true; + peek = (char)ReaderPeek(); + } + + if (peek == 'f' || peek == 'F') { // float value + ReaderRead(); + suffix = "f"; + isfloat = true; + } else if (peek == 'd' || peek == 'D') { // double type suffix (obsolete, double is default) + ReaderRead(); + suffix = "d"; + isdouble = true; + } else if (peek == 'm' || peek == 'M') { // decimal value + ReaderRead(); + suffix = "m"; + isdecimal = true; + } else if (!isdouble) { + if (peek == 'u' || peek == 'U') { + ReaderRead(); + suffix = "u"; + isunsigned = true; + peek = (char)ReaderPeek(); + } + + if (peek == 'l' || peek == 'L') { + ReaderRead(); + peek = (char)ReaderPeek(); + islong = true; + if (!isunsigned && (peek == 'u' || peek == 'U')) { + ReaderRead(); + suffix = "Lu"; + isunsigned = true; + } else { + suffix = isunsigned ? "uL" : "L"; + } + } + } + + string digit = sb.ToString(); + string stringValue = prefix + digit + suffix; + + if (isfloat) { + float num; + if (float.TryParse(digit, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) { + return new Token(Tokens.Literal, x, y, stringValue, num, LiteralFormat.DecimalNumber); + } else { + errors.Error(y, x, String.Format("Can't parse float {0}", digit)); + return new Token(Tokens.Literal, x, y, stringValue, 0f, LiteralFormat.DecimalNumber); + } + } + if (isdecimal) { + decimal num; + if (decimal.TryParse(digit, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) { + return new Token(Tokens.Literal, x, y, stringValue, num, LiteralFormat.DecimalNumber); + } else { + errors.Error(y, x, String.Format("Can't parse decimal {0}", digit)); + return new Token(Tokens.Literal, x, y, stringValue, 0m, LiteralFormat.DecimalNumber); + } + } + if (isdouble) { + double num; + if (double.TryParse(digit, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) { + return new Token(Tokens.Literal, x, y, stringValue, num, LiteralFormat.DecimalNumber); + } else { + errors.Error(y, x, String.Format("Can't parse double {0}", digit)); + return new Token(Tokens.Literal, x, y, stringValue, 0d, LiteralFormat.DecimalNumber); + } + } + + // Try to determine a parsable value using ranges. + ulong result; + if (ishex) { + if (!ulong.TryParse(digit, NumberStyles.HexNumber, null, out result)) { + errors.Error(y, x, String.Format("Can't parse hexadecimal constant {0}", digit)); + return new Token(Tokens.Literal, x, y, stringValue.ToString(), 0, LiteralFormat.HexadecimalNumber); + } + } else { + if (!ulong.TryParse(digit, NumberStyles.Integer, null, out result)) { + errors.Error(y, x, String.Format("Can't parse integral constant {0}", digit)); + return new Token(Tokens.Literal, x, y, stringValue.ToString(), 0, LiteralFormat.DecimalNumber); + } + } + + if (result > long.MaxValue) { + islong = true; + isunsigned = true; + } else if (result > uint.MaxValue) { + islong = true; + } else if (islong == false && result > int.MaxValue) { + isunsigned = true; + } + + Token token; + + LiteralFormat literalFormat = ishex ? LiteralFormat.HexadecimalNumber : LiteralFormat.DecimalNumber; + if (islong) { + if (isunsigned) { + ulong num; + if (ulong.TryParse(digit, ishex ? NumberStyles.HexNumber : NumberStyles.Number, CultureInfo.InvariantCulture, out num)) { + token = new Token(Tokens.Literal, x, y, stringValue, num, literalFormat); + } else { + errors.Error(y, x, String.Format("Can't parse unsigned long {0}", digit)); + token = new Token(Tokens.Literal, x, y, stringValue, 0UL, literalFormat); + } + } else { + long num; + if (long.TryParse(digit, ishex ? NumberStyles.HexNumber : NumberStyles.Number, CultureInfo.InvariantCulture, out num)) { + token = new Token(Tokens.Literal, x, y, stringValue, num, literalFormat); + } else { + errors.Error(y, x, String.Format("Can't parse long {0}", digit)); + token = new Token(Tokens.Literal, x, y, stringValue, 0L, literalFormat); + } + } + } else { + if (isunsigned) { + uint num; + if (uint.TryParse(digit, ishex ? NumberStyles.HexNumber : NumberStyles.Number, CultureInfo.InvariantCulture, out num)) { + token = new Token(Tokens.Literal, x, y, stringValue, num, literalFormat); + } else { + errors.Error(y, x, String.Format("Can't parse unsigned int {0}", digit)); + token = new Token(Tokens.Literal, x, y, stringValue, (uint)0, literalFormat); + } + } else { + int num; + if (int.TryParse(digit, ishex ? NumberStyles.HexNumber : NumberStyles.Number, CultureInfo.InvariantCulture, out num)) { + token = new Token(Tokens.Literal, x, y, stringValue, num, literalFormat); + } else { + errors.Error(y, x, String.Format("Can't parse int {0}", digit)); + token = new Token(Tokens.Literal, x, y, stringValue, 0, literalFormat); + } + } + } + token.next = nextToken; + return token; + } + } + + Token ReadString() + { + int x = Col - 1; + int y = Line; + + sb.Length = 0; + originalValue.Length = 0; + originalValue.Append('"'); + bool doneNormally = false; + int nextChar; + while ((nextChar = ReaderRead()) != -1) { + char ch = (char)nextChar; + + if (ch == '"') { + doneNormally = true; + originalValue.Append('"'); + break; + } + + if (ch == '\\') { + originalValue.Append('\\'); + string surrogatePair; + originalValue.Append(ReadEscapeSequence(out ch, out surrogatePair)); + if (surrogatePair != null) { + sb.Append(surrogatePair); + } else { + sb.Append(ch); + } + } else if (HandleLineEnd(ch)) { + // call HandleLineEnd to ensure line numbers are still correct after the error + errors.Error(y, x, String.Format("No new line is allowed inside a string literal")); + break; + } else { + originalValue.Append(ch); + sb.Append(ch); + } + } + + if (!doneNormally) { + errors.Error(y, x, String.Format("End of file reached inside string literal")); + } + + return new Token(Tokens.Literal, x, y, originalValue.ToString(), sb.ToString(), LiteralFormat.StringLiteral); + } + + Token ReadVerbatimString() + { + sb.Length = 0; + originalValue.Length = 0; + originalValue.Append("@\""); + Location startLocation = new Location(Col - 2, Line); // @ and " already read + int nextChar; + while ((nextChar = ReaderRead()) != -1) { + char ch = (char)nextChar; + + if (ch == '"') { + if (ReaderPeek() != '"') { + originalValue.Append('"'); + break; + } + originalValue.Append("\"\""); + sb.Append('"'); + ReaderRead(); + } else if (HandleLineEnd(ch)) { + sb.Append("\r\n"); + originalValue.Append("\r\n"); + } else { + sb.Append(ch); + originalValue.Append(ch); + } + } + + if (nextChar == -1) { + errors.Error(startLocation.Line, startLocation.Column, String.Format("End of file reached inside verbatim string literal")); + } + + return new Token(Tokens.Literal, startLocation, new Location(Col, Line), originalValue.ToString(), sb.ToString(), LiteralFormat.VerbatimStringLiteral); + } + + readonly char[] escapeSequenceBuffer = new char[12]; + + /// + /// reads an escape sequence + /// + /// The character represented by the escape sequence, + /// or '\0' if there was an error or the escape sequence represents a character that + /// can be represented only be a suggorate pair + /// Null, except when the character represented + /// by the escape sequence can only be represented by a surrogate pair (then the string + /// contains the surrogate pair) + /// The escape sequence + string ReadEscapeSequence(out char ch, out string surrogatePair) + { + surrogatePair = null; + + int nextChar = ReaderRead(); + if (nextChar == -1) { + errors.Error(Line, Col, String.Format("End of file reached inside escape sequence")); + ch = '\0'; + return String.Empty; + } + int number; + char c = (char)nextChar; + int curPos = 1; + escapeSequenceBuffer[0] = c; + switch (c) { + case '\'': + ch = '\''; + break; + case '\"': + ch = '\"'; + break; + case '\\': + ch = '\\'; + break; + case '0': + ch = '\0'; + break; + case 'a': + ch = '\a'; + break; + case 'b': + ch = '\b'; + break; + case 'f': + ch = '\f'; + break; + case 'n': + ch = '\n'; + break; + case 'r': + ch = '\r'; + break; + case 't': + ch = '\t'; + break; + case 'v': + ch = '\v'; + break; + case 'u': + case 'x': + // 16 bit unicode character + c = (char)ReaderRead(); + number = GetHexNumber(c); + escapeSequenceBuffer[curPos++] = c; + + if (number < 0) { + errors.Error(Line, Col - 1, String.Format("Invalid char in literal : {0}", c)); + } + for (int i = 0; i < 3; ++i) { + if (IsHex((char)ReaderPeek())) { + c = (char)ReaderRead(); + int idx = GetHexNumber(c); + escapeSequenceBuffer[curPos++] = c; + number = 16 * number + idx; + } else { + break; + } + } + ch = (char)number; + break; + case 'U': + // 32 bit unicode character + number = 0; + for (int i = 0; i < 8; ++i) { + if (IsHex((char)ReaderPeek())) { + c = (char)ReaderRead(); + int idx = GetHexNumber(c); + escapeSequenceBuffer[curPos++] = c; + number = 16 * number + idx; + } else { + errors.Error(Line, Col - 1, String.Format("Invalid char in literal : {0}", (char)ReaderPeek())); + break; + } + } + if (number > 0xffff) { + ch = '\0'; + surrogatePair = char.ConvertFromUtf32(number); + } else { + ch = (char)number; + } + break; + default: + errors.Error(Line, Col, String.Format("Unexpected escape sequence : {0}", c)); + ch = '\0'; + break; + } + return new String(escapeSequenceBuffer, 0, curPos); + } + + Token ReadChar() + { + int x = Col - 1; + int y = Line; + int nextChar = ReaderRead(); + if (nextChar == -1 || HandleLineEnd((char)nextChar)) { + errors.Error(y, x, String.Format("End of line reached inside character literal")); + return null; + } + char ch = (char)nextChar; + char chValue = ch; + string escapeSequence = String.Empty; + if (ch == '\\') { + string surrogatePair; + escapeSequence = ReadEscapeSequence(out chValue, out surrogatePair); + if (surrogatePair != null) { + errors.Error(y, x, String.Format("The unicode character must be represented by a surrogate pair and does not fit into a System.Char")); + } + } + + unchecked { + if ((char)ReaderRead() != '\'') { + errors.Error(y, x, String.Format("Char not terminated")); + } + } + return new Token(Tokens.Literal, x, y, "'" + ch + escapeSequence + "'", chValue, LiteralFormat.CharLiteral); + } + + Token ReadOperator(char ch) + { + int x = Col - 1; + int y = Line; + switch (ch) { + case '+': + switch (ReaderPeek()) { + case '+': + ReaderRead(); + return new Token(Tokens.Increment, x, y); + case '=': + ReaderRead(); + return new Token(Tokens.PlusAssign, x, y); + } + return new Token(Tokens.Plus, x, y); + case '-': + switch (ReaderPeek()) { + case '-': + ReaderRead(); + return new Token(Tokens.Decrement, x, y); + case '=': + ReaderRead(); + return new Token(Tokens.MinusAssign, x, y); + case '>': + ReaderRead(); + return new Token(Tokens.Pointer, x, y); + } + return new Token(Tokens.Minus, x, y); + case '*': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.TimesAssign, x, y); + default: + break; + } + return new Token(Tokens.Times, x, y); + case '/': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.DivAssign, x, y); + } + return new Token(Tokens.Div, x, y); + case '%': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.ModAssign, x, y); + } + return new Token(Tokens.Mod, x, y); + case '&': + switch (ReaderPeek()) { + case '&': + ReaderRead(); + return new Token(Tokens.LogicalAnd, x, y); + case '=': + ReaderRead(); + return new Token(Tokens.BitwiseAndAssign, x, y); + } + return new Token(Tokens.BitwiseAnd, x, y); + case '|': + switch (ReaderPeek()) { + case '|': + ReaderRead(); + return new Token(Tokens.LogicalOr, x, y); + case '=': + ReaderRead(); + return new Token(Tokens.BitwiseOrAssign, x, y); + } + return new Token(Tokens.BitwiseOr, x, y); + case '^': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.XorAssign, x, y); + default: + break; + } + return new Token(Tokens.Xor, x, y); + case '!': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.NotEqual, x, y); + } + return new Token(Tokens.Not, x, y); + case '~': + return new Token(Tokens.BitwiseComplement, x, y); + case '=': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.Equal, x, y); + case '>': + ReaderRead(); + return new Token(Tokens.LambdaArrow, x, y); + } + return new Token(Tokens.Assign, x, y); + case '<': + switch (ReaderPeek()) { + case '<': + ReaderRead(); + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.ShiftLeftAssign, x, y); + default: + break; + } + return new Token(Tokens.ShiftLeft, x, y); + case '=': + ReaderRead(); + return new Token(Tokens.LessEqual, x, y); + } + return new Token(Tokens.LessThan, x, y); + case '>': + switch (ReaderPeek()) { + // Removed because of generics: +// case '>': +// ReaderRead(); +// if (ReaderPeek() != -1) { +// switch ((char)ReaderPeek()) { +// case '=': +// ReaderRead(); +// return new Token(Tokens.ShiftRightAssign, x, y); +// default: +// break; +// } +// } +// return new Token(Tokens.ShiftRight, x, y); + case '=': + ReaderRead(); + return new Token(Tokens.GreaterEqual, x, y); + } + return new Token(Tokens.GreaterThan, x, y); + case '?': + if (ReaderPeek() == '?') { + ReaderRead(); + return new Token(Tokens.DoubleQuestion, x, y); + } + return new Token(Tokens.Question, x, y); + case ';': + return new Token(Tokens.Semicolon, x, y); + case ':': + if (ReaderPeek() == ':') { + ReaderRead(); + return new Token(Tokens.DoubleColon, x, y); + } + return new Token(Tokens.Colon, x, y); + case ',': + return new Token(Tokens.Comma, x, y); + case '.': + // Prevent OverflowException when ReaderPeek returns -1 + int tmp = ReaderPeek(); + if (tmp > 0 && Char.IsDigit((char)tmp)) { + return ReadDigit('.', Col - 1); + } + return new Token(Tokens.Dot, x, y); + case ')': + return new Token(Tokens.CloseParenthesis, x, y); + case '(': + return new Token(Tokens.OpenParenthesis, x, y); + case ']': + return new Token(Tokens.CloseSquareBracket, x, y); + case '[': + return new Token(Tokens.OpenSquareBracket, x, y); + case '}': + return new Token(Tokens.CloseCurlyBrace, x, y); + case '{': + return new Token(Tokens.OpenCurlyBrace, x, y); + default: + return null; + } + } + + void ReadComment() + { + switch (ReaderRead()) { + case '*': + ReadMultiLineComment(); + isAtLineBegin = false; + break; + case '/': + if (ReaderPeek() == '/') { + ReaderRead(); + ReadSingleLineComment(CommentType.Documentation); + } else { + ReadSingleLineComment(CommentType.SingleLine); + } + isAtLineBegin = true; + break; + default: + errors.Error(Line, Col, String.Format("Error while reading comment")); + break; + } + } + + string ReadCommentToEOL() + { + if (specialCommentHash == null) { + return ReadToEndOfLine(); + } + sb.Length = 0; + StringBuilder curWord = new StringBuilder(); + + int nextChar; + while ((nextChar = ReaderRead()) != -1) { + char ch = (char)nextChar; + + if (HandleLineEnd(ch)) { + break; + } + + sb.Append(ch); + if (IsIdentifierPart(nextChar)) { + curWord.Append(ch); + } else { + string tag = curWord.ToString(); + curWord.Length = 0; + if (specialCommentHash.ContainsKey(tag)) { + Location p = new Location(Col, Line); + string comment = ch + ReadToEndOfLine(); + this.TagComments.Add(new TagComment(tag, comment, isAtLineBegin, p, new Location(Col, Line))); + sb.Append(comment); + break; + } + } + } + return sb.ToString(); + } + + void ReadSingleLineComment(CommentType commentType) + { + if (this.SkipAllComments) { + SkipToEndOfLine(); + } else { + specialTracker.StartComment(commentType, isAtLineBegin, new Location(Col, Line)); + specialTracker.AddString(ReadCommentToEOL()); + specialTracker.FinishComment(new Location(Col, Line)); + } + } + + void ReadMultiLineComment() + { + int nextChar; + if (this.SkipAllComments) { + while ((nextChar = ReaderRead()) != -1) { + char ch = (char)nextChar; + if (ch == '*' && ReaderPeek() == '/') { + ReaderRead(); + return; + } else { + HandleLineEnd(ch); + } + } + } else { + specialTracker.StartComment(CommentType.Block, isAtLineBegin, new Location(Col, Line)); + + // sc* = special comment handling (TO DO markers) + string scTag = null; // is set to non-null value when we are inside a comment marker + StringBuilder scCurWord = new StringBuilder(); // current word, (scTag == null) or comment (when scTag != null) + Location scStartLocation = Location.Empty; + + while ((nextChar = ReaderRead()) != -1) { + char ch = (char)nextChar; + + if (HandleLineEnd(ch)) { + if (scTag != null) { + this.TagComments.Add(new TagComment(scTag, scCurWord.ToString(), isAtLineBegin, scStartLocation, new Location(Col, Line))); + scTag = null; + } + scCurWord.Length = 0; + specialTracker.AddString(Environment.NewLine); + continue; + } + + // End of multiline comment reached ? + if (ch == '*' && ReaderPeek() == '/') { + if (scTag != null) { + this.TagComments.Add(new TagComment(scTag, scCurWord.ToString(), isAtLineBegin, scStartLocation, new Location(Col, Line))); + } + ReaderRead(); + specialTracker.FinishComment(new Location(Col, Line)); + return; + } + specialTracker.AddChar(ch); + if (scTag != null || IsIdentifierPart(ch)) { + scCurWord.Append(ch); + } else { + if (specialCommentHash != null && specialCommentHash.ContainsKey(scCurWord.ToString())) { + scTag = scCurWord.ToString(); + scStartLocation = new Location(Col, Line); + } + scCurWord.Length = 0; + } + } + specialTracker.FinishComment(new Location(Col, Line)); + } + // Reached EOF before end of multiline comment. + errors.Error(Line, Col, String.Format("Reached EOF before the end of a multiline comment")); + } + + /// + /// Skips to the end of the current code block. + /// For this, the lexer must have read the next token AFTER the token opening the + /// block (so that Lexer.Token is the block-opening token, not Lexer.LookAhead). + /// After the call, Lexer.LookAhead will be the block-closing token. + /// + public override void SkipCurrentBlock(int targetToken) + { + int braceCount = 0; + while (curToken != null) { + if (curToken.kind == Tokens.OpenCurlyBrace) { + ++braceCount; + } else if (curToken.kind == Tokens.CloseCurlyBrace) { + if (--braceCount < 0) + return; + } + lastToken = curToken; + curToken = curToken.next; + } + isAtLineBegin = true; + int nextChar; + while ((nextChar = ReaderRead()) != -1) { + switch (nextChar) { + case '{': + isAtLineBegin = false; + braceCount++; + break; + case '}': + isAtLineBegin = false; + if (--braceCount < 0) { + curToken = new Token(Tokens.CloseCurlyBrace, Col - 1, Line); + return; + } + break; + case '/': + int peek = ReaderPeek(); + if (peek == '/' || peek == '*') { + ReadComment(); + } + isAtLineBegin = false; + break; + case '#': + ReadPreProcessingDirective(); + isAtLineBegin = false; + break; + case '"': + ReadString(); + isAtLineBegin = false; + break; + case '\'': + ReadChar(); + isAtLineBegin = false; + break; + case '\r': + case '\n': + HandleLineEnd((char)nextChar); + isAtLineBegin = true; + break; + case '@': + int next = ReaderRead(); + if (next == -1) { + errors.Error(Line, Col, String.Format("EOF after @")); + } else if (next == '"') { + ReadVerbatimString(); + } + isAtLineBegin = false; + break; + } + } + curToken = new Token(Tokens.EOF, Col, Line); + } + + public override IDictionary ConditionalCompilationSymbols { + get { return conditionalCompilation.Symbols; } + } + + public override void SetConditionalCompilationSymbols (string symbols) + { + foreach (string symbol in GetSymbols (symbols)) { + conditionalCompilation.Define (symbol); + } + } + + + ConditionalCompilation conditionalCompilation = new ConditionalCompilation(); + + void ReadPreProcessingDirective() + { + PreprocessingDirective d = ReadPreProcessingDirectiveInternal(true, true); + this.specialTracker.AddPreprocessingDirective(d); + + if (EvaluateConditionalCompilation) { + switch (d.Cmd) { + case "#define": + conditionalCompilation.Define(d.Arg); + break; + case "#undef": + conditionalCompilation.Undefine(d.Arg); + break; + case "#if": + if (!conditionalCompilation.Evaluate(d.Expression)) { + // skip to valid #elif or #else or #endif + int level = 1; + while (true) { + d = SkipToPreProcessingDirective(false, level == 1); + if (d == null) + break; + if (d.Cmd == "#if") { + level++; + } else if (d.Cmd == "#endif") { + level--; + if (level == 0) + break; + } else if (level == 1 && (d.Cmd == "#else" + || d.Cmd == "#elif" && conditionalCompilation.Evaluate(d.Expression))) + { + break; + } + } + if (d != null) + this.specialTracker.AddPreprocessingDirective(d); + } + break; + case "#elif": + case "#else": + // we already visited the #if part or a previous #elif part, so skip until #endif + { + int level = 1; + while (true) { + d = SkipToPreProcessingDirective(false, false); + if (d == null) + break; + if (d.Cmd == "#if") { + level++; + } else if (d.Cmd == "#endif") { + level--; + if (level == 0) + break; + } + } + if (d != null) + this.specialTracker.AddPreprocessingDirective(d); + } + break; + } + } + } + + PreprocessingDirective SkipToPreProcessingDirective(bool parseIfExpression, bool parseElifExpression) + { + int c; + while (true) { + PPWhitespace(); + c = ReaderRead(); + if (c == -1) { + errors.Error(Line, Col, String.Format("Reached EOF but expected #endif")); + return null; + } else if (c == '#') { + break; + } else { + SkipToEndOfLine(); + } + } + return ReadPreProcessingDirectiveInternal(parseIfExpression, parseElifExpression); + } + + PreprocessingDirective ReadPreProcessingDirectiveInternal(bool parseIfExpression, bool parseElifExpression) + { + Location start = new Location(Col - 1, Line); + + // skip spaces between # and the directive + PPWhitespace(); + + bool canBeKeyword; + string directive = ReadIdent('#', out canBeKeyword); + + PPWhitespace(); + if (parseIfExpression && directive == "#if" || parseElifExpression && directive == "#elif") { + recordedText.Length = 0; + recordRead = true; + Ast.Expression expr = PPExpression(); + string arg = recordedText.ToString (); + recordRead = false; + + Location endLocation = new Location(Col, Line); + int c = ReaderRead(); + if (c >= 0 && !HandleLineEnd((char)c)) { + if (c == '/' && ReaderRead() == '/') { + // comment to end of line + } else { + errors.Error(Col, Line, "Expected end of line"); + } + SkipToEndOfLine(); // skip comment + } + return new PreprocessingDirective(directive, arg, start, endLocation) { Expression = expr, LastLineEnd = lastLineEnd }; + } else { + Location endLocation = new Location(Col, Line); + string arg = ReadToEndOfLine(); + endLocation.Column += arg.Length; + int pos = arg.IndexOf("//"); + if (pos >= 0) + arg = arg.Substring(0, pos); + arg = arg.Trim(); + return new PreprocessingDirective(directive, arg, start, endLocation) { LastLineEnd = lastLineEnd }; + } + } + + void PPWhitespace() + { + while (ReaderPeek() == ' ' || ReaderPeek() == '\t') + ReaderRead(); + } + + Ast.Expression PPExpression() + { + Ast.Expression expr = PPAndExpression(); + while (ReaderPeek() == '|') { + Token token = ReadOperator((char)ReaderRead()); + if (token == null || token.kind != Tokens.LogicalOr) { + return expr; + } + Ast.Expression expr2 = PPAndExpression(); + expr = new Ast.BinaryOperatorExpression(expr, Ast.BinaryOperatorType.LogicalOr, expr2); + } + return expr; + } + + Ast.Expression PPAndExpression() + { + Ast.Expression expr = PPEqualityExpression(); + while (ReaderPeek() == '&') { + Token token = ReadOperator((char)ReaderRead()); + if (token == null || token.kind != Tokens.LogicalAnd) { + break; + } + Ast.Expression expr2 = PPEqualityExpression(); + expr = new Ast.BinaryOperatorExpression(expr, Ast.BinaryOperatorType.LogicalAnd, expr2); + } + return expr; + } + + Ast.Expression PPEqualityExpression() + { + Ast.Expression expr = PPUnaryExpression(); + while (ReaderPeek() == '=' || ReaderPeek() == '!') { + Token token = ReadOperator((char)ReaderRead()); + if (token == null || token.kind != Tokens.Equals && token.kind != Tokens.NotEqual) { + break; + } + Ast.Expression expr2 = PPUnaryExpression(); + expr = new Ast.BinaryOperatorExpression(expr, token.kind == Tokens.Equals ? Ast.BinaryOperatorType.Equality : Ast.BinaryOperatorType.InEquality, expr2); + } + return expr; + } + + Ast.Expression PPUnaryExpression() + { + PPWhitespace(); + if (ReaderPeek() == '!') { + ReaderRead(); + PPWhitespace(); + return new Ast.UnaryOperatorExpression(PPUnaryExpression(), Ast.UnaryOperatorType.Not); + } else { + return PPPrimaryExpression(); + } + } + + Ast.Expression PPPrimaryExpression() + { + int c = ReaderRead(); + if (c < 0) + return Ast.Expression.Null; + if (c == '(') { + Ast.Expression expr = new Ast.ParenthesizedExpression(PPExpression()); + PPWhitespace(); + if (ReaderRead() != ')') + errors.Error(Col, Line, "Expected ')'"); + PPWhitespace(); + return expr; + } else { + if (c != '_' && !char.IsLetterOrDigit((char)c) && c != '\\') + errors.Error(Col, Line, "Expected conditional symbol"); + bool canBeKeyword; + string symbol = ReadIdent((char)c, out canBeKeyword); + PPWhitespace(); + if (canBeKeyword && symbol == "true") + return new Ast.PrimitiveExpression(true, "true"); + else if (canBeKeyword && symbol == "false") + return new Ast.PrimitiveExpression(false, "false"); + else + return new Ast.IdentifierExpression(symbol); + } + } + } +} diff --git a/Project/Src/Lexer/CSharp/Tokens.cs b/Project/Src/Lexer/CSharp/Tokens.cs new file mode 100644 index 0000000000..339a043aa2 --- /dev/null +++ b/Project/Src/Lexer/CSharp/Tokens.cs @@ -0,0 +1,356 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +// this file was autogenerated by a tool. +using System; +using System.Collections; + +namespace ICSharpCode.NRefactory.Parser.CSharp +{ + public static class Tokens + { + // ----- terminal classes ----- + public const int EOF = 0; + public const int Identifier = 1; + public const int Literal = 2; + + // ----- special character ----- + public const int Assign = 3; + public const int Plus = 4; + public const int Minus = 5; + public const int Times = 6; + public const int Div = 7; + public const int Mod = 8; + public const int Colon = 9; + public const int DoubleColon = 10; + public const int Semicolon = 11; + public const int Question = 12; + public const int DoubleQuestion = 13; + public const int Comma = 14; + public const int Dot = 15; + public const int OpenCurlyBrace = 16; + public const int CloseCurlyBrace = 17; + public const int OpenSquareBracket = 18; + public const int CloseSquareBracket = 19; + public const int OpenParenthesis = 20; + public const int CloseParenthesis = 21; + public const int GreaterThan = 22; + public const int LessThan = 23; + public const int Not = 24; + public const int LogicalAnd = 25; + public const int LogicalOr = 26; + public const int BitwiseComplement = 27; + public const int BitwiseAnd = 28; + public const int BitwiseOr = 29; + public const int Xor = 30; + public const int Increment = 31; + public const int Decrement = 32; + public const int Equal = 33; + public const int NotEqual = 34; + public const int GreaterEqual = 35; + public const int LessEqual = 36; + public const int ShiftLeft = 37; + public const int PlusAssign = 38; + public const int MinusAssign = 39; + public const int TimesAssign = 40; + public const int DivAssign = 41; + public const int ModAssign = 42; + public const int BitwiseAndAssign = 43; + public const int BitwiseOrAssign = 44; + public const int XorAssign = 45; + public const int ShiftLeftAssign = 46; + public const int Pointer = 47; + public const int LambdaArrow = 48; + + // ----- keywords ----- + public const int Abstract = 49; + public const int As = 50; + public const int Base = 51; + public const int Bool = 52; + public const int Break = 53; + public const int Byte = 54; + public const int Case = 55; + public const int Catch = 56; + public const int Char = 57; + public const int Checked = 58; + public const int Class = 59; + public const int Const = 60; + public const int Continue = 61; + public const int Decimal = 62; + public const int Default = 63; + public const int Delegate = 64; + public const int Do = 65; + public const int Double = 66; + public const int Else = 67; + public const int Enum = 68; + public const int Event = 69; + public const int Explicit = 70; + public const int Extern = 71; + public const int False = 72; + public const int Finally = 73; + public const int Fixed = 74; + public const int Float = 75; + public const int For = 76; + public const int Foreach = 77; + public const int Goto = 78; + public const int If = 79; + public const int Implicit = 80; + public const int In = 81; + public const int Int = 82; + public const int Interface = 83; + public const int Internal = 84; + public const int Is = 85; + public const int Lock = 86; + public const int Long = 87; + public const int Namespace = 88; + public const int New = 89; + public const int Null = 90; + public const int Object = 91; + public const int Operator = 92; + public const int Out = 93; + public const int Override = 94; + public const int Params = 95; + public const int Private = 96; + public const int Protected = 97; + public const int Public = 98; + public const int Readonly = 99; + public const int Ref = 100; + public const int Return = 101; + public const int Sbyte = 102; + public const int Sealed = 103; + public const int Short = 104; + public const int Sizeof = 105; + public const int Stackalloc = 106; + public const int Static = 107; + public const int String = 108; + public const int Struct = 109; + public const int Switch = 110; + public const int This = 111; + public const int Throw = 112; + public const int True = 113; + public const int Try = 114; + public const int Typeof = 115; + public const int Uint = 116; + public const int Ulong = 117; + public const int Unchecked = 118; + public const int Unsafe = 119; + public const int Ushort = 120; + public const int Using = 121; + public const int Virtual = 122; + public const int Void = 123; + public const int Volatile = 124; + public const int While = 125; + public const int Partial = 126; + public const int Where = 127; + public const int Get = 128; + public const int Set = 129; + public const int Add = 130; + public const int Remove = 131; + public const int Yield = 132; + public const int Select = 133; + public const int Group = 134; + public const int By = 135; + public const int Into = 136; + public const int From = 137; + public const int Ascending = 138; + public const int Descending = 139; + public const int Orderby = 140; + public const int Let = 141; + public const int Join = 142; + public const int On = 143; + new public const int Equals = 144; + + public const int MaxToken = 145; + static BitArray NewSet(params int[] values) + { + BitArray bitArray = new BitArray(MaxToken); + foreach (int val in values) { + bitArray[val] = true; + } + return bitArray; + } + public static BitArray IdentifierTokens = NewSet(Identifier, Partial, Where, Get, Set, Add, Remove, Yield, Select, Group, By, Into, From, Ascending, Descending, Orderby, Let, Join, On, Equals); + public static BitArray OverloadableUnaryOp = NewSet(Minus, Not, BitwiseComplement, Increment, Decrement, True, False); + public static BitArray OverloadableBinaryOp = NewSet(Plus, Minus, Times, Div, Mod, BitwiseAnd, BitwiseOr, Xor, ShiftLeft, Equal, NotEqual, GreaterThan, LessThan, GreaterEqual, LessEqual); + public static BitArray TypeKW = NewSet(Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal); + public static BitArray UnaryHead = NewSet(Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd); + public static BitArray AssnStartOp = NewSet(Plus, Minus, Not, BitwiseComplement, Times); + public static BitArray CastFollower = NewSet(Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal, Identifier, Partial, Where, Get, Set, Add, Remove, Yield, Select, Group, By, Into, From, Ascending, Descending, Orderby, Let, Join, On, Equals, Void, Literal, OpenParenthesis, BitwiseComplement, Not, Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, Default); + public static BitArray AssgnOps = NewSet(Assign, PlusAssign, MinusAssign, TimesAssign, DivAssign, ModAssign, BitwiseAndAssign, BitwiseOrAssign, ShiftLeftAssign); + public static BitArray UnaryOp = NewSet(Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd); + public static BitArray TypeDeclarationKW = NewSet(Class, Interface, Struct, Enum, Delegate); + public static BitArray GenericFollower = NewSet(OpenParenthesis, CloseParenthesis, CloseSquareBracket, CloseCurlyBrace, Colon, Semicolon, Comma, Dot, Question, Equal, NotEqual); + public static BitArray ValidInsideTypeName = NewSet(Identifier, Partial, Where, Get, Set, Add, Remove, Yield, Select, Group, By, Into, From, Ascending, Descending, Orderby, Let, Join, On, Equals, Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal, LessThan, GreaterThan, Dot, Question, OpenSquareBracket, Comma, CloseSquareBracket, Times, DoubleColon); + public static BitArray KCCClassModifiers = NewSet(Abstract, Sealed, Static, Unsafe, Partial); + public static BitArray KCCTypeDeclarationStart = NewSet(Public, Internal, Class, Interface, Struct, Enum, Delegate, Abstract, Sealed, Static, Unsafe, Partial); + public static BitArray KCCMemberVisibilityModifiers = NewSet(Protected, Private, Public, Internal); + public static BitArray SimpleTypeName = NewSet(Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal, Identifier, Partial, Where, Get, Set, Add, Remove, Yield, Select, Group, By, Into, From, Ascending, Descending, Orderby, Let, Join, On, Equals, Void); + public static BitArray GlobalLevel = NewSet(Namespace, Using, Extern, Public, Internal, Class, Interface, Struct, Enum, Delegate, Abstract, Sealed, Static, Unsafe, Partial); + public static BitArray ExpressionStart = NewSet(Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, Default); + public static BitArray ExpressionContent = NewSet(As, Is, Out, Ref, In); + public static BitArray InterfaceLevel = NewSet(Event); + public static BitArray TypeLevel = NewSet(Public, Internal, Class, Interface, Struct, Enum, Delegate, Abstract, Sealed, Static, Unsafe, Partial, Protected, Private, Public, Internal, Const, Event, Explicit, Extern, Fixed, Implicit, New, Operator, Override, Readonly, Virtual, Volatile); + public static BitArray StatementStart = NewSet(Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, Default, As, Is, Out, Ref, In, Break, Case, Catch, Checked, Unchecked, Const, Continue, Default, Do, Else, Finally, Fixed, For, Foreach, Goto, If, Lock, Return, Stackalloc, Switch, Throw, Try, Unsafe, Using, While, Yield); + public static BitArray QueryExpressionClauseStart = NewSet(From, Let, Where, Join, Orderby, Group, Select); + public static BitArray InPropertyDeclaration = NewSet(Protected, Private, Public, Internal, Get, Set); + public static BitArray InEventDeclaration = NewSet(Add, Remove); + + static string[] tokenList = new string[] { + // ----- terminal classes ----- + "", + "", + "", + // ----- special character ----- + "=", + "+", + "-", + "*", + "/", + "%", + ":", + "::", + ";", + "?", + "??", + ",", + ".", + "{", + "}", + "[", + "]", + "(", + ")", + ">", + "<", + "!", + "&&", + "||", + "~", + "&", + "|", + "^", + "++", + "--", + "==", + "!=", + ">=", + "<=", + "<<", + "+=", + "-=", + "*=", + "/=", + "%=", + "&=", + "|=", + "^=", + "<<=", + "->", + "=>", + // ----- keywords ----- + "abstract", + "as", + "base", + "bool", + "break", + "byte", + "case", + "catch", + "char", + "checked", + "class", + "const", + "continue", + "decimal", + "default", + "delegate", + "do", + "double", + "else", + "enum", + "event", + "explicit", + "extern", + "false", + "finally", + "fixed", + "float", + "for", + "foreach", + "goto", + "if", + "implicit", + "in", + "int", + "interface", + "internal", + "is", + "lock", + "long", + "namespace", + "new", + "null", + "object", + "operator", + "out", + "override", + "params", + "private", + "protected", + "public", + "readonly", + "ref", + "return", + "sbyte", + "sealed", + "short", + "sizeof", + "stackalloc", + "static", + "string", + "struct", + "switch", + "this", + "throw", + "true", + "try", + "typeof", + "uint", + "ulong", + "unchecked", + "unsafe", + "ushort", + "using", + "virtual", + "void", + "volatile", + "while", + "partial", + "where", + "get", + "set", + "add", + "remove", + "yield", + "select", + "group", + "by", + "into", + "from", + "ascending", + "descending", + "orderby", + "let", + "join", + "on", + "equals", + }; + public static string GetTokenString(int token) + { + if (token >= 0 && token < tokenList.Length) { + return tokenList[token]; + } + throw new System.NotSupportedException("Unknown token:" + token); + } + } +} diff --git a/Project/Src/Lexer/ILexer.cs b/Project/Src/Lexer/ILexer.cs new file mode 100644 index 0000000000..f567b4e513 --- /dev/null +++ b/Project/Src/Lexer/ILexer.cs @@ -0,0 +1,123 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.Parser +{ + /// + /// Lexer interface + /// + public interface ILexer : IDisposable + { + /// + /// Sets the start line/column number. This method can be called only before the first token is read. + /// + void SetInitialLocation(Location location); + + /// + /// Sets the context of the lexer. + /// + void SetInitialContext(SnippetType context); + + Errors Errors { + get; + } + + /// + /// The current Token. + /// + Token Token { + get; + } + + /// + /// The next Token (The after call) . + /// + Token LookAhead { + get; + } + + /// + /// Special comment tags are tags like TODO, HACK or UNDONE which are read by the lexer and stored in . + /// + string[] SpecialCommentTags { + get; + set; + } + + /// + /// Gets/Sets if the lexer should skip adding comments to the special tracker. Set this + /// property to true to improve lexing performance. + /// + bool SkipAllComments { + get; + set; + } + + /// + /// Gets/Sets if the lexer should evaluate conditional compilation symbols. + /// + bool EvaluateConditionalCompilation { get; set; } + + /// + /// The dictionary with the conditional compilation symbols. + /// C# ignores the value (you can use null), it just cares whether a symbol is defined. + /// + IDictionary ConditionalCompilationSymbols { get; } + + /// + /// Sets the conditional compilation symbols. + /// + /// + /// A containing the symbols. The symbols are separated by ';'. + /// + void SetConditionalCompilationSymbols (string symbols); + + /// + /// Returns the comments that had been read and containing tag key words. + /// + List TagComments { + get; + } + + SpecialTracker SpecialTracker { + get; + } + + void StartPeek(); + + /// + /// Gives back the next token. A second call to Peek() gives the next token after the last call for Peek() and so on. + /// + /// An object. + Token Peek(); + + /// + /// Reads the next token and gives it back. + /// + /// An object. + Token NextToken(); + + /// + /// Skips to the end of the current code block. + /// For this, the lexer must have read the next token AFTER the token opening the + /// block (so that Lexer.Token is the block-opening token, not Lexer.LookAhead). + /// After the call, Lexer.LookAhead will be the block-closing token. + /// + void SkipCurrentBlock(int targetToken); + + /// + /// Used to export the current state of the lexer. The exported state should be + /// complete, so that it is possible to reset the lexer to a previous state completely. + /// + LexerMemento Export(); + + /// + /// Is fired by the lexer as soon as a savepoint is reached. + /// The Export-method can be used to retrieve the current state. + /// + event EventHandler SavepointReached; + } +} diff --git a/Project/Src/Lexer/LATextReader.cs b/Project/Src/Lexer/LATextReader.cs new file mode 100644 index 0000000000..8bb6940f9b --- /dev/null +++ b/Project/Src/Lexer/LATextReader.cs @@ -0,0 +1,52 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.IO; + +namespace ICSharpCode.NRefactory.Parser +{ + public class LATextReader : TextReader + { + List buffer; + TextReader reader; + + public LATextReader(TextReader reader) + { + this.buffer = new List(); + this.reader = reader; + } + + public override int Peek() + { + return Peek(0); + } + + public override int Read() + { + int c = Peek(); + buffer.RemoveAt(0); + return c; + } + + public int Peek(int step) + { + while (step >= buffer.Count) { + buffer.Add(reader.Read()); + } + + if (step < 0) + return -1; + + return buffer[step]; + } + + protected override void Dispose(bool disposing) + { + if (disposing) + reader.Dispose(); + base.Dispose(disposing); + } + } +} diff --git a/Project/Src/Lexer/LexerMemento.cs b/Project/Src/Lexer/LexerMemento.cs new file mode 100644 index 0000000000..2534ae3b74 --- /dev/null +++ b/Project/Src/Lexer/LexerMemento.cs @@ -0,0 +1,14 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory.Parser +{ + public abstract class LexerMemento + { + public int Line { get; set; } + public int Column { get; set; } + public int PrevTokenKind { get; set; } + } +} diff --git a/Project/Src/Lexer/LookupTable.cs b/Project/Src/Lexer/LookupTable.cs new file mode 100644 index 0000000000..349a22460c --- /dev/null +++ b/Project/Src/Lexer/LookupTable.cs @@ -0,0 +1,116 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Globalization; + +namespace ICSharpCode.NRefactory.Parser +{ + /// + /// This class implements a keyword map. It implements a digital search trees (tries) to find + /// a word. + /// + internal class LookupTable + { + Node root = new Node(-1, null); + bool casesensitive; + int length; + + /// + /// The number of elements in the table + /// + public int Count { + get { + return length; + } + } + + /// + /// Inserts an int in the tree, under keyword + /// + public int this[string keyword] { + get { + Node next = root; + + if (!casesensitive) { + keyword = keyword.ToUpper(CultureInfo.InvariantCulture); + } + + for (int i = 0; i < keyword.Length; ++i) { + int index = ((int)keyword[i]) % 256; + next = next.leaf[index]; + + if (next == null) { + return -1; + } + + if (keyword == next.word) { + return next.val; + } + } + return -1; + } + set { + Node node = root; + Node next = root; + + if (!casesensitive) { + keyword = keyword.ToUpper(CultureInfo.InvariantCulture); + } + + ++length; + + // insert word into the tree + for (int i = 0; i < keyword.Length; ++i) { + int index = ((int)keyword[i]) % 256; // index of curchar + bool d = keyword[i] == '\\'; + + next = next.leaf[index]; // get node to this index + + if (next == null) { // no node created -> insert word here + node.leaf[index] = new Node(value, keyword); + break; + } + + if (next.word != null && next.word.Length != i) { // node there, take node content and insert them again + string tmpword = next.word; // this word will be inserted 1 level deeper (better, don't need too much + int tmpval = next.val; // string comparisons for finding.) + next.val = -1; + next.word = null; + this[tmpword] = tmpval; + } + + if (i == keyword.Length - 1) { // end of keyword reached, insert node there, if a node was here it was + next.word = keyword; // reinserted, if it has the same length (keyword EQUALS this word) it will be overwritten + next.val = value; + break; + } + + node = next; + } + } + } + + /// + /// Creates a new instance of + /// + public LookupTable(bool casesensitive) + { + this.casesensitive = casesensitive; + } + + class Node + { + public Node(int val, string word) + { + this.word = word; + this.val = val; + } + + public string word; + public int val; + + public Node[] leaf = new Node[256]; + } + } +} diff --git a/Project/Src/Lexer/SavepointEventArgs.cs b/Project/Src/Lexer/SavepointEventArgs.cs new file mode 100644 index 0000000000..870efb41f0 --- /dev/null +++ b/Project/Src/Lexer/SavepointEventArgs.cs @@ -0,0 +1,20 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.Parser +{ + public class SavepointEventArgs : EventArgs + { + public Location SavepointLocation { get; private set; } + public LexerMemento State { get; private set; } + + public SavepointEventArgs(Location savepointLocation, LexerMemento state) + { + this.SavepointLocation = savepointLocation; + this.State = state; + } + } +} diff --git a/Project/Src/Lexer/Special/BlankLine.cs b/Project/Src/Lexer/Special/BlankLine.cs new file mode 100644 index 0000000000..5bb1473340 --- /dev/null +++ b/Project/Src/Lexer/Special/BlankLine.cs @@ -0,0 +1,19 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory +{ + public class BlankLine : AbstractSpecial + { + public BlankLine(Location point) : base(point) + { + } + + public override object AcceptVisitor(ISpecialVisitor visitor, object data) + { + return visitor.Visit(this, data); + } + } +} diff --git a/Project/Src/Lexer/Special/Comment.cs b/Project/Src/Lexer/Special/Comment.cs new file mode 100644 index 0000000000..86a9bff22d --- /dev/null +++ b/Project/Src/Lexer/Special/Comment.cs @@ -0,0 +1,59 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory +{ + public class Comment : AbstractSpecial + { + CommentType commentType; + string comment; + + public CommentType CommentType { + get { + return commentType; + } + set { + commentType = value; + } + } + + public string CommentText { + get { + return comment; + } + set { + comment = value; + } + } + + /// + /// Is true, when the comment is at line start or only whitespaces + /// between line and comment start. + /// + public bool CommentStartsLine { + get; + set; + } + + public Comment(CommentType commentType, string comment, bool commentStartsLine, Location startPosition, Location endPosition) + : base(startPosition, endPosition) + { + this.commentType = commentType; + this.comment = comment; + this.CommentStartsLine = commentStartsLine; + } + + public override string ToString() + { + return String.Format("[{0}: Type = {1}, Text = {2}, Start = {3}, End = {4}]", + GetType().Name, CommentType, CommentText, StartPosition, EndPosition); + } + + public override object AcceptVisitor(ISpecialVisitor visitor, object data) + { + return visitor.Visit(this, data); + } + } +} diff --git a/Project/Src/Lexer/Special/CommentType.cs b/Project/Src/Lexer/Special/CommentType.cs new file mode 100644 index 0000000000..7e829309d4 --- /dev/null +++ b/Project/Src/Lexer/Special/CommentType.cs @@ -0,0 +1,14 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory +{ + public enum CommentType + { + Block, + SingleLine, + Documentation + } +} diff --git a/Project/Src/Lexer/Special/ISpecial.cs b/Project/Src/Lexer/Special/ISpecial.cs new file mode 100644 index 0000000000..0e864a2cdf --- /dev/null +++ b/Project/Src/Lexer/Special/ISpecial.cs @@ -0,0 +1,52 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory +{ + /// + /// Interface for all specials. + /// + public interface ISpecial + { + Location StartPosition { get; } + Location EndPosition { get; } + + object AcceptVisitor(ISpecialVisitor visitor, object data); + } + + public interface ISpecialVisitor + { + object Visit(ISpecial special, object data); + object Visit(BlankLine special, object data); + object Visit(Comment special, object data); + object Visit(PreprocessingDirective special, object data); + } + + public abstract class AbstractSpecial : ISpecial + { + public abstract object AcceptVisitor(ISpecialVisitor visitor, object data); + + protected AbstractSpecial(Location position) + { + this.StartPosition = position; + this.EndPosition = position; + } + + protected AbstractSpecial(Location startPosition, Location endPosition) + { + this.StartPosition = startPosition; + this.EndPosition = endPosition; + } + + public Location StartPosition { get; set; } + public Location EndPosition { get; set; } + + public override string ToString() + { + return String.Format("[{0}: Start = {1}, End = {2}]", + GetType().Name, StartPosition, EndPosition); + } + } +} diff --git a/Project/Src/Lexer/Special/PreProcessingDirective.cs b/Project/Src/Lexer/Special/PreProcessingDirective.cs new file mode 100644 index 0000000000..cd20c8c8e0 --- /dev/null +++ b/Project/Src/Lexer/Special/PreProcessingDirective.cs @@ -0,0 +1,156 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory +{ + public class PreprocessingDirective : AbstractSpecial + { + #region Conversion C# <-> VB + public static void VBToCSharp(IList list) + { + for (int i = 0; i < list.Count; ++i) { + if (list[i] is PreprocessingDirective) + list[i] = VBToCSharp((PreprocessingDirective)list[i]); + } + } + + public static PreprocessingDirective VBToCSharp(PreprocessingDirective dir) + { + string cmd = dir.Cmd; + string arg = dir.Arg; + if (cmd.Equals("#End", StringComparison.InvariantCultureIgnoreCase)) { + if (arg.ToLowerInvariant().StartsWith("region")) { + cmd = "#endregion"; + arg = ""; + } else if ("if".Equals(arg, StringComparison.InvariantCultureIgnoreCase)) { + cmd = "#endif"; + arg = ""; + } + } else if (cmd.Equals("#Region", StringComparison.InvariantCultureIgnoreCase)) { + cmd = "#region"; + } else if (cmd.Equals("#If", StringComparison.InvariantCultureIgnoreCase)) { + cmd = "#if"; + if (arg.ToLowerInvariant().EndsWith(" then")) + arg = arg.Substring(0, arg.Length - 5); + } else if (cmd.Equals("#Else", StringComparison.InvariantCultureIgnoreCase)) { + if (dir.Expression != null) + cmd = "#elif"; + else + cmd = "#else"; + } else if (cmd.Equals("#ElseIf", StringComparison.InvariantCultureIgnoreCase)) { + cmd = "#elif"; + } + return new PreprocessingDirective(cmd, arg, dir.StartPosition, dir.EndPosition) { + Expression = dir.Expression + }; + } + + public static void CSharpToVB(List list) + { + for (int i = 0; i < list.Count; ++i) { + if (list[i] is PreprocessingDirective) + list[i] = CSharpToVB((PreprocessingDirective)list[i]); + } + } + + public static PreprocessingDirective CSharpToVB(PreprocessingDirective dir) + { + string cmd = dir.Cmd; + string arg = dir.Arg; + switch (cmd) { + case "#region": + cmd = "#Region"; + if (!arg.StartsWith("\"")) { + arg = "\"" + arg.Trim() + "\""; + } + break; + case "#endregion": + cmd = "#End"; + arg = "Region"; + break; + case "#endif": + cmd = "#End"; + arg = "If"; + break; + case "#if": + arg += " Then"; + break; + } + if (cmd.Length > 1) { + cmd = cmd.Substring(0, 2).ToUpperInvariant() + cmd.Substring(2); + } + return new PreprocessingDirective(cmd, arg, dir.StartPosition, dir.EndPosition) { + Expression = dir.Expression + }; + } + #endregion + + string cmd; + string arg; + Ast.Expression expression = Ast.Expression.Null; + + /// + /// Gets the directive name, including '#'. + /// + public string Cmd { + get { + return cmd; + } + set { + cmd = value ?? string.Empty; + } + } + + /// + /// Gets the directive argument. + /// + public string Arg { + get { + return arg; + } + set { + arg = value ?? string.Empty; + } + } + + /// + /// Gets/sets the expression (for directives that take an expression, e.g. #if and #elif). + /// + public Ast.Expression Expression { + get { return expression; } + set { expression = value ?? Ast.Expression.Null; } + } + + /// + /// The end position of the pre processor directive line. + /// May be != EndPosition. + /// + public Location LastLineEnd { + get; + set; + } + + + public override string ToString() + { + return String.Format("[PreProcessingDirective: Cmd = {0}, Arg = {1}]", + Cmd, + Arg); + } + + public PreprocessingDirective(string cmd, string arg, Location start, Location end) + : base(start, end) + { + this.Cmd = cmd; + this.Arg = arg; + } + + public override object AcceptVisitor(ISpecialVisitor visitor, object data) + { + return visitor.Visit(this, data); + } + } +} diff --git a/Project/Src/Lexer/Special/SpecialTracker.cs b/Project/Src/Lexer/Special/SpecialTracker.cs new file mode 100644 index 0000000000..37b7bdd404 --- /dev/null +++ b/Project/Src/Lexer/Special/SpecialTracker.cs @@ -0,0 +1,71 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.Text; + +namespace ICSharpCode.NRefactory.Parser +{ + public class SpecialTracker + { + List currentSpecials = new List(); + + CommentType currentCommentType; + StringBuilder sb = new StringBuilder(); + Location startPosition; + bool commentStartsLine; + + public List CurrentSpecials { + get { + return currentSpecials; + } + } + + /// + /// Gets the specials from the SpecialTracker and resets the lists. + /// + public List RetrieveSpecials() + { + List tmp = currentSpecials; + currentSpecials = new List(); + return tmp; + } + + public void AddEndOfLine(Location point) + { + currentSpecials.Add(new BlankLine(point)); + } + + public void AddPreprocessingDirective(PreprocessingDirective directive) + { + if (directive == null) + throw new ArgumentNullException("directive"); + currentSpecials.Add(directive); + } + + // used for comment tracking + public void StartComment(CommentType commentType, bool commentStartsLine, Location startPosition) + { + this.currentCommentType = commentType; + this.startPosition = startPosition; + this.sb.Length = 0; + this.commentStartsLine = commentStartsLine; + } + + public void AddChar(char c) + { + sb.Append(c); + } + + public void AddString(string s) + { + sb.Append(s); + } + + public void FinishComment(Location endPosition) + { + currentSpecials.Add(new Comment(currentCommentType, sb.ToString(), commentStartsLine, startPosition, endPosition)); + } + } +} diff --git a/Project/Src/Lexer/Special/TagComment.cs b/Project/Src/Lexer/Special/TagComment.cs new file mode 100644 index 0000000000..7fcea7e99e --- /dev/null +++ b/Project/Src/Lexer/Special/TagComment.cs @@ -0,0 +1,29 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory.Parser +{ + /// + /// Description of TagComment. + /// + public class TagComment : Comment + { + string tag; + + public string Tag { + get { + return tag; + } + set { + tag = value; + } + } + + public TagComment(string tag, string comment, bool commentStartsLine, Location startPosition, Location endPosition) : base(CommentType.SingleLine, comment, commentStartsLine, startPosition, endPosition) + { + this.tag = tag; + } + } +} diff --git a/Project/Src/Lexer/Token.cs b/Project/Src/Lexer/Token.cs new file mode 100644 index 0000000000..4ce27da0f4 --- /dev/null +++ b/Project/Src/Lexer/Token.cs @@ -0,0 +1,112 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory.Parser +{ + public enum LiteralFormat : byte + { + None, + DecimalNumber, + HexadecimalNumber, + OctalNumber, + StringLiteral, + VerbatimStringLiteral, + CharLiteral, + DateTimeLiteral + } + + public class Token + { + internal readonly int kind; + + internal readonly int col; + internal readonly int line; + + internal readonly LiteralFormat literalFormat; + internal readonly object literalValue; + internal readonly string val; + internal Token next; + readonly Location endLocation; + + public int Kind { + get { return kind; } + } + + public LiteralFormat LiteralFormat { + get { return literalFormat; } + } + + public object LiteralValue { + get { return literalValue; } + } + + public string Value { + get { return val; } + } + + public Location EndLocation { + get { return endLocation; } + } + + public Location Location { + get { + return new Location(col, line); + } + } + + public Token(int kind, int col, int line) : this (kind, col, line, null) + { + } + + public Token(int kind, Location startLocation, Location endLocation) : this(kind, startLocation, endLocation, "", null, LiteralFormat.None) + { + } + + public Token(int kind, int col, int line, string val) + { + this.kind = kind; + this.col = col; + this.line = line; + this.val = val; + this.endLocation = new Location(col + (val == null ? 1 : val.Length), line); + } + + internal Token(int kind, int x, int y, string val, object literalValue, LiteralFormat literalFormat) + : this(kind, new Location(x, y), new Location(x + val.Length, y), val, literalValue, literalFormat) + { + } + + public Token(int kind, Location startLocation, Location endLocation, string val, object literalValue, LiteralFormat literalFormat) + { + this.kind = kind; + this.col = startLocation.Column; + this.line = startLocation.Line; + this.endLocation = endLocation; + this.val = val; + this.literalValue = literalValue; + this.literalFormat = literalFormat; + } + + public override string ToString() + { + string csharpToken, vbToken; + + try { + csharpToken = CSharp.Tokens.GetTokenString(kind); + } catch (NotSupportedException) { + csharpToken = ""; + } + + try { + vbToken = VB.Tokens.GetTokenString(kind); + } catch (NotSupportedException) { + vbToken = ""; + } + + return string.Format("[C# {0}/VB {1} Location={2} EndLocation={3} val={4}]", + csharpToken, vbToken, Location, EndLocation, val); + } + } +} diff --git a/Project/Src/Lexer/VBNet/Block.cs b/Project/Src/Lexer/VBNet/Block.cs new file mode 100644 index 0000000000..2faf53dbb8 --- /dev/null +++ b/Project/Src/Lexer/VBNet/Block.cs @@ -0,0 +1,57 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ICSharpCode.NRefactory.Parser.VB +{ + public enum Context + { + Global, + TypeDeclaration, + ObjectCreation, + ObjectInitializer, + CollectionInitializer, + Type, + Member, + Parameter, + Identifier, + Body, + Xml, + Attribute, + Importable, + Query, + Expression, + Debug, + Default + } + + public class Block : ICloneable + { + public static readonly Block Default = new Block() { + context = Context.Global, + lastExpressionStart = Location.Empty + }; + + public Context context; + public Location lastExpressionStart; + public bool isClosed; + + public override string ToString() + { + return string.Format("[Block Context={0}, LastExpressionStart={1}, IsClosed={2}]", context, lastExpressionStart, isClosed); + } + + public object Clone() + { + return new Block() { + context = this.context, + lastExpressionStart = this.lastExpressionStart, + isClosed = this.isClosed + }; + } + } +} diff --git a/Project/Src/Lexer/VBNet/ExpressionFinder.atg b/Project/Src/Lexer/VBNet/ExpressionFinder.atg new file mode 100644 index 0000000000..f4c218cd3f --- /dev/null +++ b/Project/Src/Lexer/VBNet/ExpressionFinder.atg @@ -0,0 +1,1377 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +PUSHCOMPILER WITH EXPECTEDSETS ExpressionFinder + +/* START AUTOGENERATED TOKENS SECTION */ +TOKENS + /* ----- terminal classes ----- */ + /* EOF is 0 */ + EOL + ident + LiteralString + LiteralCharacter + LiteralInteger + LiteralDouble + LiteralSingle + LiteralDecimal + LiteralDate + XmlOpenTag + XmlCloseTag + XmlStartInlineVB + XmlEndInlineVB + XmlCloseTagEmptyElement + XmlOpenEndTag + XmlContent + XmlComment + XmlCData + XmlProcessingInstruction + + /* ----- special character ----- */ + "=" + ":" + "," + "&" + "/" + "\\" + "." + "..." + ".@" + "!" + "-" + "+" + "^" + "?" + "*" + "{" + "}" + "(" + ")" + ">" + "<" + "<>" + ">=" + "<=" + "<<" + ">>" + "+=" + "^=" + "-=" + "*=" + "/=" + "\\=" + "<<=" + ">>=" + "&=" + ":=" + + /* ----- keywords ----- */ + "AddHandler" + "AddressOf" + "Aggregate" + "Alias" + "And" + "AndAlso" + "Ansi" + "As" + "Ascending" + "Assembly" + "Auto" + "Binary" + "Boolean" + "ByRef" + "By" + "Byte" + "ByVal" + "Call" + "Case" + "Catch" + "CBool" + "CByte" + "CChar" + "CDate" + "CDbl" + "CDec" + "Char" + "CInt" + "Class" + "CLng" + "CObj" + "Compare" + "Const" + "Continue" + "CSByte" + "CShort" + "CSng" + "CStr" + "CType" + "CUInt" + "CULng" + "CUShort" + "Custom" + "Date" + "Decimal" + "Declare" + "Default" + "Delegate" + "Descending" + "Dim" + "DirectCast" + "Distinct" + "Do" + "Double" + "Each" + "Else" + "ElseIf" + "End" + "EndIf" + "Enum" + "Equals" + "Erase" + "Error" + "Event" + "Exit" + "Explicit" + "False" + "Finally" + "For" + "Friend" + "From" + "Function" + "Get" + "GetType" + "Global" + "GoSub" + "GoTo" + "Group" + "Handles" + "If" + "Implements" + "Imports" + "In" + "Infer" + "Inherits" + "Integer" + "Interface" + "Into" + "Is" + "IsNot" + "Join" + "Key" + "Let" + "Lib" + "Like" + "Long" + "Loop" + "Me" + "Mod" + "Module" + "MustInherit" + "MustOverride" + "MyBase" + "MyClass" + "Namespace" + "Narrowing" + "New" + "Next" + "Not" + "Nothing" + "NotInheritable" + "NotOverridable" + "Object" + "Of" + "Off" + "On" + "Operator" + "Option" + "Optional" + "Or" + "Order" + "OrElse" + "Out" + "Overloads" + "Overridable" + "Overrides" + "ParamArray" + "Partial" + "Preserve" + "Private" + "Property" + "Protected" + "Public" + "RaiseEvent" + "ReadOnly" + "ReDim" + "Rem" + "RemoveHandler" + "Resume" + "Return" + "SByte" + "Select" + "Set" + "Shadows" + "Shared" + "Short" + "Single" + "Skip" + "Static" + "Step" + "Stop" + "Strict" + "String" + "Structure" + "Sub" + "SyncLock" + "Take" + "Text" + "Then" + "Throw" + "To" + "True" + "Try" + "TryCast" + "TypeOf" + "UInteger" + "ULong" + "Unicode" + "Until" + "UShort" + "Using" + "Variant" + "Wend" + "When" + "Where" + "While" + "Widening" + "With" + "WithEvents" + "WriteOnly" + "Xor" + "GetXmlNamespace" +/* END AUTOGENERATED TOKENS SECTION */ + +PRODUCTIONS +/*------------------------------------------------------------------------*/ +ExpressionFinder = + (. PushContext(Context.Global, la, t); .) + { OptionStatement } + { ImportsStatement } + { EXPECTEDCONFLICT("<") AttributeBlock } /* Expected LL(1) conflict: we can't tell global attributes */ + /* from those on types. */ + /* This isn't a problem, we can just treat all as global attributes */ + { NamespaceMemberDeclaration } + (. PopContext(); .) +. + +StatementTerminator + (. if (la != null) CurrentBlock.lastExpressionStart = la.Location; .) += + EOL | ":" +. + +OptionStatement = + "Option" ( ( "Explicit" | "Strict" | "Infer" ) [ "Off" | "On" ] | "Compare" ( "Text" | "Binary" ) ) StatementTerminator +. + +ImportsStatement = + "Imports" (. PushContext(Context.Importable, la, t); .) + (. nextTokenIsStartOfImportsOrAccessExpression = true; .) + ( + ( "Global" | Identifier | PrimitiveTypeName ) { TypeSuffix } [ ( "." | "=" ) TypeName ] + | XmlOpenTag Identifier "=" LiteralString XmlCloseTag + ) + (. PopContext(); .) + StatementTerminator +. + +AttributeBlock = + "<" (. wasNormalAttribute = true; PushContext(Context.Attribute, la, t); .) + Attribute { "," Attribute } + ">" (. PopContext(); .) [ EOL ] +. + +Attribute = + [ EXPECTEDCONFLICT("Assembly") ( "Assembly" | "Module" ) ":" (. wasNormalAttribute = false; .) ] + // TypeName already contains an argument list production + TypeName +. + +NamespaceMemberDeclaration = + NamespaceDeclaration + | TypeDeclaration +. + +NamespaceDeclaration = + "Namespace" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) { ANY } (. PopContext(); .) StatementTerminator + { NamespaceMemberDeclaration } + "End" "Namespace" StatementTerminator +. + +TypeDeclaration = + { AttributeBlock } + { TypeModifier } + ( ClassOrModuleOrStructureTypeDeclaration | + DelegateTypeDeclaration | + EnumTypeDeclaration | + InterfaceDeclaration ) +. + +ClassOrModuleOrStructureTypeDeclaration = + (. PushContext(Context.TypeDeclaration, la, t); .) + ( "Module" | "Class" | "Structure" ) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) + [ "(" "Of" GenericTypeParameterDeclaration ")" ] StatementTerminator + [ (. isMissingModifier = false; .) "Inherits" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) StatementTerminator ] + [ (. isMissingModifier = false; .) "Implements" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) { "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) } StatementTerminator ] + { + { AttributeBlock } (.OnEachPossiblePath: isMissingModifier = true; .) + { TypeOrMemberModifier (. isMissingModifier = false; .) } (. isMissingModifier = false; .) + ( ClassOrModuleOrStructureTypeDeclaration | DelegateTypeDeclaration | EnumTypeDeclaration + | InterfaceDeclaration | MemberDeclaration ) + } + (. isMissingModifier = false; .) + "End" ( "Module" | "Class" | "Structure" ) StatementTerminator + (. PopContext(); .) +. + +EnumTypeDeclaration = + (. PushContext(Context.TypeDeclaration, la, t); .) + "Enum" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) + [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] StatementTerminator + { + { AttributeBlock } + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) + [ "=" Expression ] + StatementTerminator + } + "End" "Enum" StatementTerminator + (. PopContext(); .) +. + +InterfaceDeclaration = + (. PushContext(Context.TypeDeclaration, la, t); .) + "Interface" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) + [ "(" "Of" GenericTypeParameterDeclaration ")" ] StatementTerminator + [ "Inherits" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) { "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) } StatementTerminator ] + { + { AttributeBlock } (.OnEachPossiblePath: isMissingModifier = true; .) + { TypeOrMemberModifier (. isMissingModifier = false; .) } (. isMissingModifier = false; .) + ( ClassOrModuleOrStructureTypeDeclaration | DelegateTypeDeclaration | EnumTypeDeclaration + | InterfaceDeclaration | InterfaceMemberDeclaration ) + } + (. isMissingModifier = false; .) + "End" "Interface" StatementTerminator + (. PopContext(); .) +. + +InterfaceMemberDeclaration = + InterfaceEvent | InterfaceProperty | InterfaceSubOrFunction +. + +TypeOrMemberModifier = + MemberModifier /* contains all modifiers for types */ +. + +InterfaceEvent = + "Event" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) + [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | ParameterListInParenthesis ] + StatementTerminator +. + +InterfaceProperty = + "Property" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) + [ ParameterListInParenthesis ] [ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } TypeName (. PopContext(); .) ] + StatementTerminator +. + +InterfaceSubOrFunction = + ("Sub" | "Function") + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .) + { "(" [ ( "Of" GenericTypeParameterDeclaration | ParameterList ) ] ")" } + [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] + StatementTerminator +. + +GenericConstraint = + TypeName | "New" | "Class" | "Structure" +. + +GenericConstraintList = + GenericConstraint | "{" GenericConstraint { "," GenericConstraint } "}" +. + +GenericTypeParameterDeclaration = + [ "Out" | "In" ] (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) IdentifierExceptOut (. PopContext(); .) [ "As" (. PushContext(Context.Type, la, t); .) GenericConstraintList (. PopContext(); .) ] + { "," [ "Out" | "In" ] (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) IdentifierExceptOut (. PopContext(); .) [ "As" (. PushContext(Context.Type, la, t); .) GenericConstraintList (. PopContext(); .) ] } +. + +DelegateTypeDeclaration = + "Delegate" ("Sub" | "Function") + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .) + { "(" [ "Of" GenericTypeParameterDeclaration | ParameterList ] ")" } + [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] + StatementTerminator +. + +MemberDeclaration = + (. PushContext(Context.Member, la, t); .) + ( + MemberVariableOrConstantDeclaration | + SubOrFunctionDeclaration | + ExternalMemberDeclaration | + EventMemberDeclaration | + CustomEventMemberDeclaration | + PropertyDeclaration | + OperatorDeclaration + ) + (. PopContext(); .) +. + +SubOrFunctionDeclaration = + ("Sub" | "Function") + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .) + { "(" [ ( "Of" GenericTypeParameterDeclaration | ParameterList ) ] ")" } + [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] + [ ( "Implements" | "Handles" ) [ ( "Me" | "MyClass" | "MyBase" ) "." ] TypeName ] + StatementTerminatorAndBlock + "End" ("Sub" | "Function") StatementTerminator +. + +ExternalMemberDeclaration = + "Declare" [ "Ansi" | "Unicode" | "Auto" ] ( "Sub" | "Function" ) + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) + "Lib" LiteralString + [ "Alias" LiteralString ] + [ ParameterListInParenthesis ] + [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] + StatementTerminator +. + +EventMemberDeclaration = + "Event" + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) + ( "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | [ ParameterListInParenthesis ] ) + [ "Implements" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ + { "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ } ] + /* the TypeName production already allows the "." IdentifierOrKeyword syntax, so to avoid an ambiguous grammar we just leave that out */ + StatementTerminator +. + +CustomEventMemberDeclaration = + "Custom" EventMemberDeclaration + { + { AttributeBlock } ( "AddHandler" | "RemoveHandler" | "RaiseEvent" ) "(" ParameterList ")" + StatementTerminatorAndBlock + "End" ( "AddHandler" | "RemoveHandler" | "RaiseEvent" ) StatementTerminator + } + "End" "Event" StatementTerminator +. + +PropertyDeclaration = + "Property" + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) + [ ParameterListInParenthesis ] + [ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } ( NewExpression | TypeName ) (. PopContext(); .) ] + [ "Implements" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ + { "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ } ] + [ "=" Expression ] StatementTerminator + (. PopContext(); .) { EXPECTEDCONFLICT("<") AttributeBlock } + { EXPECTEDCONFLICT("Public", "Protected", "Private", "Friend") AccessModifier + // HACK : OnEachPossiblePath cannot detect that this might be the end of an auto property + // so we need to simulate it + (.OnEachPossiblePath: SetIdentifierExpected(la); .) } + [ (. PushContext(Context.Member, la, t); .) + ( "Get" | "Set" ) [ ParameterListInParenthesis ] + StatementTerminatorAndBlock + "End" ( "Get" | "Set" ) StatementTerminator + [ { AttributeBlock } { AccessModifier } ( "Get" | "Set" ) [ ParameterListInParenthesis ] + StatementTerminatorAndBlock + "End" ( "Get" | "Set" ) StatementTerminator ] + + "End" "Property" StatementTerminator ] +. + +OperatorDeclaration = + "Operator" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .) + "(" ParameterList ")" + [ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } TypeName (. PopContext(); .) ] + StatementTerminatorAndBlock + "End" "Operator" StatementTerminator +. + +MemberVariableOrConstantDeclaration = + MemberVariableOrConstantDeclarator { "," MemberVariableOrConstantDeclarator } StatementTerminator +. + +MemberVariableOrConstantDeclarator = + [ "Const" ] + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) IdentifierForFieldDeclaration (. PopContext(); .) + [ "?" ] { "(" [ Expression ] { "," [ Expression ] } ")" } + [ "As" (. PushContext(Context.Type, la, t); .) ( NewExpression | TypeName ) (. PopContext(); .) ] + [ "=" Expression ] +. + +ParameterList = + Parameter { "," Parameter } +. + +Parameter = + (. PushContext(Context.Parameter, la, t); .) + { AttributeBlock } { ParameterModifier } + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) + [ "?" ] { "(" { "," } ")" } + [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] + [ "=" Expression ] + (. PopContext(); .) +. + +StatementTerminatorAndBlock + (.NamedState:startOfBlock.) += + (. PushContext(Context.Body, la, t); .) + StatementTerminator + { EXPECTEDCONFLICT("End") + ( + [ Statement] StatementTerminator + | "End" + ( StatementTerminator /* End+StatementTerminator is end statement */ + | /* End+anything else is the end of this block. */ + (. + currentState = endOfStatementTerminatorAndBlock; /* leave this block */ + InformToken(t); /* process End again*/ + /* for processing current token (la): go to the position after processing End */ + goto switchlbl; + .) + ANY /* never reached due to goto above: */ + /* this ANY is just so that Coco knows this branch isn't empty */ + ) + ) + } + (.NamedState:endOfStatementTerminatorAndBlock.) + (. PopContext(); .) +. + +Expression + (.NamedState:startOfExpression.) += + (. PushContext(Context.Expression, la, t); .) + SimpleExpressionWithSuffix { BinaryOperator SimpleExpressionWithSuffix } + (. PopContext(); .) +. + +BinaryOperator = + "+" | "-" | "*" | "\\" | "/" | "^" | "Mod" + | "=" | "<>" | "<" | ">" (. wasNormalAttribute = false; .) | "<=" | ">=" + | "Like" | "&" | "And" | "AndAlso" | "Or" | "OrElse" + | "Xor" | "<<" | ">>" | "Is" | "IsNot" + | "^=" | "*=" | "/=" | "\\=" | "+=" | "-=" | "&=" | "<<=" | ">>=" | "To" | ":=" +. + +UnaryOperator = + "+" | "-" | "Not" | "AddressOf" +. + +SimpleExpressionWithSuffix = + (. PushContext(Context.Expression, la, t); .) + { UnaryOperator } + ( + SimpleExpression { ExpressionSuffix } + | "TypeOf" SimpleExpressionWithSuffix "Is" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) + | NewExpression + | CollectionInitializer + ) + (. PopContext(); .) +. + +SimpleExpression = + (. PushContext(Context.Expression, la, t); .) + ( Literal + | ( "(" (. activeArgument = 0; .) Expression // HACK in ExpressionRangeVariable Identifier is consumed before start + // of Expression so this can be an argument list too + { "," (. activeArgument++; .) Expression } ")" ) + | IdentifierForExpressionStart + | PrimitiveTypeName + | ( "." | "!" | ".@" | "..." ) (. nextTokenIsStartOfImportsOrAccessExpression = true; wasQualifierTokenAtStart = true; .) [ XmlOpenTag ] IdentifierOrKeyword [ XmlCloseTag ] + | "GetType" "(" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ")" + | "GetXmlNamespace" "(" (. readXmlIdentifier = true; .) Identifier ")" + | XmlLiteral + | LambdaExpression + | GREEDY QueryExpression + | CastExpression + | ConditionalExpression + ) + (. PopContext(); .) +. + +NewExpression = + "New" (. PushContext(Context.ObjectCreation, la, t); .) + ( + TypeName + [ + EXPECTEDCONFLICT("From") + ( + (. PushContext(Context.CollectionInitializer, la, t); .) + "From" + ( + CollectionInitializer /* From + CollectionInitializer is a NewExpression */ + | + (. + currentState = endOfStatementTerminatorAndBlock; /* leave this block */ + InformToken(t); /* process From again*/ + /* for processing current token (la): go to the position after processing End */ + goto switchlbl; + .) + ANY /* never reached due to goto above: */ + /* this ANY is just so that Coco knows this branch isn't empty */ + ) + (. PopContext(); .) + | + /* handle array initializer after New */ + (. PushContext(Context.CollectionInitializer, la, t); .) + CollectionInitializer + (. PopContext(); .) + | + (. PushContext(Context.ObjectInitializer, la, t); .) + "With" ObjectInitializer + (. PopContext(); .) + ) + ] + | + (. PushContext(Context.ObjectInitializer, la, t); .) + "With" ObjectInitializer + (. PopContext(); .) + ) + (. PopContext(); .) +. + +ObjectInitializer = + "{" [ [ "Key" ] "." IdentifierOrKeyword "=" Expression { "," [ "Key" ] "." IdentifierOrKeyword "=" Expression } ] "}" +. + +CollectionInitializer = + "{" [ Expression { "," Expression } ] "}" +. + +ExpressionSuffix = + "(" (. PushContext(Context.Expression, la, t); .) + ( "Of" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) + { "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) } + | [ ArgumentList ] ) (. PopContext(); .) ")" +| ( "." | "!" | ".@" | "..." ) (. nextTokenIsStartOfImportsOrAccessExpression = true; .) [ XmlOpenTag ] IdentifierOrKeyword [ XmlCloseTag ] +. + +CastExpression = + SimpleCastExpression | ("DirectCast" | "TryCast" | "CType") "(" Expression "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ")" +. + +SimpleCastExpression = + ( + "CBool" | + "CByte" | + "CChar" | + "CDate" | + "CDec" | + "CDbl" | + "CInt" | + "CLng" | + "CObj" | + "CSByte" | + "CShort" | + "CSng" | + "CStr" | + "CUInt" | + "CULng" | + "CUShort" + ) + "(" Expression ")" +. + +ConditionalExpression = + "If" "(" Expression "," Expression [ "," Expression ] ")" +. + +LambdaExpression = + SubLambdaExpression | + FunctionLambdaExpression +. + +SubLambdaExpression = + "Sub" ParameterListInParenthesis + ( GREEDY Statement | StatementTerminatorAndBlock "End" "Sub" ) +. + +FunctionLambdaExpression = + "Function" ParameterListInParenthesis + ( GREEDY Expression | [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] StatementTerminatorAndBlock "End" "Function" ) +. + +ParameterListInParenthesis = + "(" (. PushContext(Context.Default, la, t); .) [ ParameterList ] (. PopContext(); .) ")" +. + +QueryExpression + (. PushContext(Context.Query, la, t); .) += + ( FromQueryOperator | AggregateQueryOperator ) + { QueryOperator } + (. PopContext(); .) +. + +QueryOperator = + FromQueryOperator + | AggregateQueryOperator + | SelectQueryOperator + | DistinctQueryOperator + | WhereQueryOperator + | OrderByQueryOperator + | PartitionQueryOperator + | LetQueryOperator + | GroupByOrGroupJoinQueryOperator + | JoinQueryOperator +. + +FromQueryOperator = + "From" CollectionRangeVariable { "," CollectionRangeVariable } +. + +AggregateQueryOperator = + "Aggregate" CollectionRangeVariable { QueryOperator } "Into" ExpressionRangeVariable { "," ExpressionRangeVariable } +. + +SelectQueryOperator = + "Select" ExpressionRangeVariable { "," ExpressionRangeVariable } +. + +DistinctQueryOperator = + "Distinct" +. + +WhereQueryOperator = + "Where" Expression +. + +OrderByQueryOperator = + "Order" "By" Expression ( "Ascending" | "Descending" ) { "," Expression ( "Ascending" | "Descending" ) } +. + +PartitionQueryOperator = + ( "Take" | "Skip" ) [ "While" ] Expression +. + +LetQueryOperator = + "Let" ExpressionRangeVariable { "," ExpressionRangeVariable } +. + +GroupByOrGroupJoinQueryOperator = + "Group" + ( + EXPECTEDCONFLICT("Join") + JoinQueryOperator { ( "Group" JoinQueryOperator GroupJoinSuffix | JoinQueryOperator ) } + GroupJoinSuffix + | + ( EXPECTEDCONFLICT("By") () | ExpressionRangeVariable { "," ExpressionRangeVariable } ) + "By" ExpressionRangeVariable { "," ExpressionRangeVariable } + "Into" ExpressionRangeVariable { "," ExpressionRangeVariable } + ) +. + +JoinQueryOperator = + "Join" CollectionRangeVariable + "On" Expression "Equals" Expression { "," Expression "Equals" Expression } +. + +GroupJoinSuffix = + "Into" ExpressionRangeVariable { "," ExpressionRangeVariable } +. + +ExpressionRangeVariable = + [ + EXPECTEDCONFLICT("Where", "Until", "Unicode", "Text", "Take", "Skip", "Preserve", + "Order", "Off", "Out", "Key", "Join", "Into", "Infer", "Group", "From", + "Explicit", "Equals", "Distinct", "Descending", "Compare", "By", + "Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident) + ( + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier + // HACK: needs to be optional because Expression can start with Identifier too + [ (. PopContext(); isAlreadyInExpr = true; .) + ( "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) "=" + | "=" + | (. + currentState = endOfStatementTerminatorAndBlock; /* leave this block */ + InformToken(t); /* process Identifier again*/ + /* for processing current token (la): go to the position after processing End */ + goto switchlbl; + .) + ANY /* never reached due to goto above: */ + /* this ANY is just so that Coco knows this branch isn't empty */ + ) + ] + ) + ] + Expression + (. if (!isAlreadyInExpr) PopContext(); isAlreadyInExpr = false; .) +. + +CollectionRangeVariable = + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) + [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] + "In" Expression +. + +/* semantic action will be inserted on all paths that possibly lead to XmlLiteral */ +XmlLiteral + (.OnEachPossiblePath: nextTokenIsPotentialStartOfExpression = true; .) += + (. PushContext(Context.Xml, la, t); .) + ( + ( XmlComment | XmlProcessingInstruction | XmlCData ) [ XmlContent ] { ( XmlComment | XmlProcessingInstruction ) [ XmlContent ] } [ XmlElement { XmlComment [ XmlContent ] } ] + | + XmlElement { XmlComment [ XmlContent ] } + ) + (. PopContext(); .) +. + +XmlElement = + (. PushContext(Context.Xml, la, t); .) + XmlOpenTag { ANY | XmlEmbeddedExpression } ( XmlCloseTagEmptyElement | XmlCloseTag { ANY | XmlEmbeddedExpression | XmlElement } XmlOpenEndTag { ANY | XmlEmbeddedExpression } XmlCloseTag ) + (. PopContext(); .) +. + +XmlEmbeddedExpression = + XmlStartInlineVB Expression XmlEndInlineVB +. + +PrimitiveTypeName = + "Byte" | + "SByte" | + "UShort" | + "Short" | + "UInteger" | + "Integer" | + "ULong" | + "Long" | + "Single" | + "Double" | + "Decimal" | + "Boolean" | + "Date" | + "Char" | + "String" | + "Object" +. + +TypeName = ( "Global" | Identifier | PrimitiveTypeName | "?" /* used for ? = completion */ ) { TypeSuffix } { "." IdentifierOrKeyword { TypeSuffix } } . + +TypeSuffix = "?" | "(" (. PushContext(Context.Expression, la, t); .) ( "Of" [ (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] { "," [ (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] } | [ ArgumentList ] ) (. PopContext(); .) ")" . + +IdentifierOrKeyword = ident +| "AddHandler" +| "AddressOf" +| "Aggregate" +| "Alias" +| "And" +| "AndAlso" +| "Ansi" +| "As" +| "Ascending" +| "Assembly" +| "Auto" +| "Binary" +| "Boolean" +| "ByRef" +| "By" +| "Byte" +| "ByVal" +| "Call" +| "Case" +| "Catch" +| "CBool" +| "CByte" +| "CChar" +| "CDate" +| "CDbl" +| "CDec" +| "Char" +| "CInt" +| "Class" +| "CLng" +| "CObj" +| "Compare" +| "Const" +| "Continue" +| "CSByte" +| "CShort" +| "CSng" +| "CStr" +| "CType" +| "CUInt" +| "CULng" +| "CUShort" +| "Custom" +| "Date" +| "Decimal" +| "Declare" +| "Default" +| "Delegate" +| "Descending" +| "Dim" +| "DirectCast" +| "Distinct" +| "Do" +| "Double" +| "Each" +| "Else" +| "ElseIf" +| "End" +| "EndIf" +| "Enum" +| "Equals" +| "Erase" +| "Error" +| "Event" +| "Exit" +| "Explicit" +| "False" +| "Finally" +| "For" +| "Friend" +| "From" +| "Function" +| "Get" +| "GetType" +| "Global" +| "GoSub" +| "GoTo" +| "Group" +| "Handles" +| "If" +| "Implements" +| "Imports" +| "In" +| "Infer" +| "Inherits" +| "Integer" +| "Interface" +| "Into" +| "Is" +| "IsNot" +| "Join" +| "Key" +| "Let" +| "Lib" +| "Like" +| "Long" +| "Loop" +| "Me" +| "Mod" +| "Module" +| "MustInherit" +| "MustOverride" +| "MyBase" +| "MyClass" +| "Namespace" +| "Narrowing" +| "New" +| "Next" +| "Not" +| "Nothing" +| "NotInheritable" +| "NotOverridable" +| "Object" +| "Of" +| "Off" +| "On" +| "Operator" +| "Option" +| "Optional" +| "Or" +| "Order" +| "OrElse" +| "Out" +| "Overloads" +| "Overridable" +| "Overrides" +| "ParamArray" +| "Partial" +| "Preserve" +| "Private" +| "Property" +| "Protected" +| "Public" +| "RaiseEvent" +| "ReadOnly" +| "ReDim" +| "Rem" +| "RemoveHandler" +| "Resume" +| "Return" +| "SByte" +| "Select" +| "Set" +| "Shadows" +| "Shared" +| "Short" +| "Single" +| "Skip" +| "Static" +| "Step" +| "Stop" +| "Strict" +| "String" +| "Structure" +| "Sub" +| "SyncLock" +| "Take" +| "Text" +| "Then" +| "Throw" +| "To" +| "True" +| "Try" +| "TryCast" +| "TypeOf" +| "UInteger" +| "ULong" +| "Unicode" +| "Until" +| "UShort" +| "Using" +| "Variant" +| "Wend" +| "When" +| "Where" +| "While" +| "Widening" +| "With" +| "WithEvents" +| "WriteOnly" +| "Xor" +| "GetXmlNamespace" +. + +Literal = + LiteralString | + LiteralCharacter | + LiteralInteger | + LiteralDouble | + LiteralSingle | + LiteralDecimal | + LiteralDate | + "True" | + "False" | + "Nothing" | + /* from InstanceExpression */ + "Me" | + "MyBase" | + "MyClass" +. + +Statement = + VariableDeclarationStatement + | WithOrLockStatement + | AddOrRemoveHandlerStatement + | RaiseEventStatement + | EXPECTEDCONFLICT("If") IfStatement /* prefer if-statement to if-expression */ + | SelectStatement + | WhileStatement + | DoLoopStatement + | ForStatement + | ErrorHandlingStatement + | ThrowStatement + | TryStatement + | BranchStatement + | ReDimStatement + | EraseStatement + | UsingStatement + | InvocationStatement +. + +VariableDeclarationStatement = + ( "Dim" | "Static" | "Const" ) + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) + Identifier (. PopContext(); .) [ "?" ] { "(" [ Expression ] { "," [ Expression ] } ")" } + [ "As" (. PushContext(Context.Type, la, t); .) ( NewExpression | TypeName ) (. PopContext(); .) ] + [ "=" Expression ] + { "," + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) + Identifier (. PopContext(); .) [ "?" ] { "(" [ Expression ] { "," [ Expression ] } ")" } + [ "As" (. PushContext(Context.Type, la, t); .) ( NewExpression | TypeName ) (. PopContext(); .) ] + [ "=" Expression ] + } +. + +WithOrLockStatement = + ( "With" | "SyncLock" ) Expression StatementTerminatorAndBlock "End" ( "With" | "SyncLock" ) +. + +AddOrRemoveHandlerStatement = + ( "AddHandler" | "RemoveHandler" ) Expression "," Expression +. + +RaiseEventStatement = + "RaiseEvent" IdentifierOrKeyword [ "(" (. PushContext(Context.Expression, la, t); .) [ ArgumentList ] (. PopContext(); .) ")" ] +. + +IfStatement = + "If" Expression + ( "Then" + ( Statement { EXPECTEDCONFLICT(":") ":" [Statement] } [ EXPECTEDCONFLICT("Else") "Else" [Statement] { EXPECTEDCONFLICT(":") ":" [Statement] } ] + | MultilineIfRemainder + ) + | MultilineIfRemainder + ) +. + +MultilineIfRemainder = + StatementTerminatorAndBlock + { + ("Else" [ "If" Expression [ "Then" ] ] + | "ElseIf" Expression [ "Then" ] + ) + StatementTerminatorAndBlock + } + "End" "If" +. + +SelectStatement = + "Select" [ "Case" ] Expression StatementTerminator + { + "Case" ( + "Else" | + ( [ "Is" ] ComparisonOperator SimpleExpressionWithSuffix | Expression ) + { "," ( [ "Is" ] ComparisonOperator SimpleExpressionWithSuffix | Expression ) } + ) + StatementTerminatorAndBlock + } + "End" "Select" +. + +ComparisonOperator = + "=" | "<>" | "<" | ">" (. wasNormalAttribute = false; .) | ">=" | "<=" +. + +WhileStatement = + "While" Expression StatementTerminatorAndBlock "End" "While" +. + +DoLoopStatement = + "Do" ( DoTopLoopStatement | DoBottomLoopStatement ) +. + +DoTopLoopStatement = + ( "While" | "Until" ) Expression + StatementTerminatorAndBlock + "Loop" +. + +DoBottomLoopStatement = + StatementTerminatorAndBlock + "Loop" [ ( "While" | "Until" ) Expression ] +. + +ForStatement = + "For" ( ForLoopStatement | ForEachLoopStatement ) +. + +ForLoopStatement = + ForLoopVariable "=" Expression /* "To" is binary operator */ [ "Step" Expression ] + StatementTerminatorAndBlock + "Next" [ Expression { "," Expression } ] +. + +ForEachLoopStatement = + "Each" ForLoopVariable "In" Expression + StatementTerminatorAndBlock + "Next" [ Expression { "," Expression } ] +. + +ForLoopVariable = + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) SimpleExpression (. PopContext(); .) + [ "?" ] { ExpressionSuffix } + [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] +. + +ErrorHandlingStatement = + [ "On" ] "Error" ( Expression | "GoTo" ( LiteralInteger | Identifier ) | "Resume" "Next" ) + | "Resume" ( "Next" | LiteralInteger | Identifier ) +. + +ThrowStatement = + "Throw" [ Expression ] +. + +TryStatement = + "Try" + StatementTerminatorAndBlock + { + "Catch" + [ (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) + [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] + ] + [ "When" Expression ] + StatementTerminatorAndBlock + } + [ + "Finally" + StatementTerminatorAndBlock + ] + "End" "Try" +. + +BranchStatement = + "GoTo" ( Identifier | LiteralInteger ) + | "Exit" ( "Do" | "For" | "While" | "Select" | "Sub" | "Function" | "Property" | "Try" ) + | "Continue" ( "Do" | "For" | "While" ) + | "Stop" + /*| "End" HACK End-Statements has special handling in Block */ + | "Return" (. PushContext(Context.Expression, la, t); .) [ Expression ] (. PopContext(); .) +. + +ReDimStatement = + "ReDim" + [ EXPECTEDCONFLICT("Preserve") "Preserve" ] /* Preserve is context-dependend keyword */ + Expression +. + +EraseStatement = + "Erase" Expression { "," Expression } +. + +UsingVariable = + [ + EXPECTEDCONFLICT("Where", "Until", "Unicode", "Text", "Take", "Skip", "Preserve", + "Order", "Off", "Out", "Key", "Join", "Into", "Infer", "Group", "From", + "Explicit", "Equals", "Distinct", "Descending", "Compare", "By", + "Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident) + ( + (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier + // HACK: needs to be optional because Expression can start with Identifier too + [ (. PopContext(); isAlreadyInExpr = true; .) + ( "As" [ EXPECTEDCONFLICT("Where", "UShort", "Until", "Unicode", "ULong", "UInteger", "Text", "Take", + "String", "Skip", "Single", "Short", "SByte", "Preserve", "Out", "Order", + "Off", "Object", "Long", "Key", "Join", "Into", "Integer", "Infer", "Group", + "From", "Explicit", "Equals", "Double", "Distinct", "Descending", "Decimal", + "Date", "Compare", "Char", "Byte", "By", "Boolean", "Binary", "Binary", "Auto", + "Assembly", "Ascending", "Ansi", "Aggregate", ident) + (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) "=" ] + | "=" + | (. + currentState = endOfStatementTerminatorAndBlock; /* leave this block */ + InformToken(t); /* process Identifier again*/ + /* for processing current token (la): go to the position after processing End */ + goto switchlbl; + .) + ANY /* never reached due to goto above: */ + /* this ANY is just so that Coco knows this branch isn't empty */ + ) + ] + ) + ] + Expression + (. if (!isAlreadyInExpr) PopContext(); isAlreadyInExpr = false; .) +. + +UsingStatement = + "Using" UsingVariable { "," UsingVariable } + StatementTerminatorAndBlock + "End" "Using" +. + +InvocationStatement = + [ "Call" ] Expression +. + +ArgumentList = + (. activeArgument = 0; .) Expression { "," (. activeArgument++; .) [ Expression ] } +| (. activeArgument = 0; .) "," (. activeArgument++; .) [ Expression ] { "," (. activeArgument++; .) [ Expression ] } +. + +/* This production handles pseudo keywords that are needed in the grammar */ +Identifier = + IdentifierForFieldDeclaration + | "Custom" +. + +IdentifierForFieldDeclaration = + IdentifierForExpressionStart + | "Aggregate" + | "From" +. + +IdentifierForExpressionStart = + IdentifierExceptOut + | "Out" +. + +IdentifierExceptOut = + ident + | "Ansi" + | "Ascending" + | "Assembly" + | "Auto" + | "Binary" + | "By" + | "Compare" + | "Descending" + | "Distinct" + | "Equals" + | "Explicit" + | "Group" + | "Infer" + | "Into" + | "Join" + | "Key" + | "Off" + | "Order" + | "Preserve" + | "Skip" + | "Take" + | "Text" + | "Unicode" + | "Until" + | "Where" +. + +AccessModifier = + "Public" | + "Friend" | + "Protected" | + "Private" +. + +TypeModifier = + AccessModifier | + "MustInherit" | + "NotInheritable" | + "Shadows" | + "Partial" +. + +MemberModifier = + AccessModifier | + "Shadows" | + "Shared" | + "Overridable" | + "NotOverridable" | + "NotInheritable" | + "Overrides" | + "Overloads" | + "Partial" | + "WithEvents" | + "MustOverride" | + "Widening" | + "Narrowing" | + "ReadOnly" | + "WriteOnly" | + "Default" | + "Dim" +. + +ParameterModifier = + "ByVal" | + "ByRef" | + "Optional" | + "ParamArray" +. + +END ExpressionFinder . diff --git a/Project/Src/Lexer/VBNet/ExpressionFinder.cs b/Project/Src/Lexer/VBNet/ExpressionFinder.cs new file mode 100644 index 0000000000..1649eb2c50 --- /dev/null +++ b/Project/Src/Lexer/VBNet/ExpressionFinder.cs @@ -0,0 +1,157 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ICSharpCode.NRefactory.Parser.VB +{ + public partial class ExpressionFinder + { + Stack stack = new Stack(); + StringBuilder output = new StringBuilder(); + + void PopContext() + { + if (stack.Any()) { + string indent = new string('\t', stack.Count - 1); + var item = stack.Pop(); + item.isClosed = true; + Print(indent + "exit " + item.context); + } else { + Print("empty stack"); + } + } + + void PushContext(Context context, Token la, Token t) + { + string indent = new string('\t', stack.Count); + Location l = la == null ? (t == null ? Location.Empty : t.EndLocation) : la.Location; + + stack.Push(new Block() { context = context, lastExpressionStart = l }); + Print(indent + "enter " + context); + } + + public ExpressionFinder(ExpressionFinderState state) + { + wasQualifierTokenAtStart = state.WasQualifierTokenAtStart; + nextTokenIsPotentialStartOfExpression = state.NextTokenIsPotentialStartOfExpression; + nextTokenIsStartOfImportsOrAccessExpression = state.NextTokenIsStartOfImportsOrAccessExpression; + readXmlIdentifier = state.ReadXmlIdentifier; + identifierExpected = state.IdentifierExpected; + stateStack = new Stack(state.StateStack.Reverse()); + stack = new Stack(state.BlockStack.Select(x => (Block)x.Clone()).Reverse()); + currentState = state.CurrentState; + output = new StringBuilder(); + } + + void Print(string text) + { + //Console.WriteLine(text); + output.AppendLine(text); + } + + public void SetContext(SnippetType type) + { + switch (type) { + case SnippetType.Expression: + currentState = startOfExpression; + break; + case SnippetType.Statements: + currentState = startOfBlock; + break; + } + + Advance(); + } + + public string Output { + get { return output.ToString(); } + } + + public string Stacktrace { + get { + string text = ""; + + foreach (Block b in stack) { + text += b.ToString() + "\n"; + } + + return text; + } + } + + public Block CurrentBlock { + get { return stack.Any() ? stack.Peek() : Block.Default; } + } + + public bool IsIdentifierExpected { + get { return identifierExpected; } + } + + void SetIdentifierExpected(Token la) + { + identifierExpected = true; + if (la != null) + CurrentBlock.lastExpressionStart = la.Location; + else if (t != null) + CurrentBlock.lastExpressionStart = t.EndLocation; + } + + public bool InContext(Context expected) + { + return stack + .SkipWhile(f => f.context == Context.Expression) + .IsElement(fx => fx.context == expected); + } + + public bool NextTokenIsPotentialStartOfExpression { + get { return nextTokenIsPotentialStartOfExpression; } + } + + public bool ReadXmlIdentifier { + get { return readXmlIdentifier; } + set { readXmlIdentifier = value; } + } + + public bool NextTokenIsStartOfImportsOrAccessExpression { + get { return nextTokenIsStartOfImportsOrAccessExpression; } + } + + public bool WasQualifierTokenAtStart { + get { return wasQualifierTokenAtStart; } + } + + public bool IsMissingModifier { + get { return isMissingModifier; } + } + + public bool WasNormalAttribute { + get { return wasNormalAttribute; } + } + + public int ActiveArgument { + get { return activeArgument; } + } + + public List Errors { + get { return errors; } + } + + public ExpressionFinderState Export() + { + return new ExpressionFinderState() { + WasQualifierTokenAtStart = wasQualifierTokenAtStart, + NextTokenIsPotentialStartOfExpression = nextTokenIsPotentialStartOfExpression, + NextTokenIsStartOfImportsOrAccessExpression = nextTokenIsStartOfImportsOrAccessExpression, + ReadXmlIdentifier = readXmlIdentifier, + IdentifierExpected = identifierExpected, + StateStack = new Stack(stateStack.Reverse()), + BlockStack = new Stack(stack.Select(x => (Block)x.Clone()).Reverse()), + CurrentState = currentState + }; + } + } +} diff --git a/Project/Src/Lexer/VBNet/ExpressionFinderState.cs b/Project/Src/Lexer/VBNet/ExpressionFinderState.cs new file mode 100644 index 0000000000..6b72f9f3e5 --- /dev/null +++ b/Project/Src/Lexer/VBNet/ExpressionFinderState.cs @@ -0,0 +1,22 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ICSharpCode.NRefactory.Parser.VB +{ + public class ExpressionFinderState + { + public bool WasQualifierTokenAtStart { get; set; } + public bool NextTokenIsPotentialStartOfExpression { get; set; } + public bool ReadXmlIdentifier { get; set; } + public bool IdentifierExpected { get; set; } + public bool NextTokenIsStartOfImportsOrAccessExpression { get; set; } + public Stack StateStack { get; set; } + public Stack BlockStack { get; set; } + public int CurrentState { get; set; } + } +} diff --git a/Project/Src/Lexer/VBNet/Extensions.cs b/Project/Src/Lexer/VBNet/Extensions.cs new file mode 100644 index 0000000000..1e8c26d79a --- /dev/null +++ b/Project/Src/Lexer/VBNet/Extensions.cs @@ -0,0 +1,22 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ICSharpCode.NRefactory.Parser.VB +{ + public static class Extensions + { + public static bool IsElement(this IEnumerable items, Func check) + { + T item = items.FirstOrDefault(); + + if (item != null) + return check(item); + return false; + } + } +} diff --git a/Project/Src/Lexer/VBNet/KeywordList.txt b/Project/Src/Lexer/VBNet/KeywordList.txt new file mode 100644 index 0000000000..dee2aab408 --- /dev/null +++ b/Project/Src/Lexer/VBNet/KeywordList.txt @@ -0,0 +1,284 @@ +# this list is used for autogeneration of: +# - Keywords.cs +# - Tokens.cs +# - ATGTokensSection.txt - the TOKENS section of the ATG file + +# use BuildKeywords to generate the different lists. + +$Namespace=ICSharpCode.NRefactory.Parser.VB +$UpperCaseKeywords=True + +# TERMINAL_CLASSES +EOF +EOL +Identifier +LiteralString +LiteralCharacter +LiteralInteger +LiteralDouble +LiteralSingle +LiteralDecimal +LiteralDate + +# XML_TERMINALS +XmlOpenTag +XmlCloseTag +XmlStartInlineVB +XmlEndInlineVB +XmlCloseTagEmptyElement +XmlOpenEndTag +XmlContent +XmlComment +XmlCData +XmlProcessingInstruction + +# SPECIAL_CHARACTERS +Assign = "=" +Colon =":" +Comma = "," +ConcatString = "&" +Div ="/" +DivInteger = "\\" +Dot = "." +TripleDot = "..." +DotAt = ".@" +# Exclamation mark = Dictionary access operator (not always a token, sometimes it's a type character) +ExclamationMark = "!" +Minus = "-" +Plus = "+" +Power = "^" +QuestionMark = "?" +Times = "*" + +OpenCurlyBrace = "{" +CloseCurlyBrace = "}" + +OpenParenthesis = "(" +CloseParenthesis = ")" + +GreaterThan = ">" +LessThan = "<" + +NotEqual = "<>" +GreaterEqual = ">=" +LessEqual = "<=" + +ShiftLeft = "<<" +ShiftRight = ">>" + +PlusAssign = "+=" +PowerAssign = "^=" +MinusAssign = "-=" +TimesAssign = "*=" +DivAssign = "/=" +DivIntegerAssign = "\\=" +ShiftLeftAssign = "<<=" +ShiftRightAssign = ">>=" +ConcatStringAssign = "&=" +ColonAssign = ":=" + +# keywords according to the spec: +# Keywordlist +"AddHandler" +"AddressOf" +"Aggregate" +"Alias" +"And" +"AndAlso" +"Ansi" +"As" +"Ascending" +"Assembly" +"Auto" +"Binary" +"Boolean" +"ByRef" +"By" +"Byte" +"ByVal" +"Call" +"Case" +"Catch" +"CBool" +"CByte" +"CChar" +"CDate" +"CDbl" +"CDec" +"Char" +"CInt" +"Class" +"CLng" +"CObj" +"Compare" +"Const" +"Continue" +"CSByte" +"CShort" +"CSng" +"CStr" +"CType" +"CUInt" +"CULng" +"CUShort" +"Custom" +"Date" +"Decimal" +"Declare" +"Default" +"Delegate" +"Descending" +"Dim" +"DirectCast" +"Distinct" +"Do" +"Double" +"Each" +"Else" +"ElseIf" +"End" +"EndIf" +"Enum" +"Equals" +"Erase" +"Error" +"Event" +"Exit" +"Explicit" +"False" +"Finally" +"For" +"Friend" +"From" +"Function" +"Get" +"GetType" +"Global" +"GoSub" +"GoTo" +"Group" +"Handles" +"If" +"Implements" +"Imports" +"In" +"Infer" +"Inherits" +"Integer" +"Interface" +"Into" +"Is" +"IsNot" +# Note: IsTrue and IsFalse are 'NOT' keywords they're only valid in Operator declarations (like get/set/value are no C# 'keywords') +"Join" +"Key" +"Let" +"Lib" +"Like" +"Long" +"Loop" +"Me" +"Mod" +"Module" +"MustInherit" +"MustOverride" +"MyBase" +"MyClass" +"Namespace" +"Narrowing" +"New" +"Next" +"Not" +"Nothing" +"NotInheritable" +"NotOverridable" +"Object" +"Of" +"Off" +"On" +"Operator" +"Option" +"Optional" +"Or" +"Order" +"OrElse" +"Out" +"Overloads" +"Overridable" +"Overrides" +"ParamArray" +"Partial" +"Preserve" +"Private" +"Property" +"Protected" +"Public" +"RaiseEvent" +"ReadOnly" +"ReDim" +# has to be in the keyword list for the output formatter +"Rem" +"RemoveHandler" +"Resume" +"Return" +"SByte" +"Select" +"Set" +"Shadows" +"Shared" +"Short" +"Single" +"Skip" +"Static" +"Step" +"Stop" +"Strict" +"String" +"Structure" +"Sub" +"SyncLock" +"Take" +"Text" +"Then" +"Throw" +"To" +"True" +"Try" +"TryCast" +"TypeOf" +"UInteger" +"ULong" +"Unicode" +"Until" +"UShort" +"Using" +"Variant" +"Wend" +"When" +"Where" +"While" +"Widening" +"With" +"WithEvents" +"WriteOnly" +"Xor" + +#XML specific keywords +"GetXmlNamespace" + +#Sets +Null("Nothing") +BlockSucc("Case", "Catch", "Else", "ElseIf", "End", "Finally", "Loop", "Next") +GlobalLevel("Namespace", "Module", "Class", "Structure", "Imports", "Option") +TypeLevel("Sub", "Function", "Property") + +# List of keywords that are valid identifiers, must be the same as the "Identifier" production in VBNET.ATG +IdentifierTokens("Text", "Binary", "Compare", "Assembly", "Ansi", "Auto", "Preserve", "Unicode", "Until", "Off", "Out", "Key", "Explicit", "Infer", "From", "Join", "Equals", "Distinct", "Where", "Take", "Skip", "Order", "By", "Ascending", "Descending", "Group", "Into", "Aggregate") +ExpressionStart("Me", "MyBase", "MyClass", @BooleanExpressions, @OperatorsAtStart, "New", @Null, "AddressOf", "GetType", "TypeOf", "GetXmlNamespace", "Global", @TypeKW, @LambdaStart, @CastExpressions) +StatementStart(@Null, @ExpressionStart, "Dim", "Const", "Static", "For", "While", "Do", "Select") +SimpleTypeName(@TypeKW, @IdentifierTokens) +CastExpressions("DirectCast", "TryCast", "CType", "CBool", "CByte", "CChar", "CDate", "CDec", "CDbl", "CInt", "CLng", "CObj", "CSByte", "CShort", "CSng", "CStr", "CUInt", "CULng", "CUShort") +BooleanExpressions("True", "False") +LambdaStart("Sub", "Function") +OperatorsAtStart("Not", "From", "Aggregate") +TypeKW("Boolean", "Date", "Char", "String", "Decimal", "Byte", "Short", "Integer", "Long", "Single", "Double", "UInteger", "ULong", "UShort", "SByte") \ No newline at end of file diff --git a/Project/Src/Lexer/VBNet/Keywords.cs b/Project/Src/Lexer/VBNet/Keywords.cs new file mode 100644 index 0000000000..248eb4b8ec --- /dev/null +++ b/Project/Src/Lexer/VBNet/Keywords.cs @@ -0,0 +1,218 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +// this file was autogenerated by a tool. +using System; + +namespace ICSharpCode.NRefactory.Parser.VB +{ + public static class Keywords + { + static readonly string[] keywordList = { + "ADDHANDLER", + "ADDRESSOF", + "AGGREGATE", + "ALIAS", + "AND", + "ANDALSO", + "ANSI", + "AS", + "ASCENDING", + "ASSEMBLY", + "AUTO", + "BINARY", + "BOOLEAN", + "BYREF", + "BY", + "BYTE", + "BYVAL", + "CALL", + "CASE", + "CATCH", + "CBOOL", + "CBYTE", + "CCHAR", + "CDATE", + "CDBL", + "CDEC", + "CHAR", + "CINT", + "CLASS", + "CLNG", + "COBJ", + "COMPARE", + "CONST", + "CONTINUE", + "CSBYTE", + "CSHORT", + "CSNG", + "CSTR", + "CTYPE", + "CUINT", + "CULNG", + "CUSHORT", + "CUSTOM", + "DATE", + "DECIMAL", + "DECLARE", + "DEFAULT", + "DELEGATE", + "DESCENDING", + "DIM", + "DIRECTCAST", + "DISTINCT", + "DO", + "DOUBLE", + "EACH", + "ELSE", + "ELSEIF", + "END", + "ENDIF", + "ENUM", + "EQUALS", + "ERASE", + "ERROR", + "EVENT", + "EXIT", + "EXPLICIT", + "FALSE", + "FINALLY", + "FOR", + "FRIEND", + "FROM", + "FUNCTION", + "GET", + "GETTYPE", + "GLOBAL", + "GOSUB", + "GOTO", + "GROUP", + "HANDLES", + "IF", + "IMPLEMENTS", + "IMPORTS", + "IN", + "INFER", + "INHERITS", + "INTEGER", + "INTERFACE", + "INTO", + "IS", + "ISNOT", + "JOIN", + "KEY", + "LET", + "LIB", + "LIKE", + "LONG", + "LOOP", + "ME", + "MOD", + "MODULE", + "MUSTINHERIT", + "MUSTOVERRIDE", + "MYBASE", + "MYCLASS", + "NAMESPACE", + "NARROWING", + "NEW", + "NEXT", + "NOT", + "NOTHING", + "NOTINHERITABLE", + "NOTOVERRIDABLE", + "OBJECT", + "OF", + "OFF", + "ON", + "OPERATOR", + "OPTION", + "OPTIONAL", + "OR", + "ORDER", + "ORELSE", + "OUT", + "OVERLOADS", + "OVERRIDABLE", + "OVERRIDES", + "PARAMARRAY", + "PARTIAL", + "PRESERVE", + "PRIVATE", + "PROPERTY", + "PROTECTED", + "PUBLIC", + "RAISEEVENT", + "READONLY", + "REDIM", + "REM", + "REMOVEHANDLER", + "RESUME", + "RETURN", + "SBYTE", + "SELECT", + "SET", + "SHADOWS", + "SHARED", + "SHORT", + "SINGLE", + "SKIP", + "STATIC", + "STEP", + "STOP", + "STRICT", + "STRING", + "STRUCTURE", + "SUB", + "SYNCLOCK", + "TAKE", + "TEXT", + "THEN", + "THROW", + "TO", + "TRUE", + "TRY", + "TRYCAST", + "TYPEOF", + "UINTEGER", + "ULONG", + "UNICODE", + "UNTIL", + "USHORT", + "USING", + "VARIANT", + "WEND", + "WHEN", + "WHERE", + "WHILE", + "WIDENING", + "WITH", + "WITHEVENTS", + "WRITEONLY", + "XOR", + "GETXMLNAMESPACE" + }; + + static LookupTable keywords = new LookupTable(false); + + static Keywords() + { + for (int i = 0; i < keywordList.Length; ++i) { + keywords[keywordList[i]] = i + Tokens.AddHandler; + } + } + + public static int GetToken(string keyword) + { + return keywords[keyword]; + } + + public static bool IsNonIdentifierKeyword(string word) + { + int token = GetToken(word); + if (token < 0) + return false; + return !Tokens.IdentifierTokens[token]; + } + } +} diff --git a/Project/Src/Lexer/VBNet/Lexer.cs b/Project/Src/Lexer/VBNet/Lexer.cs new file mode 100644 index 0000000000..84d72f4534 --- /dev/null +++ b/Project/Src/Lexer/VBNet/Lexer.cs @@ -0,0 +1,1169 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Xml; + +namespace ICSharpCode.NRefactory.Parser.VB +{ + internal sealed class Lexer : AbstractLexer + { + bool lineEnd = true; + bool isAtLineBegin = false; // TODO: handle line begin, if neccessarry + bool misreadExclamationMarkAsTypeCharacter; + bool encounteredLineContinuation; + + ExpressionFinder ef; + + bool inXmlMode; + + Stack xmlModeStack = new Stack(); + + public Lexer(TextReader reader) : base(reader) + { + ef = new ExpressionFinder(); + } + + public Lexer(TextReader reader, LexerMemento state) : base(reader, state) + { + if (!(state is VBLexerMemento)) + throw new InvalidOperationException("state must be a VBLexerState"); + + var vbState = state as VBLexerMemento; + ef = new ExpressionFinder(vbState.ExpressionFinder); + lineEnd = vbState.LineEnd; + isAtLineBegin = vbState.IsAtLineBegin; + encounteredLineContinuation = vbState.EncounteredLineContinuation; + misreadExclamationMarkAsTypeCharacter = vbState.MisreadExclamationMarkAsTypeCharacter; + xmlModeStack = new Stack(vbState.XmlModeInfoStack.Select(i => (XmlModeInfo)i.Clone()).Reverse()); + inXmlMode = vbState.InXmlMode; + } + + Token NextInternal() + { + if (misreadExclamationMarkAsTypeCharacter) { + misreadExclamationMarkAsTypeCharacter = false; + return new Token(Tokens.ExclamationMark, Col - 1, Line); + } + + unchecked { + while (true) { + Location startLocation = new Location(Col, Line); + int nextChar = ReaderRead(); + if (nextChar == -1) + return new Token(Tokens.EOF, Col, Line, string.Empty); + char ch = (char)nextChar; + #region XML mode + CheckXMLState(startLocation); + if (inXmlMode && xmlModeStack.Peek().level <= 0 && !xmlModeStack.Peek().isDocumentStart && !xmlModeStack.Peek().inXmlTag) { + XmlModeInfo info = xmlModeStack.Peek(); + int peek = nextChar; + while (true) { + int step = -1; + while (peek != -1 && XmlConvert.IsWhitespaceChar((char)peek)) { + step++; + peek = ReaderPeek(step); + } + + if (peek == '<' && (ReaderPeek(step + 1) == '!' || ReaderPeek(step + 1) == '?')) { + char lastCh = '\0'; + for (int i = 0; i < step + 2; i++) + lastCh = (char)ReaderRead(); + + if (lastCh == '!') + return ReadXmlCommentOrCData(Col - 2, Line); + else + return ReadXmlProcessingInstruction(Col - 2, Line); + } + + break; + } + inXmlMode = false; + xmlModeStack.Pop(); + } + if (inXmlMode) { + XmlModeInfo info = xmlModeStack.Peek(); + int x = Col - 1; + int y = Line; + switch (ch) { + case '<': + if (ReaderPeek() == '/') { + ReaderRead(); + info.inXmlCloseTag = true; + return new Token(Tokens.XmlOpenEndTag, new Location(x, y), new Location(Col, Line)); + } + if (ReaderPeek() == '%' && ReaderPeek(1) == '=') { + inXmlMode = false; + ReaderRead(); ReaderRead(); + return new Token(Tokens.XmlStartInlineVB, new Location(x, y), new Location(Col, Line)); + } + if (ReaderPeek() == '?') { + ReaderRead(); + Token t = ReadXmlProcessingInstruction(x, y); + return t; + } + if (ReaderPeek() == '!') { + ReaderRead(); + Token token = ReadXmlCommentOrCData(x, y); + return token; + } + info.level++; + info.isDocumentStart = false; + info.inXmlTag = true; + return new Token(Tokens.XmlOpenTag, x, y); + case '/': + if (ReaderPeek() == '>') { + ReaderRead(); + info.inXmlTag = false; + info.level--; + return new Token(Tokens.XmlCloseTagEmptyElement, new Location(x, y), new Location(Col, Line)); + } + break; + case '>': + if (info.inXmlCloseTag) + info.level--; + info.inXmlTag = info.inXmlCloseTag = false; + return new Token(Tokens.XmlCloseTag, x, y); + case '=': + return new Token(Tokens.Assign, x, y); + case '\'': + case '"': + string s = ReadXmlString(ch); + return new Token(Tokens.LiteralString, x, y, ch + s + ch, s, LiteralFormat.StringLiteral); + default: + if (info.inXmlCloseTag || info.inXmlTag) { + if (XmlConvert.IsWhitespaceChar(ch)) + continue; + return new Token(Tokens.Identifier, x, y, ReadXmlIdent(ch)); + } else { + string content = ReadXmlContent(ch); + return new Token(Tokens.XmlContent, startLocation, new Location(Col, Line), content, null, LiteralFormat.None); + } + } + #endregion + } else { + #region Standard Mode + if (Char.IsWhiteSpace(ch)) { + if (HandleLineEnd(ch)) { + if (lineEnd) { + // second line end before getting to a token + // -> here was a blank line + specialTracker.AddEndOfLine(startLocation); + } else { + lineEnd = true; + return new Token(Tokens.EOL, startLocation, new Location(Col, Line), null, null, LiteralFormat.None); + } + } + continue; + } + if (ch == '_') { + if (ReaderPeek() == -1) { + errors.Error(Line, Col, String.Format("No EOF expected after _")); + return new Token(Tokens.EOF, Col, Line, string.Empty); + } + if (!Char.IsWhiteSpace((char)ReaderPeek())) { + int x = Col - 1; + int y = Line; + string s = ReadIdent('_'); + lineEnd = false; + return new Token(Tokens.Identifier, x, y, s); + } + encounteredLineContinuation = true; + ch = (char)ReaderRead(); + + bool oldLineEnd = lineEnd; + lineEnd = false; + while (Char.IsWhiteSpace(ch)) { + if (HandleLineEnd(ch)) { + lineEnd = true; + break; + } + if (ReaderPeek() != -1) { + ch = (char)ReaderRead(); + } else { + errors.Error(Line, Col, String.Format("No EOF expected after _")); + return new Token(Tokens.EOF, Col, Line, string.Empty); + } + } + if (!lineEnd) { + errors.Error(Line, Col, String.Format("NewLine expected")); + } + lineEnd = oldLineEnd; + continue; + } + + if (ch == '#') { + while (Char.IsWhiteSpace((char)ReaderPeek())) { + ReaderRead(); + } + if (Char.IsDigit((char)ReaderPeek())) { + int x = Col - 1; + int y = Line; + string s = ReadDate(); + DateTime time = new DateTime(1, 1, 1, 0, 0, 0); + try { + time = DateTime.Parse(s, System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault); + } catch (Exception e) { + errors.Error(Line, Col, String.Format("Invalid date time {0}", e)); + } + return new Token(Tokens.LiteralDate, x, y, s, time, LiteralFormat.DateTimeLiteral); + } else { + ReadPreprocessorDirective(); + continue; + } + } + + if (ch == '[') { // Identifier + lineEnd = false; + if (ReaderPeek() == -1) { + errors.Error(Line, Col, String.Format("Identifier expected")); + } + ch = (char)ReaderRead(); + if (ch == ']' || Char.IsWhiteSpace(ch)) { + errors.Error(Line, Col, String.Format("Identifier expected")); + } + int x = Col - 1; + int y = Line; + string s = ReadIdent(ch); + if (ReaderPeek() == -1) { + errors.Error(Line, Col, String.Format("']' expected")); + } + ch = (char)ReaderRead(); + if (!(ch == ']')) { + errors.Error(Line, Col, String.Format("']' expected")); + } + return new Token(Tokens.Identifier, x, y, s); + } + if (Char.IsLetter(ch)) { + int x = Col - 1; + int y = Line; + char typeCharacter; + string s = ReadIdent(ch, out typeCharacter); + if (typeCharacter == '\0') { + int keyWordToken = Keywords.GetToken(s); + if (keyWordToken >= 0) { + // handle 'REM' comments + if (keyWordToken == Tokens.Rem) { + ReadComment(); + if (!lineEnd) { + lineEnd = true; + return new Token(Tokens.EOL, Col, Line, "\n"); + } + continue; + } + + lineEnd = false; + return new Token(keyWordToken, x, y, s); + } + } + + lineEnd = false; + return new Token(Tokens.Identifier, x, y, s); + + } + if (Char.IsDigit(ch)) { + lineEnd = false; + return ReadDigit(ch, Col - 1); + } + if (ch == '&') { + lineEnd = false; + if (ReaderPeek() == -1) { + return ReadOperator('&'); + } + ch = (char)ReaderPeek(); + if (Char.ToUpper(ch, CultureInfo.InvariantCulture) == 'H' || Char.ToUpper(ch, CultureInfo.InvariantCulture) == 'O') { + return ReadDigit('&', Col - 1); + } + return ReadOperator('&'); + } + if (ch == '\'' || ch == '\u2018' || ch == '\u2019') { + int x = Col - 1; + int y = Line; + ReadComment(); + if (!lineEnd) { + lineEnd = true; + return new Token(Tokens.EOL, x, y, "\n"); + } + continue; + } + if (ch == '"') { + lineEnd = false; + int x = Col - 1; + int y = Line; + string s = ReadString(); + if (ReaderPeek() != -1 && (ReaderPeek() == 'C' || ReaderPeek() == 'c')) { + ReaderRead(); + if (s.Length != 1) { + errors.Error(Line, Col, String.Format("Chars can only have Length 1 ")); + } + if (s.Length == 0) { + s = "\0"; + } + return new Token(Tokens.LiteralCharacter, x, y, '"' + s + "\"C", s[0], LiteralFormat.CharLiteral); + } + return new Token(Tokens.LiteralString, x, y, '"' + s + '"', s, LiteralFormat.StringLiteral); + } + if (ch == '%' && ReaderPeek() == '>') { + int x = Col - 1; + int y = Line; + inXmlMode = true; + ReaderRead(); + return new Token(Tokens.XmlEndInlineVB, new Location(x, y), new Location(Col, Line)); + } + #endregion + if (ch == '<' && (ef.NextTokenIsPotentialStartOfExpression || ef.NextTokenIsStartOfImportsOrAccessExpression)) { + xmlModeStack.Push(new XmlModeInfo(ef.NextTokenIsStartOfImportsOrAccessExpression)); + XmlModeInfo info = xmlModeStack.Peek(); + int x = Col - 1; + int y = Line; + inXmlMode = true; + if (ReaderPeek() == '/') { + ReaderRead(); + info.inXmlCloseTag = true; + return new Token(Tokens.XmlOpenEndTag, new Location(x, y), new Location(Col, Line)); + } + // should we allow <%= at start of an expression? not valid with vbc ... + if (ReaderPeek() == '%' && ReaderPeek(1) == '=') { + inXmlMode = false; + ReaderRead(); ReaderRead(); + return new Token(Tokens.XmlStartInlineVB, new Location(x, y), new Location(Col, Line)); + } + if (ReaderPeek() == '!') { + ReaderRead(); + Token t = ReadXmlCommentOrCData(x, y); + return t; + } + if (ReaderPeek() == '?') { + ReaderRead(); + Token t = ReadXmlProcessingInstruction(x, y); + info.isDocumentStart = t.val.Trim().StartsWith("xml", StringComparison.OrdinalIgnoreCase); + return t; + } + info.inXmlTag = true; + info.level++; + return new Token(Tokens.XmlOpenTag, x, y); + } + Token token = ReadOperator(ch); + if (token != null) { + lineEnd = false; + return token; + } + } + + errors.Error(Line, Col, String.Format("Unknown char({0}) which can't be read", ch)); + } + } + } + + void CheckXMLState(Location startLocation) + { + if (inXmlMode && !xmlModeStack.Any()) + throw new InvalidOperationException("invalid XML stack state at " + startLocation); + } + + Token prevToken; + + protected override Token Next() + { + Token t = NextInternal(); + if (t.kind == Tokens.EOL) { + Debug.Assert(t.next == null); // NextInternal() must return only 1 token + t.next = NextInternal(); + Debug.Assert(t.next.next == null); + if (SkipEOL(prevToken.kind, t.next.kind)) { + t = t.next; + } + } else + encounteredLineContinuation = false; + // inform EF only once we're sure it's really a token + // this means we inform it about EOL tokens "1 token too late", but that's not a problem because + // XML literals cannot start immediately after an EOL token + ef.InformToken(t); + if (t.next != null) { + // Next() isn't called again when it returns 2 tokens, so we need to process both tokens + ef.InformToken(t.next); + prevToken = t.next; + } else { + prevToken = t; + } + ef.Advance(); + Debug.Assert(t != null); + return t; + } + + /// see VB language specification 10; pg. 6 + bool SkipEOL(int prevTokenKind, int nextTokenKind) + { + // exception directly after _ + if (encounteredLineContinuation) { + return encounteredLineContinuation = false; + } + + // 1st rule + // after a comma (,), open parenthesis ((), open curly brace ({), or open embedded expression (<%=) + if (new[] { Tokens.Comma, Tokens.OpenParenthesis, Tokens.OpenCurlyBrace, Tokens.XmlStartInlineVB } + .Contains(prevTokenKind)) + return true; + + // 2nd rule + // after a member qualifier (. or .@ or ...), provided that something is being qualified (i.e. is not + // using an implicit With context) + if (new[] { Tokens.Dot, Tokens.DotAt, Tokens.TripleDot }.Contains(prevTokenKind) + && !ef.WasQualifierTokenAtStart) + return true; + + // 3rd rule + // before a close parenthesis ()), close curly brace (}), or close embedded expression (%>) + if (new[] { Tokens.CloseParenthesis, Tokens.CloseCurlyBrace, Tokens.XmlEndInlineVB } + .Contains(nextTokenKind)) + return true; + + // 4th rule + // after a less-than (<) in an attribute context + if (prevTokenKind == Tokens.LessThan && ef.InContext(Context.Attribute)) + return true; + + // 5th rule + // before a greater-than (>) in an attribute context + if (nextTokenKind == Tokens.GreaterThan && ef.InContext(Context.Attribute)) + return true; + + // 6th rule + // after a greater-than (>) in a non-file-level attribute context + if (ef.WasNormalAttribute && prevTokenKind == Tokens.GreaterThan) + return true; + + // 7th rule + // before and after query operators (Where, Order, Select, etc.) + var queryOperators = new int[] { Tokens.From, Tokens.Aggregate, Tokens.Select, Tokens.Distinct, + Tokens.Where, Tokens.Order, Tokens.By, Tokens.Ascending, Tokens.Descending, Tokens.Take, + Tokens.Skip, Tokens.Let, Tokens.Group, Tokens.Into, Tokens.On, Tokens.While, Tokens.Join }; + if (ef.InContext(Context.Query)) { + // Ascending, Descending, Distinct are special + // fixes http://community.sharpdevelop.net/forums/p/12068/32893.aspx#32893 + var specialQueryOperators = new int[] { Tokens.Ascending, Tokens.Descending, Tokens.Distinct }; + if (specialQueryOperators.Contains(prevTokenKind) && !queryOperators.Contains(nextTokenKind)) + return false; + + if ((queryOperators.Contains(prevTokenKind) || queryOperators.Contains(nextTokenKind))) + return true; + } + + // 8th rule + // after binary operators (+, -, /, *, etc.) in an expression context + if (new[] { Tokens.Plus, Tokens.Minus, Tokens.Div, Tokens.DivInteger, Tokens.Times, Tokens.Mod, Tokens.Power, + Tokens.Assign, Tokens.NotEqual, Tokens.LessThan, Tokens.LessEqual, Tokens.GreaterThan, Tokens.GreaterEqual, + Tokens.Like, Tokens.ConcatString, Tokens.AndAlso, Tokens.OrElse, Tokens.And, Tokens.Or, Tokens.Xor, + Tokens.ShiftLeft, Tokens.ShiftRight }.Contains(prevTokenKind) && ef.CurrentBlock.context == Context.Expression) + return true; + + // 9th rule + // after assignment operators (=, :=, +=, -=, etc.) in any context. + if (new[] { Tokens.Assign, Tokens.ColonAssign, Tokens.ConcatStringAssign, Tokens.DivAssign, + Tokens.DivIntegerAssign, Tokens.MinusAssign, Tokens.PlusAssign, Tokens.PowerAssign, + Tokens.ShiftLeftAssign, Tokens.ShiftRightAssign, Tokens.TimesAssign }.Contains(prevTokenKind)) + return true; + + return false; + } + + public override Token NextToken() + { + if (curToken == null) { // first call of NextToken() + curToken = Next(); + //Console.WriteLine("Tok:" + Tokens.GetTokenString(curToken.kind) + " --- " + curToken.val); + return curToken; + } + + lastToken = curToken; + + if (curToken.next == null) { + curToken.next = Next(); + } + + curToken = curToken.next; + + if (curToken.kind == Tokens.EOF && !(lastToken.kind == Tokens.EOL)) { // be sure that before EOF there is an EOL token + curToken = new Token(Tokens.EOL, curToken.col, curToken.line, string.Empty); + curToken.next = new Token(Tokens.EOF, curToken.col, curToken.line, string.Empty); + } + //Console.WriteLine("Tok:" + Tokens.GetTokenString(curToken.kind) + " --- " + curToken.val); + return curToken; + } + + #region VB Readers + string ReadIdent(char ch) + { + char typeCharacter; + return ReadIdent(ch, out typeCharacter); + } + + string ReadIdent(char ch, out char typeCharacter) + { + typeCharacter = '\0'; + + if (ef.ReadXmlIdentifier) { + ef.ReadXmlIdentifier = false; + return ReadXmlIdent(ch); + } + + sb.Length = 0; + sb.Append(ch); + int peek; + while ((peek = ReaderPeek()) != -1 && (Char.IsLetterOrDigit(ch = (char)peek) || ch == '_')) { + ReaderRead(); + sb.Append(ch.ToString()); + } + if (peek == -1) { + return sb.ToString(); + } + + if ("%&@!#$".IndexOf((char)peek) != -1) { + typeCharacter = (char)peek; + ReaderRead(); + if (typeCharacter == '!') { + peek = ReaderPeek(); + if (peek != -1 && (peek == '_' || peek == '[' || char.IsLetter((char)peek))) { + misreadExclamationMarkAsTypeCharacter = true; + } + } + } + return sb.ToString(); + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1818:DoNotConcatenateStringsInsideLoops")] + Token ReadDigit(char ch, int x) + { + sb.Length = 0; + sb.Append(ch); + + int y = Line; + string digit = ""; + if (ch != '&') { + digit += ch; + } + + bool isHex = false; + bool isOct = false; + bool isSingle = false; + bool isDouble = false; + bool isDecimal = false; + + if (ReaderPeek() == -1) { + if (ch == '&') { + errors.Error(Line, Col, String.Format("digit expected")); + } + return new Token(Tokens.LiteralInteger, x, y, sb.ToString() ,ch - '0', LiteralFormat.DecimalNumber); + } + if (ch == '.') { + if (Char.IsDigit((char)ReaderPeek())) { + isDouble = true; // double is default + if (isHex || isOct) { + errors.Error(Line, Col, String.Format("No hexadecimal or oktadecimal floating point values allowed")); + } + while (ReaderPeek() != -1 && Char.IsDigit((char)ReaderPeek())){ // read decimal digits beyond the dot + digit += (char)ReaderRead(); + } + } + } else if (ch == '&' && PeekUpperChar() == 'H') { + const string hex = "0123456789ABCDEF"; + sb.Append((char)ReaderRead()); // skip 'H' + while (ReaderPeek() != -1 && hex.IndexOf(PeekUpperChar()) != -1) { + ch = (char)ReaderRead(); + sb.Append(ch); + digit += Char.ToUpper(ch, CultureInfo.InvariantCulture); + } + isHex = true; + } else if (ReaderPeek() != -1 && ch == '&' && PeekUpperChar() == 'O') { + const string okt = "01234567"; + sb.Append((char)ReaderRead()); // skip 'O' + while (ReaderPeek() != -1 && okt.IndexOf(PeekUpperChar()) != -1) { + ch = (char)ReaderRead(); + sb.Append(ch); + digit += Char.ToUpper(ch, CultureInfo.InvariantCulture); + } + isOct = true; + } else { + while (ReaderPeek() != -1 && Char.IsDigit((char)ReaderPeek())) { + ch = (char)ReaderRead();; + digit += ch; + sb.Append(ch); + } + } + + if (digit.Length == 0) { + errors.Error(Line, Col, String.Format("digit expected")); + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), 0, LiteralFormat.DecimalNumber); + } + + if (ReaderPeek() != -1 && "%&SILU".IndexOf(PeekUpperChar()) != -1 || isHex || isOct) { + bool unsigned = false; + if (ReaderPeek() != -1) { + ch = (char)ReaderPeek(); + sb.Append(ch); + ch = Char.ToUpper(ch, CultureInfo.InvariantCulture); + unsigned = ch == 'U'; + if (unsigned) { + ReaderRead(); // read the U + ch = (char)ReaderPeek(); + sb.Append(ch); + ch = Char.ToUpper(ch, CultureInfo.InvariantCulture); + if (ch != 'I' && ch != 'L' && ch != 'S') { + errors.Error(Line, Col, "Invalid type character: U" + ch); + } + } + } + try { + if (isOct) { + ReaderRead(); + ulong number = 0L; + for (int i = 0; i < digit.Length; ++i) { + number = number * 8 + digit[i] - '0'; + } + if (ch == 'S') { + if (unsigned) + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), (ushort)number, LiteralFormat.OctalNumber); + else + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), (short)number, LiteralFormat.OctalNumber); + } else if (ch == '%' || ch == 'I') { + if (unsigned) + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), (uint)number, LiteralFormat.OctalNumber); + else + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), (int)number, LiteralFormat.OctalNumber); + } else if (ch == '&' || ch == 'L') { + if (unsigned) + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), (ulong)number, LiteralFormat.OctalNumber); + else + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), (long)number, LiteralFormat.OctalNumber); + } else { + if (number > uint.MaxValue) { + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), unchecked((long)number), LiteralFormat.OctalNumber); + } else { + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), unchecked((int)number), LiteralFormat.OctalNumber); + } + } + } + LiteralFormat literalFormat = isHex ? LiteralFormat.HexadecimalNumber : LiteralFormat.DecimalNumber; + if (ch == 'S') { + ReaderRead(); + if (unsigned) + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), UInt16.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number), literalFormat); + else + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), Int16.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number), literalFormat); + } else if (ch == '%' || ch == 'I') { + ReaderRead(); + if (unsigned) + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), UInt32.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number), literalFormat); + else + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), Int32.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number), literalFormat); + } else if (ch == '&' || ch == 'L') { + ReaderRead(); + if (unsigned) + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), UInt64.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number), literalFormat); + else + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), Int64.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number), literalFormat); + } else if (isHex) { + ulong number = UInt64.Parse(digit, NumberStyles.HexNumber); + if (number > uint.MaxValue) { + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), unchecked((long)number), literalFormat); + } else { + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), unchecked((int)number), literalFormat); + } + } + } catch (OverflowException ex) { + errors.Error(Line, Col, ex.Message); + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), 0, LiteralFormat.None); + } catch (FormatException) { + errors.Error(Line, Col, String.Format("{0} is not a parseable number", digit)); + return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), 0, LiteralFormat.None); + } + } + Token nextToken = null; // if we accidently read a 'dot' + if (!isDouble && ReaderPeek() == '.') { // read floating point number + ReaderRead(); + if (ReaderPeek() != -1 && Char.IsDigit((char)ReaderPeek())) { + isDouble = true; // double is default + if (isHex || isOct) { + errors.Error(Line, Col, String.Format("No hexadecimal or oktadecimal floating point values allowed")); + } + digit += '.'; + while (ReaderPeek() != -1 && Char.IsDigit((char)ReaderPeek())){ // read decimal digits beyond the dot + digit += (char)ReaderRead(); + } + } else { + nextToken = new Token(Tokens.Dot, Col - 1, Line); + } + } + + if (ReaderPeek() != -1 && PeekUpperChar() == 'E') { // read exponent + isDouble = true; + digit += (char)ReaderRead(); + if (ReaderPeek() != -1 && (ReaderPeek() == '-' || ReaderPeek() == '+')) { + digit += (char)ReaderRead(); + } + while (ReaderPeek() != -1 && Char.IsDigit((char)ReaderPeek())) { // read exponent value + digit += (char)ReaderRead(); + } + } + + if (ReaderPeek() != -1) { + switch (PeekUpperChar()) { + case 'R': + case '#': + ReaderRead(); + isDouble = true; + break; + case 'D': + case '@': + ReaderRead(); + isDecimal = true; + break; + case 'F': + case '!': + ReaderRead(); + isSingle = true; + break; + } + } + + try { + if (isSingle) { + return new Token(Tokens.LiteralSingle, x, y, sb.ToString(), Single.Parse(digit, CultureInfo.InvariantCulture), LiteralFormat.DecimalNumber); + } + if (isDecimal) { + return new Token(Tokens.LiteralDecimal, x, y, sb.ToString(), Decimal.Parse(digit, NumberStyles.Currency | NumberStyles.AllowExponent, CultureInfo.InvariantCulture), LiteralFormat.DecimalNumber); + } + if (isDouble) { + return new Token(Tokens.LiteralDouble, x, y, sb.ToString(), Double.Parse(digit, CultureInfo.InvariantCulture), LiteralFormat.DecimalNumber); + } + } catch (FormatException) { + errors.Error(Line, Col, String.Format("{0} is not a parseable number", digit)); + if (isSingle) + return new Token(Tokens.LiteralSingle, x, y, sb.ToString(), 0f, LiteralFormat.DecimalNumber); + if (isDecimal) + return new Token(Tokens.LiteralDecimal, x, y, sb.ToString(), 0m, LiteralFormat.DecimalNumber); + if (isDouble) + return new Token(Tokens.LiteralDouble, x, y, sb.ToString(), 0.0, LiteralFormat.DecimalNumber); + } + Token token; + try { + token = new Token(Tokens.LiteralInteger, x, y, sb.ToString(), Int32.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number), isHex ? LiteralFormat.HexadecimalNumber : LiteralFormat.DecimalNumber); + } catch (Exception) { + try { + token = new Token(Tokens.LiteralInteger, x, y, sb.ToString(), Int64.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number), isHex ? LiteralFormat.HexadecimalNumber : LiteralFormat.DecimalNumber); + } catch (FormatException) { + errors.Error(Line, Col, String.Format("{0} is not a parseable number", digit)); + // fallback, when nothing helps :) + token = new Token(Tokens.LiteralInteger, x, y, sb.ToString(), 0, LiteralFormat.DecimalNumber); + } catch (OverflowException) { + errors.Error(Line, Col, String.Format("{0} is too long for a integer literal", digit)); + // fallback, when nothing helps :) + token = new Token(Tokens.LiteralInteger, x, y, sb.ToString(), 0, LiteralFormat.DecimalNumber); + } + } + token.next = nextToken; + return token; + } + + void ReadPreprocessorDirective() + { + Location start = new Location(Col - 1, Line); + string directive = ReadIdent('#'); + // TODO : expression parser for PP directives + // needed for proper conversion to e. g. C# + string argument = ReadToEndOfLine(); + this.specialTracker.AddPreprocessingDirective(new PreprocessingDirective(directive, argument.Trim(), start, new Location(start.Column + directive.Length + argument.Length, start.Line))); + } + + string ReadDate() + { + char ch = '\0'; + sb.Length = 0; + int nextChar; + while ((nextChar = ReaderRead()) != -1) { + ch = (char)nextChar; + if (ch == '#') { + break; + } else if (ch == '\n') { + errors.Error(Line, Col, String.Format("No return allowed inside Date literal")); + } else { + sb.Append(ch); + } + } + if (ch != '#') { + errors.Error(Line, Col, String.Format("End of File reached before Date literal terminated")); + } + return sb.ToString(); + } + + string ReadString() + { + char ch = '\0'; + sb.Length = 0; + int nextChar; + while ((nextChar = ReaderRead()) != -1) { + ch = (char)nextChar; + if (ch == '"') { + if (ReaderPeek() != -1 && ReaderPeek() == '"') { + sb.Append('"'); + ReaderRead(); + } else { + break; + } + } else if (ch == '\n') { + errors.Error(Line, Col, String.Format("No return allowed inside String literal")); + } else { + sb.Append(ch); + } + } + if (ch != '"') { + errors.Error(Line, Col, String.Format("End of File reached before String terminated ")); + } + return sb.ToString(); + } + + void ReadComment() + { + Location startPos = new Location(Col, Line); + sb.Length = 0; + StringBuilder curWord = specialCommentHash != null ? new StringBuilder() : null; + int missingApostrophes = 2; // no. of ' missing until it is a documentation comment + int nextChar; + while ((nextChar = ReaderRead()) != -1) { + char ch = (char)nextChar; + + if (HandleLineEnd(ch)) { + break; + } + + sb.Append(ch); + + if (missingApostrophes > 0) { + if (ch == '\'' || ch == '\u2018' || ch == '\u2019') { + if (--missingApostrophes == 0) { + specialTracker.StartComment(CommentType.Documentation, isAtLineBegin, startPos); + sb.Length = 0; + } + } else { + specialTracker.StartComment(CommentType.SingleLine, isAtLineBegin, startPos); + missingApostrophes = 0; + } + } + + if (specialCommentHash != null) { + if (Char.IsLetter(ch)) { + curWord.Append(ch); + } else { + string tag = curWord.ToString(); + curWord.Length = 0; + if (specialCommentHash.ContainsKey(tag)) { + Location p = new Location(Col, Line); + string comment = ch + ReadToEndOfLine(); + this.TagComments.Add(new TagComment(tag, comment, isAtLineBegin, p, new Location(Col, Line))); + sb.Append(comment); + break; + } + } + } + } + if (missingApostrophes > 0) { + specialTracker.StartComment(CommentType.SingleLine, isAtLineBegin, startPos); + } + specialTracker.AddString(sb.ToString()); + specialTracker.FinishComment(new Location(Col, Line)); + } + + Token ReadOperator(char ch) + { + int x = Col - 1; + int y = Line; + switch(ch) { + case '+': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.PlusAssign, x, y); + default: + break; + } + return new Token(Tokens.Plus, x, y); + case '-': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.MinusAssign, x, y); + default: + break; + } + return new Token(Tokens.Minus, x, y); + case '*': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.TimesAssign, x, y); + default: + break; + } + return new Token(Tokens.Times, x, y, "*"); + case '/': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.DivAssign, x, y); + default: + break; + } + return new Token(Tokens.Div, x, y); + case '\\': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.DivIntegerAssign, x, y); + default: + break; + } + return new Token(Tokens.DivInteger, x, y); + case '&': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.ConcatStringAssign, x, y); + default: + break; + } + return new Token(Tokens.ConcatString, x, y); + case '^': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.PowerAssign, x, y); + default: + break; + } + return new Token(Tokens.Power, x, y); + case ':': + if (ReaderPeek() == '=') { + ReaderRead(); + return new Token(Tokens.ColonAssign, x, y); + } + return new Token(Tokens.Colon, x, y); + case '=': + return new Token(Tokens.Assign, x, y); + case '<': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.LessEqual, x, y); + case '>': + ReaderRead(); + return new Token(Tokens.NotEqual, x, y); + case '<': + ReaderRead(); + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.ShiftLeftAssign, x, y); + default: + break; + } + return new Token(Tokens.ShiftLeft, x, y); + } + return new Token(Tokens.LessThan, x, y); + case '>': + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.GreaterEqual, x, y); + case '>': + ReaderRead(); + if (ReaderPeek() != -1) { + switch (ReaderPeek()) { + case '=': + ReaderRead(); + return new Token(Tokens.ShiftRightAssign, x, y); + default: + break; + } + } + return new Token(Tokens.ShiftRight, x, y); + } + return new Token(Tokens.GreaterThan, x, y); + case ',': + return new Token(Tokens.Comma, x, y); + case '.': + // Prevent OverflowException when Peek returns -1 + int tmp = ReaderPeek(); int tmp2 = ReaderPeek(1); + if (tmp > 0) { + if (char.IsDigit((char)tmp)) + return ReadDigit('.', Col); + else if ((char)tmp == '@') { + ReaderRead(); + return new Token(Tokens.DotAt, x, y); + } else if ((char)tmp == '.' && tmp2 > 0 && (char)tmp2 == '.') { + ReaderRead(); ReaderRead(); + return new Token(Tokens.TripleDot, x, y); + } + } + return new Token(Tokens.Dot, x, y); + case '(': + return new Token(Tokens.OpenParenthesis, x, y); + case ')': + return new Token(Tokens.CloseParenthesis, x, y); + case '{': + return new Token(Tokens.OpenCurlyBrace, x, y); + case '}': + return new Token(Tokens.CloseCurlyBrace, x, y); + case '?': + return new Token(Tokens.QuestionMark, x, y); + case '!': + return new Token(Tokens.ExclamationMark, x, y); + } + return null; + } + #endregion + + #region XML Readers + Token ReadXmlProcessingInstruction(int x, int y) + { + sb.Length = 0; + int nextChar = -1; + + while (ReaderPeek() != '?' || ReaderPeek(1) != '>') { + nextChar = ReaderRead(); + if (nextChar == -1) + break; + sb.Append((char)nextChar); + } + + ReaderSkip("?>".Length); + + return new Token(Tokens.XmlProcessingInstruction, new Location(x, y), new Location(Col, Line), sb.ToString(), null, LiteralFormat.None); + } + + Token ReadXmlCommentOrCData(int x, int y) + { + sb.Length = 0; + int nextChar = -1; + + if (string.CompareOrdinal(ReaderPeekString("--".Length), "--") == 0) { + ReaderSkip("--".Length); + while ((nextChar = ReaderRead()) != -1) { + sb.Append((char)nextChar); + if (string.CompareOrdinal(ReaderPeekString("-->".Length), "-->") == 0) { + ReaderSkip("-->".Length); + return new Token(Tokens.XmlComment, new Location(x, y), new Location(Col, Line), sb.ToString(), null, LiteralFormat.None); + } + } + } + + if (string.CompareOrdinal(ReaderPeekString("[CDATA[".Length), "[CDATA[") == 0) { + ReaderSkip("[CDATA[".Length); + while ((nextChar = ReaderRead()) != -1) { + sb.Append((char)nextChar); + if (string.CompareOrdinal(ReaderPeekString("]]>".Length), "]]>") == 0) { + ReaderSkip("]]>".Length); + return new Token(Tokens.XmlCData, new Location(x, y), new Location(Col, Line), sb.ToString(), null, LiteralFormat.None); + } + } + } + + return new Token(Tokens.XmlComment, new Location(x, y), new Location(Col, Line), sb.ToString(), null, LiteralFormat.None); + } + + string ReadXmlContent(char ch) + { + sb.Length = 0; + while (true) { + sb.Append(ch); + int next = ReaderPeek(); + + if (next == -1 || next == '<') + break; + ch = (char)ReaderRead(); + } + + return sb.ToString(); + } + + string ReadXmlString(char terminator) + { + char ch = '\0'; + sb.Length = 0; + int nextChar; + while ((nextChar = ReaderRead()) != -1) { + ch = (char)nextChar; + if (ch == terminator) { + break; + } else if (ch == '\n') { + errors.Error(Line, Col, String.Format("No return allowed inside String literal")); + } else { + sb.Append(ch); + } + } + if (ch != terminator) { + errors.Error(Line, Col, String.Format("End of File reached before String terminated ")); + } + return sb.ToString(); + } + + string ReadXmlIdent(char ch) + { + sb.Length = 0; + sb.Append(ch); + + int peek; + + while ((peek = ReaderPeek()) != -1 && (peek == ':' || XmlConvert.IsNCNameChar((char)peek))) { + sb.Append((char)ReaderRead()); + } + + return sb.ToString(); + } + #endregion + + char PeekUpperChar() + { + return Char.ToUpper((char)ReaderPeek(), CultureInfo.InvariantCulture); + } + + public override void SkipCurrentBlock(int targetToken) + { + int lastKind = -1; + int kind = base.lastToken.kind; + while (kind != Tokens.EOF && + !(lastKind == Tokens.End && kind == targetToken)) + { + lastKind = kind; + NextToken(); + kind = lastToken.kind; + } + } + + public override void SetInitialContext(SnippetType type) + { + ef.SetContext(type); + } + + public override LexerMemento Export() + { + return new VBLexerMemento() { + Column = Col, + Line = Line, + EncounteredLineContinuation = encounteredLineContinuation, + ExpressionFinder = ef.Export(), + InXmlMode = inXmlMode, + IsAtLineBegin = isAtLineBegin, + LineEnd = lineEnd, + PrevTokenKind = prevToken.kind, + MisreadExclamationMarkAsTypeCharacter = misreadExclamationMarkAsTypeCharacter, + XmlModeInfoStack = new Stack(xmlModeStack.Select(i => (XmlModeInfo)i.Clone()).Reverse()) + }; + } + } +} diff --git a/Project/Src/Lexer/VBNet/Parser.cs b/Project/Src/Lexer/VBNet/Parser.cs new file mode 100644 index 0000000000..a4cf09d0cc --- /dev/null +++ b/Project/Src/Lexer/VBNet/Parser.cs @@ -0,0 +1,8613 @@ +using System; +using System.Collections; +using System.Collections.Generic; + + + +namespace ICSharpCode.NRefactory.Parser.VB { + + + +partial class ExpressionFinder { + const int startOfExpression = 55; + const int startOfBlock = 259; + const int endOfStatementTerminatorAndBlock = 263; + static BitArray GetExpectedSet(int state) + { + switch (state) { + case 0: + case 1: + return set[0]; + case 2: + return set[1]; + case 3: + case 4: + return set[2]; + case 5: + return set[3]; + case 6: + case 88: + case 264: + case 531: + { + BitArray a = new BitArray(239); + return a; + } + case 7: + return set[4]; + case 8: + return set[5]; + case 9: + case 10: + case 20: + { + BitArray a = new BitArray(239); + a.Set(142, true); + return a; + } + case 11: + case 193: + case 199: + case 205: + case 244: + case 248: + case 295: + case 399: + case 405: + case 475: + case 521: + case 528: + case 536: + case 566: + case 602: + case 651: + case 665: + case 738: + return set[6]; + case 12: + case 13: + case 567: + case 568: + case 613: + case 623: + { + BitArray a = new BitArray(239); + a.Set(1, true); + a.Set(21, true); + a.Set(37, true); + return a; + } + case 14: + case 21: + case 23: + case 24: + case 36: + case 256: + case 259: + case 260: + case 296: + case 300: + case 322: + case 337: + case 348: + case 351: + case 357: + case 362: + case 372: + case 373: + case 396: + case 423: + case 527: + case 533: + case 539: + case 543: + case 551: + case 559: + case 569: + case 578: + case 595: + case 600: + case 608: + case 614: + case 617: + case 624: + case 627: + case 646: + case 649: + case 673: + case 681: + case 717: + case 737: + { + BitArray a = new BitArray(239); + a.Set(1, true); + a.Set(21, true); + return a; + } + case 15: + case 16: + return set[7]; + case 17: + case 18: + return set[8]; + case 19: + case 257: + case 271: + case 298: + case 352: + case 397: + case 455: + case 576: + case 596: + case 615: + case 619: + case 625: + case 647: + case 682: + { + BitArray a = new BitArray(239); + a.Set(113, true); + return a; + } + case 22: + case 544: + case 579: + return set[9]; + case 25: + { + BitArray a = new BitArray(239); + a.Set(1, true); + return a; + } + case 26: + case 27: + return set[10]; + case 28: + case 721: + return set[11]; + case 29: + return set[12]; + case 30: + return set[13]; + case 31: + case 32: + case 152: + case 217: + case 218: + case 265: + case 276: + case 277: + case 463: + case 464: + case 465: + case 466: + case 554: + case 555: + case 588: + case 589: + case 676: + case 677: + case 730: + case 731: + return set[14]; + case 33: + case 34: + case 522: + case 523: + case 529: + case 530: + case 556: + case 557: + case 670: + return set[15]; + case 35: + case 37: + case 157: + case 168: + case 171: + case 187: + case 203: + case 221: + case 307: + case 332: + case 422: + case 440: + case 451: + case 478: + case 532: + case 550: + case 558: + case 630: + case 633: + case 655: + case 658: + case 660: + case 672: + case 685: + case 687: + case 710: + case 713: + case 716: + case 722: + case 725: + case 743: + return set[16]; + case 38: + case 41: + return set[17]; + case 39: + return set[18]; + case 40: + case 97: + case 101: + case 163: + case 388: + case 482: + return set[19]; + case 42: + { + BitArray a = new BitArray(239); + a.Set(33, true); + a.Set(37, true); + return a; + } + case 43: + case 44: + case 165: + case 166: + return set[20]; + case 45: + case 46: + case 167: + case 188: + case 392: + case 427: + case 476: + case 479: + case 499: + case 562: + case 593: + case 645: + case 691: + case 720: + case 729: + { + BitArray a = new BitArray(239); + a.Set(38, true); + return a; + } + case 47: + case 48: + return set[21]; + case 49: + case 179: + case 186: + case 394: + { + BitArray a = new BitArray(239); + a.Set(22, true); + return a; + } + case 50: + case 51: + case 52: + case 54: + case 390: + case 391: + case 412: + case 413: + case 419: + case 420: + case 490: + case 491: + case 704: + case 705: + return set[22]; + case 53: + case 169: + case 170: + case 172: + case 181: + case 414: + case 421: + case 429: + case 438: + case 442: + case 486: + case 489: + case 493: + case 495: + case 496: + case 506: + case 513: + case 520: + case 706: + { + BitArray a = new BitArray(239); + a.Set(22, true); + a.Set(38, true); + return a; + } + case 55: + case 56: + case 70: + case 75: + case 76: + case 77: + case 83: + case 99: + case 155: + case 178: + case 180: + case 182: + case 185: + case 195: + case 197: + case 215: + case 239: + case 274: + case 284: + case 286: + case 287: + case 304: + case 321: + case 326: + case 335: + case 341: + case 343: + case 347: + case 350: + case 356: + case 367: + case 369: + case 370: + case 376: + case 393: + case 395: + case 415: + case 439: + case 468: + case 484: + case 485: + case 487: + case 488: + case 549: + case 629: + return set[23]; + case 57: + case 78: + case 158: + return set[24]; + case 58: + return set[25]; + case 59: + { + BitArray a = new BitArray(239); + a.Set(216, true); + return a; + } + case 60: + { + BitArray a = new BitArray(239); + a.Set(145, true); + return a; + } + case 61: + case 156: + { + BitArray a = new BitArray(239); + a.Set(144, true); + return a; + } + case 62: + { + BitArray a = new BitArray(239); + a.Set(236, true); + return a; + } + case 63: + { + BitArray a = new BitArray(239); + a.Set(177, true); + return a; + } + case 64: + { + BitArray a = new BitArray(239); + a.Set(175, true); + return a; + } + case 65: + { + BitArray a = new BitArray(239); + a.Set(61, true); + return a; + } + case 66: + { + BitArray a = new BitArray(239); + a.Set(60, true); + return a; + } + case 67: + { + BitArray a = new BitArray(239); + a.Set(150, true); + return a; + } + case 68: + { + BitArray a = new BitArray(239); + a.Set(42, true); + return a; + } + case 69: + { + BitArray a = new BitArray(239); + a.Set(43, true); + return a; + } + case 71: + case 443: + { + BitArray a = new BitArray(239); + a.Set(40, true); + return a; + } + case 72: + { + BitArray a = new BitArray(239); + a.Set(41, true); + return a; + } + case 73: + case 98: + case 222: + case 223: + case 282: + case 283: + case 334: + case 739: + { + BitArray a = new BitArray(239); + a.Set(20, true); + return a; + } + case 74: + { + BitArray a = new BitArray(239); + a.Set(154, true); + return a; + } + case 79: + case 91: + case 93: + case 148: + { + BitArray a = new BitArray(239); + a.Set(35, true); + return a; + } + case 80: + case 81: + return set[26]; + case 82: + { + BitArray a = new BitArray(239); + a.Set(36, true); + return a; + } + case 84: + case 100: + case 516: + { + BitArray a = new BitArray(239); + a.Set(22, true); + a.Set(36, true); + return a; + } + case 85: + case 121: + { + BitArray a = new BitArray(239); + a.Set(162, true); + return a; + } + case 86: + case 87: + return set[27]; + case 89: + case 92: + case 149: + case 150: + case 153: + return set[28]; + case 90: + case 102: + case 147: + { + BitArray a = new BitArray(239); + a.Set(233, true); + return a; + } + case 94: + { + BitArray a = new BitArray(239); + a.Set(26, true); + a.Set(36, true); + a.Set(147, true); + return a; + } + case 95: + { + BitArray a = new BitArray(239); + a.Set(26, true); + a.Set(147, true); + return a; + } + case 96: + case 686: + { + BitArray a = new BitArray(239); + a.Set(26, true); + return a; + } + case 103: + case 353: + { + BitArray a = new BitArray(239); + a.Set(231, true); + return a; + } + case 104: + { + BitArray a = new BitArray(239); + a.Set(230, true); + return a; + } + case 105: + { + BitArray a = new BitArray(239); + a.Set(224, true); + return a; + } + case 106: + { + BitArray a = new BitArray(239); + a.Set(223, true); + return a; + } + case 107: + case 299: + { + BitArray a = new BitArray(239); + a.Set(218, true); + return a; + } + case 108: + { + BitArray a = new BitArray(239); + a.Set(213, true); + return a; + } + case 109: + { + BitArray a = new BitArray(239); + a.Set(212, true); + return a; + } + case 110: + { + BitArray a = new BitArray(239); + a.Set(211, true); + return a; + } + case 111: + case 456: + { + BitArray a = new BitArray(239); + a.Set(210, true); + return a; + } + case 112: + { + BitArray a = new BitArray(239); + a.Set(209, true); + return a; + } + case 113: + { + BitArray a = new BitArray(239); + a.Set(206, true); + return a; + } + case 114: + { + BitArray a = new BitArray(239); + a.Set(203, true); + return a; + } + case 115: + case 359: + { + BitArray a = new BitArray(239); + a.Set(197, true); + return a; + } + case 116: + case 601: + case 620: + { + BitArray a = new BitArray(239); + a.Set(186, true); + return a; + } + case 117: + { + BitArray a = new BitArray(239); + a.Set(184, true); + return a; + } + case 118: + { + BitArray a = new BitArray(239); + a.Set(176, true); + return a; + } + case 119: + { + BitArray a = new BitArray(239); + a.Set(170, true); + return a; + } + case 120: + case 316: + case 323: + case 338: + { + BitArray a = new BitArray(239); + a.Set(163, true); + return a; + } + case 122: + { + BitArray a = new BitArray(239); + a.Set(147, true); + return a; + } + case 123: + case 226: + case 231: + case 233: + { + BitArray a = new BitArray(239); + a.Set(146, true); + return a; + } + case 124: + case 228: + case 232: + { + BitArray a = new BitArray(239); + a.Set(143, true); + return a; + } + case 125: + { + BitArray a = new BitArray(239); + a.Set(139, true); + return a; + } + case 126: + { + BitArray a = new BitArray(239); + a.Set(133, true); + return a; + } + case 127: + case 258: + { + BitArray a = new BitArray(239); + a.Set(127, true); + return a; + } + case 128: + case 151: + case 251: + { + BitArray a = new BitArray(239); + a.Set(126, true); + return a; + } + case 129: + { + BitArray a = new BitArray(239); + a.Set(124, true); + return a; + } + case 130: + { + BitArray a = new BitArray(239); + a.Set(121, true); + return a; + } + case 131: + case 196: + { + BitArray a = new BitArray(239); + a.Set(116, true); + return a; + } + case 132: + { + BitArray a = new BitArray(239); + a.Set(108, true); + return a; + } + case 133: + { + BitArray a = new BitArray(239); + a.Set(107, true); + return a; + } + case 134: + { + BitArray a = new BitArray(239); + a.Set(104, true); + return a; + } + case 135: + case 638: + { + BitArray a = new BitArray(239); + a.Set(98, true); + return a; + } + case 136: + { + BitArray a = new BitArray(239); + a.Set(87, true); + return a; + } + case 137: + { + BitArray a = new BitArray(239); + a.Set(84, true); + return a; + } + case 138: + case 208: + case 238: + { + BitArray a = new BitArray(239); + a.Set(70, true); + return a; + } + case 139: + { + BitArray a = new BitArray(239); + a.Set(67, true); + return a; + } + case 140: + { + BitArray a = new BitArray(239); + a.Set(66, true); + return a; + } + case 141: + { + BitArray a = new BitArray(239); + a.Set(65, true); + return a; + } + case 142: + { + BitArray a = new BitArray(239); + a.Set(64, true); + return a; + } + case 143: + { + BitArray a = new BitArray(239); + a.Set(62, true); + return a; + } + case 144: + case 250: + { + BitArray a = new BitArray(239); + a.Set(58, true); + return a; + } + case 145: + { + BitArray a = new BitArray(239); + a.Set(2, true); + return a; + } + case 146: + return set[29]; + case 154: + return set[30]; + case 159: + return set[31]; + case 160: + return set[32]; + case 161: + case 162: + case 480: + case 481: + return set[33]; + case 164: + return set[34]; + case 173: + case 174: + case 319: + case 328: + return set[35]; + case 175: + case 458: + return set[36]; + case 176: + case 375: + { + BitArray a = new BitArray(239); + a.Set(135, true); + return a; + } + case 177: + case 184: + case 189: + case 253: + case 424: + case 452: + case 474: + case 477: + case 590: + case 591: + case 643: + { + BitArray a = new BitArray(239); + a.Set(37, true); + return a; + } + case 183: + return set[37]; + case 190: + { + BitArray a = new BitArray(239); + a.Set(58, true); + a.Set(126, true); + return a; + } + case 191: + case 192: + return set[38]; + case 194: + { + BitArray a = new BitArray(239); + a.Set(171, true); + return a; + } + case 198: + case 212: + case 230: + case 235: + case 241: + case 243: + case 247: + case 249: + return set[39]; + case 200: + case 201: + { + BitArray a = new BitArray(239); + a.Set(63, true); + a.Set(138, true); + return a; + } + case 202: + case 204: + case 320: + { + BitArray a = new BitArray(239); + a.Set(138, true); + return a; + } + case 206: + case 207: + case 209: + case 211: + case 213: + case 214: + case 224: + case 229: + case 234: + case 242: + case 246: + case 269: + case 273: + return set[40]; + case 210: + { + BitArray a = new BitArray(239); + a.Set(22, true); + a.Set(143, true); + return a; + } + case 216: + return set[41]; + case 219: + case 278: + return set[42]; + case 220: + case 279: + return set[43]; + case 225: + { + BitArray a = new BitArray(239); + a.Set(22, true); + a.Set(70, true); + return a; + } + case 227: + { + BitArray a = new BitArray(239); + a.Set(133, true); + a.Set(143, true); + a.Set(146, true); + return a; + } + case 236: + case 237: + return set[44]; + case 240: + { + BitArray a = new BitArray(239); + a.Set(64, true); + a.Set(104, true); + return a; + } + case 245: + return set[45]; + case 252: + case 553: + case 664: + case 675: + case 683: + { + BitArray a = new BitArray(239); + a.Set(127, true); + a.Set(210, true); + return a; + } + case 254: + case 255: + return set[46]; + case 261: + case 262: + return set[47]; + case 263: + return set[48]; + case 266: + return set[49]; + case 267: + case 268: + case 381: + return set[50]; + case 270: + case 275: + case 365: + case 656: + case 657: + case 659: + case 694: + case 711: + case 712: + case 714: + case 723: + case 724: + case 726: + { + BitArray a = new BitArray(239); + a.Set(1, true); + a.Set(21, true); + a.Set(22, true); + return a; + } + case 272: + { + BitArray a = new BitArray(239); + a.Set(226, true); + return a; + } + case 280: + case 281: + return set[51]; + case 285: + case 327: + case 342: + case 404: + return set[52]; + case 288: + case 289: + case 309: + case 310: + case 324: + case 325: + case 339: + case 340: + return set[53]; + case 290: + case 382: + case 385: + { + BitArray a = new BitArray(239); + a.Set(1, true); + a.Set(21, true); + a.Set(111, true); + return a; + } + case 291: + { + BitArray a = new BitArray(239); + a.Set(108, true); + a.Set(124, true); + a.Set(231, true); + return a; + } + case 292: + return set[54]; + case 293: + case 312: + return set[55]; + case 294: + { + BitArray a = new BitArray(239); + a.Set(5, true); + return a; + } + case 297: + { + BitArray a = new BitArray(239); + a.Set(75, true); + a.Set(113, true); + a.Set(123, true); + return a; + } + case 301: + case 302: + return set[56]; + case 303: + case 308: + { + BitArray a = new BitArray(239); + a.Set(1, true); + a.Set(21, true); + a.Set(229, true); + return a; + } + case 305: + case 306: + return set[57]; + case 311: + return set[58]; + case 313: + { + BitArray a = new BitArray(239); + a.Set(118, true); + return a; + } + case 314: + case 315: + return set[59]; + case 317: + case 318: + return set[60]; + case 329: + case 330: + return set[61]; + case 331: + return set[62]; + case 333: + { + BitArray a = new BitArray(239); + a.Set(20, true); + a.Set(138, true); + return a; + } + case 336: + { + BitArray a = new BitArray(239); + a.Set(1, true); + a.Set(21, true); + a.Set(205, true); + return a; + } + case 344: + return set[63]; + case 345: + case 349: + { + BitArray a = new BitArray(239); + a.Set(152, true); + return a; + } + case 346: + return set[64]; + case 354: + case 355: + return set[65]; + case 358: + { + BitArray a = new BitArray(239); + a.Set(74, true); + a.Set(113, true); + return a; + } + case 360: + case 361: + return set[66]; + case 363: + case 364: + return set[67]; + case 366: + case 368: + return set[68]; + case 371: + case 377: + { + BitArray a = new BitArray(239); + a.Set(1, true); + a.Set(21, true); + a.Set(214, true); + return a; + } + case 374: + { + BitArray a = new BitArray(239); + a.Set(111, true); + a.Set(112, true); + a.Set(113, true); + return a; + } + case 378: + { + BitArray a = new BitArray(239); + a.Set(1, true); + a.Set(21, true); + a.Set(135, true); + return a; + } + case 379: + case 380: + case 453: + case 454: + return set[69]; + case 383: + case 384: + case 386: + case 387: + return set[70]; + case 389: + return set[71]; + case 398: + { + BitArray a = new BitArray(239); + a.Set(211, true); + a.Set(233, true); + return a; + } + case 400: + case 401: + case 406: + case 407: + return set[72]; + case 402: + case 408: + return set[73]; + case 403: + case 411: + case 418: + return set[74]; + case 409: + case 410: + case 416: + case 417: + case 701: + case 702: + return set[75]; + case 425: + case 426: + return set[76]; + case 428: + case 430: + case 431: + case 592: + case 644: + return set[77]; + case 432: + case 433: + return set[78]; + case 434: + case 435: + return set[79]; + case 436: + return set[80]; + case 437: + case 441: + { + BitArray a = new BitArray(239); + a.Set(20, true); + a.Set(22, true); + a.Set(38, true); + return a; + } + case 444: + case 445: + case 449: + return set[81]; + case 446: + { + BitArray a = new BitArray(239); + a.Set(22, true); + a.Set(39, true); + return a; + } + case 447: + case 448: + return set[82]; + case 450: + { + BitArray a = new BitArray(239); + a.Set(21, true); + return a; + } + case 457: + return set[83]; + case 459: + case 472: + return set[84]; + case 460: + case 473: + return set[85]; + case 461: + case 462: + { + BitArray a = new BitArray(239); + a.Set(10, true); + return a; + } + case 467: + { + BitArray a = new BitArray(239); + a.Set(12, true); + return a; + } + case 469: + { + BitArray a = new BitArray(239); + a.Set(13, true); + return a; + } + case 470: + return set[86]; + case 471: + return set[87]; + case 483: + return set[88]; + case 492: + case 494: + return set[89]; + case 497: + case 498: + case 560: + case 561: + case 689: + case 690: + return set[90]; + case 500: + case 501: + case 502: + case 507: + case 508: + case 563: + case 692: + case 719: + case 728: + return set[91]; + case 503: + case 509: + case 518: + return set[92]; + case 504: + case 505: + case 510: + case 511: + { + BitArray a = new BitArray(239); + a.Set(22, true); + a.Set(38, true); + a.Set(63, true); + return a; + } + case 512: + case 514: + case 519: + return set[93]; + case 515: + case 517: + return set[94]; + case 524: + case 537: + case 538: + case 594: + case 671: + { + BitArray a = new BitArray(239); + a.Set(1, true); + a.Set(21, true); + a.Set(63, true); + return a; + } + case 525: + case 526: + case 598: + case 599: + return set[95]; + case 534: + case 535: + case 542: + { + BitArray a = new BitArray(239); + a.Set(115, true); + return a; + } + case 540: + case 541: + return set[96]; + case 545: + case 546: + return set[97]; + case 547: + case 548: + case 607: + { + BitArray a = new BitArray(239); + a.Set(1, true); + a.Set(20, true); + a.Set(21, true); + return a; + } + case 552: + { + BitArray a = new BitArray(239); + a.Set(103, true); + return a; + } + case 564: + case 565: + case 577: + { + BitArray a = new BitArray(239); + a.Set(84, true); + a.Set(155, true); + a.Set(209, true); + return a; + } + case 570: + case 571: + return set[98]; + case 572: + case 573: + return set[99]; + case 574: + case 575: + case 586: + return set[100]; + case 580: + case 581: + return set[101]; + case 582: + case 583: + case 708: + return set[102]; + case 584: + return set[103]; + case 585: + return set[104]; + case 587: + case 597: + { + BitArray a = new BitArray(239); + a.Set(172, true); + return a; + } + case 603: + case 604: + return set[105]; + case 605: + return set[106]; + case 606: + case 637: + return set[107]; + case 609: + case 610: + case 611: + case 628: + return set[108]; + case 612: + case 616: + case 626: + { + BitArray a = new BitArray(239); + a.Set(128, true); + a.Set(198, true); + return a; + } + case 618: + return set[109]; + case 621: + return set[110]; + case 622: + return set[111]; + case 631: + case 632: + case 634: + case 700: + case 703: + return set[112]; + case 635: + case 636: + return set[113]; + case 639: + case 641: + case 650: + { + BitArray a = new BitArray(239); + a.Set(119, true); + return a; + } + case 640: + return set[114]; + case 642: + return set[115]; + case 648: + { + BitArray a = new BitArray(239); + a.Set(56, true); + a.Set(189, true); + a.Set(193, true); + return a; + } + case 652: + case 653: + return set[116]; + case 654: + case 661: + { + BitArray a = new BitArray(239); + a.Set(1, true); + a.Set(21, true); + a.Set(136, true); + return a; + } + case 662: + { + BitArray a = new BitArray(239); + a.Set(101, true); + return a; + } + case 663: + return set[117]; + case 666: + case 667: + { + BitArray a = new BitArray(239); + a.Set(149, true); + return a; + } + case 668: + case 674: + case 740: + { + BitArray a = new BitArray(239); + a.Set(3, true); + return a; + } + case 669: + return set[118]; + case 678: + case 679: + return set[119]; + case 680: + case 688: + return set[120]; + case 684: + return set[121]; + case 693: + case 695: + return set[122]; + case 696: + case 707: + return set[123]; + case 697: + case 698: + return set[124]; + case 699: + return set[125]; + case 709: + { + BitArray a = new BitArray(239); + a.Set(136, true); + return a; + } + case 715: + { + BitArray a = new BitArray(239); + a.Set(140, true); + return a; + } + case 718: + case 727: + { + BitArray a = new BitArray(239); + a.Set(169, true); + return a; + } + case 732: + return set[126]; + case 733: + { + BitArray a = new BitArray(239); + a.Set(160, true); + return a; + } + case 734: + { + BitArray a = new BitArray(239); + a.Set(137, true); + return a; + } + case 735: + case 736: + return set[127]; + case 741: + { + BitArray a = new BitArray(239); + a.Set(11, true); + return a; + } + case 742: + return set[128]; + case 744: + { + BitArray a = new BitArray(239); + a.Set(173, true); + return a; + } + case 745: + return set[129]; + case 746: + { + BitArray a = new BitArray(239); + a.Set(67, true); + a.Set(213, true); + return a; + } + case 747: + return set[130]; + default: throw new InvalidOperationException(); + } + } + + const bool T = true; + const bool x = false; + + int currentState = 0; + + readonly Stack stateStack = new Stack(); + bool wasQualifierTokenAtStart = false; + bool nextTokenIsPotentialStartOfExpression = false; + bool readXmlIdentifier = false; + bool identifierExpected = false; + bool nextTokenIsStartOfImportsOrAccessExpression = false; + bool isMissingModifier = false; + bool isAlreadyInExpr = false; + bool wasNormalAttribute = false; + int activeArgument = 0; + List errors = new List(); + + public ExpressionFinder() + { + stateStack.Push(-1); // required so that we don't crash when leaving the root production + } + + void Expect(int expectedKind, Token la) + { + if (la.kind != expectedKind) { + Error(la); + output.AppendLine("expected: " + expectedKind); + //Console.WriteLine("expected: " + expectedKind); + } + } + + void Error(Token la) + { + output.AppendLine("not expected: " + la); + //Console.WriteLine("not expected: " + la); + errors.Add(la); + } + + Token t; + + public void InformToken(Token la) + { + switchlbl: switch (currentState) { + case 0: { + PushContext(Context.Global, la, t); + goto case 1; + } + case 1: { + if (la == null) { currentState = 1; break; } + if (la.kind == 173) { + stateStack.Push(1); + goto case 744; + } else { + goto case 2; + } + } + case 2: { + if (la == null) { currentState = 2; break; } + if (la.kind == 137) { + stateStack.Push(2); + goto case 734; + } else { + goto case 3; + } + } + case 3: { + if (la == null) { currentState = 3; break; } + if (la.kind == 40) { + stateStack.Push(3); + goto case 443; + } else { + goto case 4; + } + } + case 4: { + if (la == null) { currentState = 4; break; } + if (set[3].Get(la.kind)) { + stateStack.Push(4); + goto case 5; + } else { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 5: { + if (la == null) { currentState = 5; break; } + if (la.kind == 160) { + currentState = 730; + break; + } else { + if (set[4].Get(la.kind)) { + goto case 7; + } else { + goto case 6; + } + } + } + case 6: { + Error(la); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 7: { + if (la == null) { currentState = 7; break; } + if (la.kind == 40) { + stateStack.Push(7); + goto case 443; + } else { + goto case 8; + } + } + case 8: { + if (la == null) { currentState = 8; break; } + if (set[131].Get(la.kind)) { + currentState = 8; + break; + } else { + if (la.kind == 84 || la.kind == 155 || la.kind == 209) { + goto case 564; + } else { + if (la.kind == 103) { + currentState = 553; + break; + } else { + if (la.kind == 115) { + goto case 534; + } else { + if (la.kind == 142) { + goto case 9; + } else { + goto case 6; + } + } + } + } + } + } + case 9: { + PushContext(Context.TypeDeclaration, la, t); + goto case 10; + } + case 10: { + if (la == null) { currentState = 10; break; } + Expect(142, la); // "Interface" + currentState = 11; + break; + } + case 11: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(12); + goto case 205; + } + case 12: { + PopContext(); + goto case 13; + } + case 13: { + if (la == null) { currentState = 13; break; } + if (la.kind == 37) { + currentState = 727; + break; + } else { + goto case 14; + } + } + case 14: { + stateStack.Push(15); + goto case 23; + } + case 15: { + isMissingModifier = true; + goto case 16; + } + case 16: { + if (la == null) { currentState = 16; break; } + if (la.kind == 140) { + currentState = 722; + break; + } else { + goto case 17; + } + } + case 17: { + isMissingModifier = true; + goto case 18; + } + case 18: { + if (la == null) { currentState = 18; break; } + if (set[10].Get(la.kind)) { + goto case 26; + } else { + isMissingModifier = false; + goto case 19; + } + } + case 19: { + if (la == null) { currentState = 19; break; } + Expect(113, la); // "End" + currentState = 20; + break; + } + case 20: { + if (la == null) { currentState = 20; break; } + Expect(142, la); // "Interface" + currentState = 21; + break; + } + case 21: { + stateStack.Push(22); + goto case 23; + } + case 22: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 23: { + if (la != null) CurrentBlock.lastExpressionStart = la.Location; + goto case 24; + } + case 24: { + if (la == null) { currentState = 24; break; } + if (la.kind == 1) { + goto case 25; + } else { + if (la.kind == 21) { + currentState = stateStack.Pop(); + break; + } else { + goto case 6; + } + } + } + case 25: { + if (la == null) { currentState = 25; break; } + currentState = stateStack.Pop(); + break; + } + case 26: { + isMissingModifier = true; + goto case 27; + } + case 27: { + if (la == null) { currentState = 27; break; } + if (la.kind == 40) { + stateStack.Push(26); + goto case 443; + } else { + isMissingModifier = true; + goto case 28; + } + } + case 28: { + if (la == null) { currentState = 28; break; } + if (set[132].Get(la.kind)) { + currentState = 721; + break; + } else { + isMissingModifier = false; + goto case 29; + } + } + case 29: { + if (la == null) { currentState = 29; break; } + if (la.kind == 84 || la.kind == 155 || la.kind == 209) { + stateStack.Push(17); + goto case 564; + } else { + if (la.kind == 103) { + stateStack.Push(17); + goto case 552; + } else { + if (la.kind == 115) { + stateStack.Push(17); + goto case 534; + } else { + if (la.kind == 142) { + stateStack.Push(17); + goto case 9; + } else { + if (set[13].Get(la.kind)) { + stateStack.Push(17); + goto case 30; + } else { + Error(la); + goto case 17; + } + } + } + } + } + } + case 30: { + if (la == null) { currentState = 30; break; } + if (la.kind == 119) { + currentState = 528; + break; + } else { + if (la.kind == 186) { + currentState = 521; + break; + } else { + if (la.kind == 127 || la.kind == 210) { + currentState = 31; + break; + } else { + goto case 6; + } + } + } + } + case 31: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + goto case 32; + } + case 32: { + if (la == null) { currentState = 32; break; } + currentState = 33; + break; + } + case 33: { + PopContext(); + goto case 34; + } + case 34: { + if (la == null) { currentState = 34; break; } + if (la.kind == 37) { + currentState = 497; + break; + } else { + if (la.kind == 63) { + currentState = 35; + break; + } else { + goto case 23; + } + } + } + case 35: { + PushContext(Context.Type, la, t); + stateStack.Push(36); + goto case 37; + } + case 36: { + PopContext(); + goto case 23; + } + case 37: { + if (la == null) { currentState = 37; break; } + if (la.kind == 130) { + currentState = 38; + break; + } else { + if (set[6].Get(la.kind)) { + currentState = 38; + break; + } else { + if (set[133].Get(la.kind)) { + currentState = 38; + break; + } else { + if (la.kind == 33) { + currentState = 38; + break; + } else { + Error(la); + goto case 38; + } + } + } + } + } + case 38: { + if (la == null) { currentState = 38; break; } + if (la.kind == 33 || la.kind == 37) { + stateStack.Push(38); + goto case 42; + } else { + goto case 39; + } + } + case 39: { + if (la == null) { currentState = 39; break; } + if (la.kind == 26) { + currentState = 40; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 40: { + stateStack.Push(41); + goto case 101; + } + case 41: { + if (la == null) { currentState = 41; break; } + if (la.kind == 33 || la.kind == 37) { + stateStack.Push(41); + goto case 42; + } else { + goto case 39; + } + } + case 42: { + if (la == null) { currentState = 42; break; } + if (la.kind == 33) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 37) { + currentState = 43; + break; + } else { + goto case 6; + } + } + } + case 43: { + PushContext(Context.Expression, la, t); + nextTokenIsPotentialStartOfExpression = true; + goto case 44; + } + case 44: { + if (la == null) { currentState = 44; break; } + if (la.kind == 169) { + currentState = 492; + break; + } else { + if (set[22].Get(la.kind)) { + if (set[21].Get(la.kind)) { + stateStack.Push(45); + goto case 47; + } else { + goto case 45; + } + } else { + Error(la); + goto case 45; + } + } + } + case 45: { + PopContext(); + goto case 46; + } + case 46: { + if (la == null) { currentState = 46; break; } + Expect(38, la); // ")" + currentState = stateStack.Pop(); + break; + } + case 47: { + nextTokenIsPotentialStartOfExpression = true; + goto case 48; + } + case 48: { + if (la == null) { currentState = 48; break; } + if (set[23].Get(la.kind)) { + activeArgument = 0; + goto case 488; + } else { + if (la.kind == 22) { + activeArgument = 0; + goto case 49; + } else { + goto case 6; + } + } + } + case 49: { + if (la == null) { currentState = 49; break; } + Expect(22, la); // "," + currentState = 50; + break; + } + case 50: { + activeArgument++; + goto case 51; + } + case 51: { + nextTokenIsPotentialStartOfExpression = true; + goto case 52; + } + case 52: { + if (la == null) { currentState = 52; break; } + if (set[23].Get(la.kind)) { + stateStack.Push(53); + goto case 55; + } else { + goto case 53; + } + } + case 53: { + if (la == null) { currentState = 53; break; } + if (la.kind == 22) { + currentState = 54; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 54: { + activeArgument++; + goto case 51; + } + case 55: { + PushContext(Context.Expression, la, t); + goto case 56; + } + case 56: { + stateStack.Push(57); + goto case 75; + } + case 57: { + if (la == null) { currentState = 57; break; } + if (set[25].Get(la.kind)) { + stateStack.Push(56); + goto case 58; + } else { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 58: { + if (la == null) { currentState = 58; break; } + if (la.kind == 31) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 30) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 34) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 25) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 24) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 32) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 154) { + goto case 74; + } else { + if (la.kind == 20) { + goto case 73; + } else { + if (la.kind == 41) { + goto case 72; + } else { + if (la.kind == 40) { + goto case 71; + } else { + if (la.kind == 39) { + currentState = 70; + break; + } else { + if (la.kind == 43) { + goto case 69; + } else { + if (la.kind == 42) { + goto case 68; + } else { + if (la.kind == 150) { + goto case 67; + } else { + if (la.kind == 23) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 60) { + goto case 66; + } else { + if (la.kind == 61) { + goto case 65; + } else { + if (la.kind == 175) { + goto case 64; + } else { + if (la.kind == 177) { + goto case 63; + } else { + if (la.kind == 236) { + goto case 62; + } else { + if (la.kind == 44) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 45) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 144) { + goto case 61; + } else { + if (la.kind == 145) { + goto case 60; + } else { + if (la.kind == 47) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 49) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 50) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 51) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 46) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 48) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 54) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 52) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 53) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 216) { + goto case 59; + } else { + if (la.kind == 55) { + currentState = stateStack.Pop(); + break; + } else { + goto case 6; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + case 59: { + if (la == null) { currentState = 59; break; } + currentState = stateStack.Pop(); + break; + } + case 60: { + if (la == null) { currentState = 60; break; } + currentState = stateStack.Pop(); + break; + } + case 61: { + if (la == null) { currentState = 61; break; } + currentState = stateStack.Pop(); + break; + } + case 62: { + if (la == null) { currentState = 62; break; } + currentState = stateStack.Pop(); + break; + } + case 63: { + if (la == null) { currentState = 63; break; } + currentState = stateStack.Pop(); + break; + } + case 64: { + if (la == null) { currentState = 64; break; } + currentState = stateStack.Pop(); + break; + } + case 65: { + if (la == null) { currentState = 65; break; } + currentState = stateStack.Pop(); + break; + } + case 66: { + if (la == null) { currentState = 66; break; } + currentState = stateStack.Pop(); + break; + } + case 67: { + if (la == null) { currentState = 67; break; } + currentState = stateStack.Pop(); + break; + } + case 68: { + if (la == null) { currentState = 68; break; } + currentState = stateStack.Pop(); + break; + } + case 69: { + if (la == null) { currentState = 69; break; } + currentState = stateStack.Pop(); + break; + } + case 70: { + wasNormalAttribute = false; + currentState = stateStack.Pop(); + goto switchlbl; + } + case 71: { + if (la == null) { currentState = 71; break; } + currentState = stateStack.Pop(); + break; + } + case 72: { + if (la == null) { currentState = 72; break; } + currentState = stateStack.Pop(); + break; + } + case 73: { + if (la == null) { currentState = 73; break; } + currentState = stateStack.Pop(); + break; + } + case 74: { + if (la == null) { currentState = 74; break; } + currentState = stateStack.Pop(); + break; + } + case 75: { + PushContext(Context.Expression, la, t); + goto case 76; + } + case 76: { + nextTokenIsPotentialStartOfExpression = true; + goto case 77; + } + case 77: { + if (la == null) { currentState = 77; break; } + if (set[134].Get(la.kind)) { + currentState = 76; + break; + } else { + if (set[35].Get(la.kind)) { + stateStack.Push(159); + goto case 173; + } else { + if (la.kind == 220) { + currentState = 155; + break; + } else { + if (la.kind == 162) { + stateStack.Push(78); + goto case 85; + } else { + if (la.kind == 35) { + stateStack.Push(78); + goto case 79; + } else { + Error(la); + goto case 78; + } + } + } + } + } + } + case 78: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 79: { + if (la == null) { currentState = 79; break; } + Expect(35, la); // "{" + currentState = 80; + break; + } + case 80: { + nextTokenIsPotentialStartOfExpression = true; + goto case 81; + } + case 81: { + if (la == null) { currentState = 81; break; } + if (set[23].Get(la.kind)) { + goto case 83; + } else { + goto case 82; + } + } + case 82: { + if (la == null) { currentState = 82; break; } + Expect(36, la); // "}" + currentState = stateStack.Pop(); + break; + } + case 83: { + stateStack.Push(84); + goto case 55; + } + case 84: { + if (la == null) { currentState = 84; break; } + if (la.kind == 22) { + currentState = 83; + break; + } else { + goto case 82; + } + } + case 85: { + if (la == null) { currentState = 85; break; } + Expect(162, la); // "New" + currentState = 86; + break; + } + case 86: { + PushContext(Context.ObjectCreation, la, t); + goto case 87; + } + case 87: { + if (la == null) { currentState = 87; break; } + if (set[16].Get(la.kind)) { + stateStack.Push(146); + goto case 37; + } else { + if (la.kind == 233) { + PushContext(Context.ObjectInitializer, la, t); + goto case 90; + } else { + goto case 88; + } + } + } + case 88: { + Error(la); + goto case 89; + } + case 89: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 90: { + if (la == null) { currentState = 90; break; } + Expect(233, la); // "With" + currentState = 91; + break; + } + case 91: { + stateStack.Push(92); + goto case 93; + } + case 92: { + PopContext(); + goto case 89; + } + case 93: { + if (la == null) { currentState = 93; break; } + Expect(35, la); // "{" + currentState = 94; + break; + } + case 94: { + if (la == null) { currentState = 94; break; } + if (la.kind == 26 || la.kind == 147) { + goto case 95; + } else { + goto case 82; + } + } + case 95: { + if (la == null) { currentState = 95; break; } + if (la.kind == 147) { + currentState = 96; + break; + } else { + goto case 96; + } + } + case 96: { + if (la == null) { currentState = 96; break; } + Expect(26, la); // "." + currentState = 97; + break; + } + case 97: { + stateStack.Push(98); + goto case 101; + } + case 98: { + if (la == null) { currentState = 98; break; } + Expect(20, la); // "=" + currentState = 99; + break; + } + case 99: { + stateStack.Push(100); + goto case 55; + } + case 100: { + if (la == null) { currentState = 100; break; } + if (la.kind == 22) { + currentState = 95; + break; + } else { + goto case 82; + } + } + case 101: { + if (la == null) { currentState = 101; break; } + if (la.kind == 2) { + goto case 145; + } else { + if (la.kind == 56) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 57) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 58) { + goto case 144; + } else { + if (la.kind == 59) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 60) { + goto case 66; + } else { + if (la.kind == 61) { + goto case 65; + } else { + if (la.kind == 62) { + goto case 143; + } else { + if (la.kind == 63) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 64) { + goto case 142; + } else { + if (la.kind == 65) { + goto case 141; + } else { + if (la.kind == 66) { + goto case 140; + } else { + if (la.kind == 67) { + goto case 139; + } else { + if (la.kind == 68) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 69) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 70) { + goto case 138; + } else { + if (la.kind == 71) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 72) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 73) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 74) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 75) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 76) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 77) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 78) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 79) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 80) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 81) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 82) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 83) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 84) { + goto case 137; + } else { + if (la.kind == 85) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 86) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 87) { + goto case 136; + } else { + if (la.kind == 88) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 89) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 90) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 91) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 92) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 93) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 94) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 95) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 96) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 97) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 98) { + goto case 135; + } else { + if (la.kind == 99) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 100) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 101) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 102) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 103) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 104) { + goto case 134; + } else { + if (la.kind == 105) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 106) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 107) { + goto case 133; + } else { + if (la.kind == 108) { + goto case 132; + } else { + if (la.kind == 109) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 110) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 111) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 112) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 113) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 114) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 115) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 116) { + goto case 131; + } else { + if (la.kind == 117) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 118) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 119) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 120) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 121) { + goto case 130; + } else { + if (la.kind == 122) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 123) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 124) { + goto case 129; + } else { + if (la.kind == 125) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 126) { + goto case 128; + } else { + if (la.kind == 127) { + goto case 127; + } else { + if (la.kind == 128) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 129) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 130) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 131) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 132) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 133) { + goto case 126; + } else { + if (la.kind == 134) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 135) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 136) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 137) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 138) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 139) { + goto case 125; + } else { + if (la.kind == 140) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 141) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 142) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 143) { + goto case 124; + } else { + if (la.kind == 144) { + goto case 61; + } else { + if (la.kind == 145) { + goto case 60; + } else { + if (la.kind == 146) { + goto case 123; + } else { + if (la.kind == 147) { + goto case 122; + } else { + if (la.kind == 148) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 149) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 150) { + goto case 67; + } else { + if (la.kind == 151) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 152) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 153) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 154) { + goto case 74; + } else { + if (la.kind == 155) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 156) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 157) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 158) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 159) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 160) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 161) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 162) { + goto case 121; + } else { + if (la.kind == 163) { + goto case 120; + } else { + if (la.kind == 164) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 165) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 166) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 167) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 168) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 169) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 170) { + goto case 119; + } else { + if (la.kind == 171) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 172) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 173) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 174) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 175) { + goto case 64; + } else { + if (la.kind == 176) { + goto case 118; + } else { + if (la.kind == 177) { + goto case 63; + } else { + if (la.kind == 178) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 179) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 180) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 181) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 182) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 183) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 184) { + goto case 117; + } else { + if (la.kind == 185) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 186) { + goto case 116; + } else { + if (la.kind == 187) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 188) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 189) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 190) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 191) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 192) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 193) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 194) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 195) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 196) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 197) { + goto case 115; + } else { + if (la.kind == 198) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 199) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 200) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 201) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 202) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 203) { + goto case 114; + } else { + if (la.kind == 204) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 205) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 206) { + goto case 113; + } else { + if (la.kind == 207) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 208) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 209) { + goto case 112; + } else { + if (la.kind == 210) { + goto case 111; + } else { + if (la.kind == 211) { + goto case 110; + } else { + if (la.kind == 212) { + goto case 109; + } else { + if (la.kind == 213) { + goto case 108; + } else { + if (la.kind == 214) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 215) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 216) { + goto case 59; + } else { + if (la.kind == 217) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 218) { + goto case 107; + } else { + if (la.kind == 219) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 220) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 221) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 222) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 223) { + goto case 106; + } else { + if (la.kind == 224) { + goto case 105; + } else { + if (la.kind == 225) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 226) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 227) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 228) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 229) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 230) { + goto case 104; + } else { + if (la.kind == 231) { + goto case 103; + } else { + if (la.kind == 232) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 233) { + goto case 102; + } else { + if (la.kind == 234) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 235) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 236) { + goto case 62; + } else { + if (la.kind == 237) { + currentState = stateStack.Pop(); + break; + } else { + goto case 6; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + case 102: { + if (la == null) { currentState = 102; break; } + currentState = stateStack.Pop(); + break; + } + case 103: { + if (la == null) { currentState = 103; break; } + currentState = stateStack.Pop(); + break; + } + case 104: { + if (la == null) { currentState = 104; break; } + currentState = stateStack.Pop(); + break; + } + case 105: { + if (la == null) { currentState = 105; break; } + currentState = stateStack.Pop(); + break; + } + case 106: { + if (la == null) { currentState = 106; break; } + currentState = stateStack.Pop(); + break; + } + case 107: { + if (la == null) { currentState = 107; break; } + currentState = stateStack.Pop(); + break; + } + case 108: { + if (la == null) { currentState = 108; break; } + currentState = stateStack.Pop(); + break; + } + case 109: { + if (la == null) { currentState = 109; break; } + currentState = stateStack.Pop(); + break; + } + case 110: { + if (la == null) { currentState = 110; break; } + currentState = stateStack.Pop(); + break; + } + case 111: { + if (la == null) { currentState = 111; break; } + currentState = stateStack.Pop(); + break; + } + case 112: { + if (la == null) { currentState = 112; break; } + currentState = stateStack.Pop(); + break; + } + case 113: { + if (la == null) { currentState = 113; break; } + currentState = stateStack.Pop(); + break; + } + case 114: { + if (la == null) { currentState = 114; break; } + currentState = stateStack.Pop(); + break; + } + case 115: { + if (la == null) { currentState = 115; break; } + currentState = stateStack.Pop(); + break; + } + case 116: { + if (la == null) { currentState = 116; break; } + currentState = stateStack.Pop(); + break; + } + case 117: { + if (la == null) { currentState = 117; break; } + currentState = stateStack.Pop(); + break; + } + case 118: { + if (la == null) { currentState = 118; break; } + currentState = stateStack.Pop(); + break; + } + case 119: { + if (la == null) { currentState = 119; break; } + currentState = stateStack.Pop(); + break; + } + case 120: { + if (la == null) { currentState = 120; break; } + currentState = stateStack.Pop(); + break; + } + case 121: { + if (la == null) { currentState = 121; break; } + currentState = stateStack.Pop(); + break; + } + case 122: { + if (la == null) { currentState = 122; break; } + currentState = stateStack.Pop(); + break; + } + case 123: { + if (la == null) { currentState = 123; break; } + currentState = stateStack.Pop(); + break; + } + case 124: { + if (la == null) { currentState = 124; break; } + currentState = stateStack.Pop(); + break; + } + case 125: { + if (la == null) { currentState = 125; break; } + currentState = stateStack.Pop(); + break; + } + case 126: { + if (la == null) { currentState = 126; break; } + currentState = stateStack.Pop(); + break; + } + case 127: { + if (la == null) { currentState = 127; break; } + currentState = stateStack.Pop(); + break; + } + case 128: { + if (la == null) { currentState = 128; break; } + currentState = stateStack.Pop(); + break; + } + case 129: { + if (la == null) { currentState = 129; break; } + currentState = stateStack.Pop(); + break; + } + case 130: { + if (la == null) { currentState = 130; break; } + currentState = stateStack.Pop(); + break; + } + case 131: { + if (la == null) { currentState = 131; break; } + currentState = stateStack.Pop(); + break; + } + case 132: { + if (la == null) { currentState = 132; break; } + currentState = stateStack.Pop(); + break; + } + case 133: { + if (la == null) { currentState = 133; break; } + currentState = stateStack.Pop(); + break; + } + case 134: { + if (la == null) { currentState = 134; break; } + currentState = stateStack.Pop(); + break; + } + case 135: { + if (la == null) { currentState = 135; break; } + currentState = stateStack.Pop(); + break; + } + case 136: { + if (la == null) { currentState = 136; break; } + currentState = stateStack.Pop(); + break; + } + case 137: { + if (la == null) { currentState = 137; break; } + currentState = stateStack.Pop(); + break; + } + case 138: { + if (la == null) { currentState = 138; break; } + currentState = stateStack.Pop(); + break; + } + case 139: { + if (la == null) { currentState = 139; break; } + currentState = stateStack.Pop(); + break; + } + case 140: { + if (la == null) { currentState = 140; break; } + currentState = stateStack.Pop(); + break; + } + case 141: { + if (la == null) { currentState = 141; break; } + currentState = stateStack.Pop(); + break; + } + case 142: { + if (la == null) { currentState = 142; break; } + currentState = stateStack.Pop(); + break; + } + case 143: { + if (la == null) { currentState = 143; break; } + currentState = stateStack.Pop(); + break; + } + case 144: { + if (la == null) { currentState = 144; break; } + currentState = stateStack.Pop(); + break; + } + case 145: { + if (la == null) { currentState = 145; break; } + currentState = stateStack.Pop(); + break; + } + case 146: { + if (la == null) { currentState = 146; break; } + if (la.kind == 35 || la.kind == 126 || la.kind == 233) { + if (la.kind == 126) { + PushContext(Context.CollectionInitializer, la, t); + goto case 151; + } else { + if (la.kind == 35) { + PushContext(Context.CollectionInitializer, la, t); + stateStack.Push(150); + goto case 79; + } else { + if (la.kind == 233) { + PushContext(Context.ObjectInitializer, la, t); + goto case 147; + } else { + goto case 88; + } + } + } + } else { + goto case 89; + } + } + case 147: { + if (la == null) { currentState = 147; break; } + Expect(233, la); // "With" + currentState = 148; + break; + } + case 148: { + stateStack.Push(149); + goto case 93; + } + case 149: { + PopContext(); + goto case 89; + } + case 150: { + PopContext(); + goto case 89; + } + case 151: { + if (la == null) { currentState = 151; break; } + Expect(126, la); // "From" + currentState = 152; + break; + } + case 152: { + if (la == null) { currentState = 152; break; } + if (la.kind == 35) { + stateStack.Push(153); + goto case 79; + } else { + if (set[30].Get(la.kind)) { + currentState = endOfStatementTerminatorAndBlock; /* leave this block */ + InformToken(t); /* process From again*/ + /* for processing current token (la): go to the position after processing End */ + goto switchlbl; + + } else { + Error(la); + goto case 153; + } + } + } + case 153: { + PopContext(); + goto case 89; + } + case 154: { + if (la == null) { currentState = 154; break; } + currentState = 153; + break; + } + case 155: { + stateStack.Push(156); + goto case 75; + } + case 156: { + if (la == null) { currentState = 156; break; } + Expect(144, la); // "Is" + currentState = 157; + break; + } + case 157: { + PushContext(Context.Type, la, t); + stateStack.Push(158); + goto case 37; + } + case 158: { + PopContext(); + goto case 78; + } + case 159: { + if (la == null) { currentState = 159; break; } + if (set[32].Get(la.kind)) { + stateStack.Push(159); + goto case 160; + } else { + goto case 78; + } + } + case 160: { + if (la == null) { currentState = 160; break; } + if (la.kind == 37) { + currentState = 165; + break; + } else { + if (set[135].Get(la.kind)) { + currentState = 161; + break; + } else { + goto case 6; + } + } + } + case 161: { + nextTokenIsStartOfImportsOrAccessExpression = true; + goto case 162; + } + case 162: { + if (la == null) { currentState = 162; break; } + if (la.kind == 10) { + currentState = 163; + break; + } else { + goto case 163; + } + } + case 163: { + stateStack.Push(164); + goto case 101; + } + case 164: { + if (la == null) { currentState = 164; break; } + if (la.kind == 11) { + currentState = stateStack.Pop(); + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 165: { + PushContext(Context.Expression, la, t); + nextTokenIsPotentialStartOfExpression = true; + goto case 166; + } + case 166: { + if (la == null) { currentState = 166; break; } + if (la.kind == 169) { + currentState = 168; + break; + } else { + if (set[22].Get(la.kind)) { + if (set[21].Get(la.kind)) { + stateStack.Push(167); + goto case 47; + } else { + goto case 167; + } + } else { + Error(la); + goto case 167; + } + } + } + case 167: { + PopContext(); + goto case 46; + } + case 168: { + PushContext(Context.Type, la, t); + stateStack.Push(169); + goto case 37; + } + case 169: { + PopContext(); + goto case 170; + } + case 170: { + if (la == null) { currentState = 170; break; } + if (la.kind == 22) { + currentState = 171; + break; + } else { + goto case 167; + } + } + case 171: { + PushContext(Context.Type, la, t); + stateStack.Push(172); + goto case 37; + } + case 172: { + PopContext(); + goto case 170; + } + case 173: { + PushContext(Context.Expression, la, t); + nextTokenIsPotentialStartOfExpression = true; + goto case 174; + } + case 174: { + if (la == null) { currentState = 174; break; } + if (set[136].Get(la.kind)) { + currentState = 175; + break; + } else { + if (la.kind == 37) { + currentState = 484; + break; + } else { + if (set[137].Get(la.kind)) { + currentState = 175; + break; + } else { + if (set[133].Get(la.kind)) { + currentState = 175; + break; + } else { + if (set[135].Get(la.kind)) { + currentState = 480; + break; + } else { + if (la.kind == 129) { + currentState = 477; + break; + } else { + if (la.kind == 237) { + currentState = 474; + break; + } else { + if (set[83].Get(la.kind)) { + stateStack.Push(175); + nextTokenIsPotentialStartOfExpression = true; + PushContext(Context.Xml, la, t); + goto case 457; + } else { + if (la.kind == 127 || la.kind == 210) { + stateStack.Push(175); + goto case 252; + } else { + if (la.kind == 58 || la.kind == 126) { + stateStack.Push(175); + PushContext(Context.Query, la, t); + goto case 190; + } else { + if (set[37].Get(la.kind)) { + stateStack.Push(175); + goto case 183; + } else { + if (la.kind == 135) { + stateStack.Push(175); + goto case 176; + } else { + Error(la); + goto case 175; + } + } + } + } + } + } + } + } + } + } + } + } + } + case 175: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 176: { + if (la == null) { currentState = 176; break; } + Expect(135, la); // "If" + currentState = 177; + break; + } + case 177: { + if (la == null) { currentState = 177; break; } + Expect(37, la); // "(" + currentState = 178; + break; + } + case 178: { + stateStack.Push(179); + goto case 55; + } + case 179: { + if (la == null) { currentState = 179; break; } + Expect(22, la); // "," + currentState = 180; + break; + } + case 180: { + stateStack.Push(181); + goto case 55; + } + case 181: { + if (la == null) { currentState = 181; break; } + if (la.kind == 22) { + currentState = 182; + break; + } else { + goto case 46; + } + } + case 182: { + stateStack.Push(46); + goto case 55; + } + case 183: { + if (la == null) { currentState = 183; break; } + if (set[138].Get(la.kind)) { + currentState = 189; + break; + } else { + if (la.kind == 94 || la.kind == 106 || la.kind == 219) { + currentState = 184; + break; + } else { + goto case 6; + } + } + } + case 184: { + if (la == null) { currentState = 184; break; } + Expect(37, la); // "(" + currentState = 185; + break; + } + case 185: { + stateStack.Push(186); + goto case 55; + } + case 186: { + if (la == null) { currentState = 186; break; } + Expect(22, la); // "," + currentState = 187; + break; + } + case 187: { + PushContext(Context.Type, la, t); + stateStack.Push(188); + goto case 37; + } + case 188: { + PopContext(); + goto case 46; + } + case 189: { + if (la == null) { currentState = 189; break; } + Expect(37, la); // "(" + currentState = 182; + break; + } + case 190: { + if (la == null) { currentState = 190; break; } + if (la.kind == 126) { + stateStack.Push(191); + goto case 251; + } else { + if (la.kind == 58) { + stateStack.Push(191); + goto case 250; + } else { + Error(la); + goto case 191; + } + } + } + case 191: { + if (la == null) { currentState = 191; break; } + if (set[38].Get(la.kind)) { + stateStack.Push(191); + goto case 192; + } else { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 192: { + if (la == null) { currentState = 192; break; } + if (la.kind == 126) { + currentState = 248; + break; + } else { + if (la.kind == 58) { + currentState = 244; + break; + } else { + if (la.kind == 197) { + currentState = 242; + break; + } else { + if (la.kind == 107) { + goto case 133; + } else { + if (la.kind == 230) { + currentState = 55; + break; + } else { + if (la.kind == 176) { + currentState = 238; + break; + } else { + if (la.kind == 203 || la.kind == 212) { + currentState = 236; + break; + } else { + if (la.kind == 148) { + currentState = 234; + break; + } else { + if (la.kind == 133) { + currentState = 206; + break; + } else { + if (la.kind == 146) { + currentState = 193; + break; + } else { + goto case 6; + } + } + } + } + } + } + } + } + } + } + } + case 193: { + stateStack.Push(194); + goto case 199; + } + case 194: { + if (la == null) { currentState = 194; break; } + Expect(171, la); // "On" + currentState = 195; + break; + } + case 195: { + stateStack.Push(196); + goto case 55; + } + case 196: { + if (la == null) { currentState = 196; break; } + Expect(116, la); // "Equals" + currentState = 197; + break; + } + case 197: { + stateStack.Push(198); + goto case 55; + } + case 198: { + if (la == null) { currentState = 198; break; } + if (la.kind == 22) { + currentState = 195; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 199: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(200); + goto case 205; + } + case 200: { + PopContext(); + goto case 201; + } + case 201: { + if (la == null) { currentState = 201; break; } + if (la.kind == 63) { + currentState = 203; + break; + } else { + goto case 202; + } + } + case 202: { + if (la == null) { currentState = 202; break; } + Expect(138, la); // "In" + currentState = 55; + break; + } + case 203: { + PushContext(Context.Type, la, t); + stateStack.Push(204); + goto case 37; + } + case 204: { + PopContext(); + goto case 202; + } + case 205: { + if (la == null) { currentState = 205; break; } + if (set[123].Get(la.kind)) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 98) { + goto case 135; + } else { + goto case 6; + } + } + } + case 206: { + SetIdentifierExpected(la); + nextTokenIsPotentialStartOfExpression = true; + goto case 207; + } + case 207: { + if (la == null) { currentState = 207; break; } + if (la.kind == 146) { + goto case 226; + } else { + if (set[40].Get(la.kind)) { + if (la.kind == 70) { + currentState = 209; + break; + } else { + if (set[40].Get(la.kind)) { + goto case 224; + } else { + Error(la); + goto case 208; + } + } + } else { + goto case 6; + } + } + } + case 208: { + if (la == null) { currentState = 208; break; } + Expect(70, la); // "By" + currentState = 209; + break; + } + case 209: { + stateStack.Push(210); + goto case 213; + } + case 210: { + if (la == null) { currentState = 210; break; } + if (la.kind == 22) { + currentState = 209; + break; + } else { + Expect(143, la); // "Into" + currentState = 211; + break; + } + } + case 211: { + stateStack.Push(212); + goto case 213; + } + case 212: { + if (la == null) { currentState = 212; break; } + if (la.kind == 22) { + currentState = 211; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 213: { + SetIdentifierExpected(la); + nextTokenIsPotentialStartOfExpression = true; + goto case 214; + } + case 214: { + if (la == null) { currentState = 214; break; } + if (set[6].Get(la.kind)) { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(217); + goto case 205; + } else { + goto case 215; + } + } + case 215: { + stateStack.Push(216); + goto case 55; + } + case 216: { + if (!isAlreadyInExpr) PopContext(); isAlreadyInExpr = false; + currentState = stateStack.Pop(); + goto switchlbl; + } + case 217: { + nextTokenIsPotentialStartOfExpression = true; + goto case 218; + } + case 218: { + if (la == null) { currentState = 218; break; } + if (set[42].Get(la.kind)) { + PopContext(); isAlreadyInExpr = true; + goto case 219; + } else { + goto case 215; + } + } + case 219: { + if (la == null) { currentState = 219; break; } + if (la.kind == 63) { + currentState = 221; + break; + } else { + if (la.kind == 20) { + currentState = 215; + break; + } else { + if (set[43].Get(la.kind)) { + currentState = endOfStatementTerminatorAndBlock; /* leave this block */ + InformToken(t); /* process Identifier again*/ + /* for processing current token (la): go to the position after processing End */ + goto switchlbl; + + } else { + Error(la); + goto case 215; + } + } + } + } + case 220: { + if (la == null) { currentState = 220; break; } + currentState = 215; + break; + } + case 221: { + PushContext(Context.Type, la, t); + stateStack.Push(222); + goto case 37; + } + case 222: { + PopContext(); + goto case 223; + } + case 223: { + if (la == null) { currentState = 223; break; } + Expect(20, la); // "=" + currentState = 215; + break; + } + case 224: { + stateStack.Push(225); + goto case 213; + } + case 225: { + if (la == null) { currentState = 225; break; } + if (la.kind == 22) { + currentState = 224; + break; + } else { + goto case 208; + } + } + case 226: { + stateStack.Push(227); + goto case 233; + } + case 227: { + if (la == null) { currentState = 227; break; } + if (la.kind == 133 || la.kind == 146) { + if (la.kind == 133) { + currentState = 231; + break; + } else { + if (la.kind == 146) { + goto case 226; + } else { + Error(la); + goto case 227; + } + } + } else { + goto case 228; + } + } + case 228: { + if (la == null) { currentState = 228; break; } + Expect(143, la); // "Into" + currentState = 229; + break; + } + case 229: { + stateStack.Push(230); + goto case 213; + } + case 230: { + if (la == null) { currentState = 230; break; } + if (la.kind == 22) { + currentState = 229; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 231: { + stateStack.Push(232); + goto case 233; + } + case 232: { + stateStack.Push(227); + goto case 228; + } + case 233: { + if (la == null) { currentState = 233; break; } + Expect(146, la); // "Join" + currentState = 193; + break; + } + case 234: { + stateStack.Push(235); + goto case 213; + } + case 235: { + if (la == null) { currentState = 235; break; } + if (la.kind == 22) { + currentState = 234; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 236: { + nextTokenIsPotentialStartOfExpression = true; + goto case 237; + } + case 237: { + if (la == null) { currentState = 237; break; } + if (la.kind == 231) { + currentState = 55; + break; + } else { + goto case 55; + } + } + case 238: { + if (la == null) { currentState = 238; break; } + Expect(70, la); // "By" + currentState = 239; + break; + } + case 239: { + stateStack.Push(240); + goto case 55; + } + case 240: { + if (la == null) { currentState = 240; break; } + if (la.kind == 64) { + currentState = 241; + break; + } else { + if (la.kind == 104) { + currentState = 241; + break; + } else { + Error(la); + goto case 241; + } + } + } + case 241: { + if (la == null) { currentState = 241; break; } + if (la.kind == 22) { + currentState = 239; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 242: { + stateStack.Push(243); + goto case 213; + } + case 243: { + if (la == null) { currentState = 243; break; } + if (la.kind == 22) { + currentState = 242; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 244: { + stateStack.Push(245); + goto case 199; + } + case 245: { + if (la == null) { currentState = 245; break; } + if (set[38].Get(la.kind)) { + stateStack.Push(245); + goto case 192; + } else { + Expect(143, la); // "Into" + currentState = 246; + break; + } + } + case 246: { + stateStack.Push(247); + goto case 213; + } + case 247: { + if (la == null) { currentState = 247; break; } + if (la.kind == 22) { + currentState = 246; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 248: { + stateStack.Push(249); + goto case 199; + } + case 249: { + if (la == null) { currentState = 249; break; } + if (la.kind == 22) { + currentState = 248; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 250: { + if (la == null) { currentState = 250; break; } + Expect(58, la); // "Aggregate" + currentState = 244; + break; + } + case 251: { + if (la == null) { currentState = 251; break; } + Expect(126, la); // "From" + currentState = 248; + break; + } + case 252: { + if (la == null) { currentState = 252; break; } + if (la.kind == 210) { + currentState = 452; + break; + } else { + if (la.kind == 127) { + currentState = 253; + break; + } else { + goto case 6; + } + } + } + case 253: { + stateStack.Push(254); + goto case 424; + } + case 254: { + nextTokenIsPotentialStartOfExpression = true; + goto case 255; + } + case 255: { + if (la == null) { currentState = 255; break; } + if (set[23].Get(la.kind)) { + goto case 55; + } else { + if (la.kind == 1 || la.kind == 21 || la.kind == 63) { + if (la.kind == 63) { + currentState = 422; + break; + } else { + goto case 256; + } + } else { + goto case 6; + } + } + } + case 256: { + stateStack.Push(257); + goto case 259; + } + case 257: { + if (la == null) { currentState = 257; break; } + Expect(113, la); // "End" + currentState = 258; + break; + } + case 258: { + if (la == null) { currentState = 258; break; } + Expect(127, la); // "Function" + currentState = stateStack.Pop(); + break; + } + case 259: { + PushContext(Context.Body, la, t); + goto case 260; + } + case 260: { + stateStack.Push(261); + goto case 23; + } + case 261: { + nextTokenIsPotentialStartOfExpression = true; + goto case 262; + } + case 262: { + if (la == null) { currentState = 262; break; } + if (set[139].Get(la.kind)) { + if (set[69].Get(la.kind)) { + if (set[50].Get(la.kind)) { + stateStack.Push(260); + goto case 267; + } else { + goto case 260; + } + } else { + if (la.kind == 113) { + currentState = 265; + break; + } else { + goto case 264; + } + } + } else { + goto case 263; + } + } + case 263: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 264: { + Error(la); + goto case 261; + } + case 265: { + if (la == null) { currentState = 265; break; } + if (la.kind == 1 || la.kind == 21) { + goto case 260; + } else { + if (set[49].Get(la.kind)) { + currentState = endOfStatementTerminatorAndBlock; /* leave this block */ + InformToken(t); /* process End again*/ + /* for processing current token (la): go to the position after processing End */ + goto switchlbl; + + } else { + goto case 264; + } + } + } + case 266: { + if (la == null) { currentState = 266; break; } + currentState = 261; + break; + } + case 267: { + nextTokenIsPotentialStartOfExpression = true; + goto case 268; + } + case 268: { + if (la == null) { currentState = 268; break; } + if (la.kind == 88 || la.kind == 105 || la.kind == 204) { + currentState = 399; + break; + } else { + if (la.kind == 211 || la.kind == 233) { + currentState = 395; + break; + } else { + if (la.kind == 56 || la.kind == 193) { + currentState = 393; + break; + } else { + if (la.kind == 189) { + currentState = 388; + break; + } else { + if (la.kind == 135) { + currentState = 370; + break; + } else { + if (la.kind == 197) { + currentState = 354; + break; + } else { + if (la.kind == 231) { + currentState = 350; + break; + } else { + if (la.kind == 108) { + currentState = 344; + break; + } else { + if (la.kind == 124) { + currentState = 317; + break; + } else { + if (la.kind == 118 || la.kind == 171 || la.kind == 194) { + if (la.kind == 118 || la.kind == 171) { + if (la.kind == 171) { + currentState = 313; + break; + } else { + goto case 313; + } + } else { + if (la.kind == 194) { + currentState = 311; + break; + } else { + goto case 6; + } + } + } else { + if (la.kind == 215) { + currentState = 309; + break; + } else { + if (la.kind == 218) { + currentState = 296; + break; + } else { + if (set[140].Get(la.kind)) { + if (la.kind == 132) { + currentState = 293; + break; + } else { + if (la.kind == 120) { + currentState = 292; + break; + } else { + if (la.kind == 89) { + currentState = 291; + break; + } else { + if (la.kind == 206) { + goto case 113; + } else { + if (la.kind == 195) { + currentState = 288; + break; + } else { + goto case 6; + } + } + } + } + } + } else { + if (la.kind == 191) { + currentState = 286; + break; + } else { + if (la.kind == 117) { + currentState = 284; + break; + } else { + if (la.kind == 226) { + currentState = 269; + break; + } else { + if (set[141].Get(la.kind)) { + if (la.kind == 73) { + currentState = 55; + break; + } else { + goto case 55; + } + } else { + goto case 6; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + case 269: { + stateStack.Push(270); + SetIdentifierExpected(la); + nextTokenIsPotentialStartOfExpression = true; + goto case 273; + } + case 270: { + if (la == null) { currentState = 270; break; } + if (la.kind == 22) { + currentState = 269; + break; + } else { + stateStack.Push(271); + goto case 259; + } + } + case 271: { + if (la == null) { currentState = 271; break; } + Expect(113, la); // "End" + currentState = 272; + break; + } + case 272: { + if (la == null) { currentState = 272; break; } + Expect(226, la); // "Using" + currentState = stateStack.Pop(); + break; + } + case 273: { + if (la == null) { currentState = 273; break; } + if (set[6].Get(la.kind)) { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(276); + goto case 205; + } else { + goto case 274; + } + } + case 274: { + stateStack.Push(275); + goto case 55; + } + case 275: { + if (!isAlreadyInExpr) PopContext(); isAlreadyInExpr = false; + currentState = stateStack.Pop(); + goto switchlbl; + } + case 276: { + nextTokenIsPotentialStartOfExpression = true; + goto case 277; + } + case 277: { + if (la == null) { currentState = 277; break; } + if (set[42].Get(la.kind)) { + PopContext(); isAlreadyInExpr = true; + goto case 278; + } else { + goto case 274; + } + } + case 278: { + if (la == null) { currentState = 278; break; } + if (la.kind == 63) { + currentState = 280; + break; + } else { + if (la.kind == 20) { + currentState = 274; + break; + } else { + if (set[43].Get(la.kind)) { + currentState = endOfStatementTerminatorAndBlock; /* leave this block */ + InformToken(t); /* process Identifier again*/ + /* for processing current token (la): go to the position after processing End */ + goto switchlbl; + + } else { + Error(la); + goto case 274; + } + } + } + } + case 279: { + if (la == null) { currentState = 279; break; } + currentState = 274; + break; + } + case 280: { + nextTokenIsPotentialStartOfExpression = true; + goto case 281; + } + case 281: { + if (la == null) { currentState = 281; break; } + if (set[16].Get(la.kind)) { + PushContext(Context.Type, la, t); + stateStack.Push(282); + goto case 37; + } else { + goto case 274; + } + } + case 282: { + PopContext(); + goto case 283; + } + case 283: { + if (la == null) { currentState = 283; break; } + Expect(20, la); // "=" + currentState = 274; + break; + } + case 284: { + stateStack.Push(285); + goto case 55; + } + case 285: { + if (la == null) { currentState = 285; break; } + if (la.kind == 22) { + currentState = 284; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 286: { + nextTokenIsPotentialStartOfExpression = true; + goto case 287; + } + case 287: { + if (la == null) { currentState = 287; break; } + if (la.kind == 184) { + currentState = 55; + break; + } else { + goto case 55; + } + } + case 288: { + PushContext(Context.Expression, la, t); + nextTokenIsPotentialStartOfExpression = true; + goto case 289; + } + case 289: { + if (la == null) { currentState = 289; break; } + if (set[23].Get(la.kind)) { + stateStack.Push(290); + goto case 55; + } else { + goto case 290; + } + } + case 290: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 291: { + if (la == null) { currentState = 291; break; } + if (la.kind == 108) { + goto case 132; + } else { + if (la.kind == 124) { + goto case 129; + } else { + if (la.kind == 231) { + goto case 103; + } else { + goto case 6; + } + } + } + } + case 292: { + if (la == null) { currentState = 292; break; } + if (la.kind == 108) { + goto case 132; + } else { + if (la.kind == 124) { + goto case 129; + } else { + if (la.kind == 231) { + goto case 103; + } else { + if (la.kind == 197) { + goto case 115; + } else { + if (la.kind == 210) { + goto case 111; + } else { + if (la.kind == 127) { + goto case 127; + } else { + if (la.kind == 186) { + goto case 116; + } else { + if (la.kind == 218) { + goto case 107; + } else { + goto case 6; + } + } + } + } + } + } + } + } + } + case 293: { + if (la == null) { currentState = 293; break; } + if (set[6].Get(la.kind)) { + goto case 295; + } else { + if (la.kind == 5) { + goto case 294; + } else { + goto case 6; + } + } + } + case 294: { + if (la == null) { currentState = 294; break; } + currentState = stateStack.Pop(); + break; + } + case 295: { + if (la == null) { currentState = 295; break; } + currentState = stateStack.Pop(); + break; + } + case 296: { + stateStack.Push(297); + goto case 259; + } + case 297: { + if (la == null) { currentState = 297; break; } + if (la.kind == 75) { + currentState = 301; + break; + } else { + if (la.kind == 123) { + currentState = 300; + break; + } else { + goto case 298; + } + } + } + case 298: { + if (la == null) { currentState = 298; break; } + Expect(113, la); // "End" + currentState = 299; + break; + } + case 299: { + if (la == null) { currentState = 299; break; } + Expect(218, la); // "Try" + currentState = stateStack.Pop(); + break; + } + case 300: { + stateStack.Push(298); + goto case 259; + } + case 301: { + SetIdentifierExpected(la); + goto case 302; + } + case 302: { + if (la == null) { currentState = 302; break; } + if (set[6].Get(la.kind)) { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(305); + goto case 205; + } else { + goto case 303; + } + } + case 303: { + if (la == null) { currentState = 303; break; } + if (la.kind == 229) { + currentState = 304; + break; + } else { + goto case 296; + } + } + case 304: { + stateStack.Push(296); + goto case 55; + } + case 305: { + PopContext(); + goto case 306; + } + case 306: { + if (la == null) { currentState = 306; break; } + if (la.kind == 63) { + currentState = 307; + break; + } else { + goto case 303; + } + } + case 307: { + PushContext(Context.Type, la, t); + stateStack.Push(308); + goto case 37; + } + case 308: { + PopContext(); + goto case 303; + } + case 309: { + nextTokenIsPotentialStartOfExpression = true; + goto case 310; + } + case 310: { + if (la == null) { currentState = 310; break; } + if (set[23].Get(la.kind)) { + goto case 55; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 311: { + if (la == null) { currentState = 311; break; } + if (la.kind == 163) { + goto case 120; + } else { + goto case 312; + } + } + case 312: { + if (la == null) { currentState = 312; break; } + if (la.kind == 5) { + goto case 294; + } else { + if (set[6].Get(la.kind)) { + goto case 295; + } else { + goto case 6; + } + } + } + case 313: { + if (la == null) { currentState = 313; break; } + Expect(118, la); // "Error" + currentState = 314; + break; + } + case 314: { + nextTokenIsPotentialStartOfExpression = true; + goto case 315; + } + case 315: { + if (la == null) { currentState = 315; break; } + if (set[23].Get(la.kind)) { + goto case 55; + } else { + if (la.kind == 132) { + currentState = 312; + break; + } else { + if (la.kind == 194) { + currentState = 316; + break; + } else { + goto case 6; + } + } + } + } + case 316: { + if (la == null) { currentState = 316; break; } + Expect(163, la); // "Next" + currentState = stateStack.Pop(); + break; + } + case 317: { + nextTokenIsPotentialStartOfExpression = true; + SetIdentifierExpected(la); + goto case 318; + } + case 318: { + if (la == null) { currentState = 318; break; } + if (set[35].Get(la.kind)) { + stateStack.Push(334); + goto case 328; + } else { + if (la.kind == 110) { + currentState = 319; + break; + } else { + goto case 6; + } + } + } + case 319: { + stateStack.Push(320); + goto case 328; + } + case 320: { + if (la == null) { currentState = 320; break; } + Expect(138, la); // "In" + currentState = 321; + break; + } + case 321: { + stateStack.Push(322); + goto case 55; + } + case 322: { + stateStack.Push(323); + goto case 259; + } + case 323: { + if (la == null) { currentState = 323; break; } + Expect(163, la); // "Next" + currentState = 324; + break; + } + case 324: { + nextTokenIsPotentialStartOfExpression = true; + goto case 325; + } + case 325: { + if (la == null) { currentState = 325; break; } + if (set[23].Get(la.kind)) { + goto case 326; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 326: { + stateStack.Push(327); + goto case 55; + } + case 327: { + if (la == null) { currentState = 327; break; } + if (la.kind == 22) { + currentState = 326; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 328: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(329); + goto case 173; + } + case 329: { + PopContext(); + goto case 330; + } + case 330: { + if (la == null) { currentState = 330; break; } + if (la.kind == 33) { + currentState = 331; + break; + } else { + goto case 331; + } + } + case 331: { + if (la == null) { currentState = 331; break; } + if (set[32].Get(la.kind)) { + stateStack.Push(331); + goto case 160; + } else { + if (la.kind == 63) { + currentState = 332; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + } + case 332: { + PushContext(Context.Type, la, t); + stateStack.Push(333); + goto case 37; + } + case 333: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 334: { + if (la == null) { currentState = 334; break; } + Expect(20, la); // "=" + currentState = 335; + break; + } + case 335: { + stateStack.Push(336); + goto case 55; + } + case 336: { + if (la == null) { currentState = 336; break; } + if (la.kind == 205) { + currentState = 343; + break; + } else { + goto case 337; + } + } + case 337: { + stateStack.Push(338); + goto case 259; + } + case 338: { + if (la == null) { currentState = 338; break; } + Expect(163, la); // "Next" + currentState = 339; + break; + } + case 339: { + nextTokenIsPotentialStartOfExpression = true; + goto case 340; + } + case 340: { + if (la == null) { currentState = 340; break; } + if (set[23].Get(la.kind)) { + goto case 341; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 341: { + stateStack.Push(342); + goto case 55; + } + case 342: { + if (la == null) { currentState = 342; break; } + if (la.kind == 22) { + currentState = 341; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 343: { + stateStack.Push(337); + goto case 55; + } + case 344: { + if (la == null) { currentState = 344; break; } + if (la.kind == 224 || la.kind == 231) { + currentState = 347; + break; + } else { + if (la.kind == 1 || la.kind == 21) { + stateStack.Push(345); + goto case 259; + } else { + goto case 6; + } + } + } + case 345: { + if (la == null) { currentState = 345; break; } + Expect(152, la); // "Loop" + currentState = 346; + break; + } + case 346: { + if (la == null) { currentState = 346; break; } + if (la.kind == 224 || la.kind == 231) { + currentState = 55; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 347: { + stateStack.Push(348); + goto case 55; + } + case 348: { + stateStack.Push(349); + goto case 259; + } + case 349: { + if (la == null) { currentState = 349; break; } + Expect(152, la); // "Loop" + currentState = stateStack.Pop(); + break; + } + case 350: { + stateStack.Push(351); + goto case 55; + } + case 351: { + stateStack.Push(352); + goto case 259; + } + case 352: { + if (la == null) { currentState = 352; break; } + Expect(113, la); // "End" + currentState = 353; + break; + } + case 353: { + if (la == null) { currentState = 353; break; } + Expect(231, la); // "While" + currentState = stateStack.Pop(); + break; + } + case 354: { + nextTokenIsPotentialStartOfExpression = true; + goto case 355; + } + case 355: { + if (la == null) { currentState = 355; break; } + if (la.kind == 74) { + currentState = 356; + break; + } else { + goto case 356; + } + } + case 356: { + stateStack.Push(357); + goto case 55; + } + case 357: { + stateStack.Push(358); + goto case 23; + } + case 358: { + if (la == null) { currentState = 358; break; } + if (la.kind == 74) { + currentState = 360; + break; + } else { + Expect(113, la); // "End" + currentState = 359; + break; + } + } + case 359: { + if (la == null) { currentState = 359; break; } + Expect(197, la); // "Select" + currentState = stateStack.Pop(); + break; + } + case 360: { + nextTokenIsPotentialStartOfExpression = true; + goto case 361; + } + case 361: { + if (la == null) { currentState = 361; break; } + if (la.kind == 111) { + currentState = 362; + break; + } else { + if (set[67].Get(la.kind)) { + goto case 363; + } else { + Error(la); + goto case 362; + } + } + } + case 362: { + stateStack.Push(358); + goto case 259; + } + case 363: { + nextTokenIsPotentialStartOfExpression = true; + goto case 364; + } + case 364: { + if (la == null) { currentState = 364; break; } + if (set[142].Get(la.kind)) { + if (la.kind == 144) { + currentState = 366; + break; + } else { + goto case 366; + } + } else { + if (set[23].Get(la.kind)) { + stateStack.Push(365); + goto case 55; + } else { + Error(la); + goto case 365; + } + } + } + case 365: { + if (la == null) { currentState = 365; break; } + if (la.kind == 22) { + currentState = 363; + break; + } else { + goto case 362; + } + } + case 366: { + stateStack.Push(367); + goto case 368; + } + case 367: { + stateStack.Push(365); + goto case 75; + } + case 368: { + if (la == null) { currentState = 368; break; } + if (la.kind == 20) { + goto case 73; + } else { + if (la.kind == 41) { + goto case 72; + } else { + if (la.kind == 40) { + goto case 71; + } else { + if (la.kind == 39) { + currentState = 369; + break; + } else { + if (la.kind == 42) { + goto case 68; + } else { + if (la.kind == 43) { + goto case 69; + } else { + goto case 6; + } + } + } + } + } + } + } + case 369: { + wasNormalAttribute = false; + currentState = stateStack.Pop(); + goto switchlbl; + } + case 370: { + stateStack.Push(371); + goto case 55; + } + case 371: { + if (la == null) { currentState = 371; break; } + if (la.kind == 214) { + currentState = 379; + break; + } else { + goto case 372; + } + } + case 372: { + if (la == null) { currentState = 372; break; } + if (la.kind == 1 || la.kind == 21) { + goto case 373; + } else { + goto case 6; + } + } + case 373: { + stateStack.Push(374); + goto case 259; + } + case 374: { + if (la == null) { currentState = 374; break; } + if (la.kind == 111 || la.kind == 112) { + if (la.kind == 111) { + currentState = 378; + break; + } else { + if (la.kind == 112) { + currentState = 376; + break; + } else { + Error(la); + goto case 373; + } + } + } else { + Expect(113, la); // "End" + currentState = 375; + break; + } + } + case 375: { + if (la == null) { currentState = 375; break; } + Expect(135, la); // "If" + currentState = stateStack.Pop(); + break; + } + case 376: { + stateStack.Push(377); + goto case 55; + } + case 377: { + if (la == null) { currentState = 377; break; } + if (la.kind == 214) { + currentState = 373; + break; + } else { + goto case 373; + } + } + case 378: { + if (la == null) { currentState = 378; break; } + if (la.kind == 135) { + currentState = 376; + break; + } else { + goto case 373; + } + } + case 379: { + nextTokenIsPotentialStartOfExpression = true; + goto case 380; + } + case 380: { + if (la == null) { currentState = 380; break; } + if (set[50].Get(la.kind)) { + goto case 381; + } else { + goto case 372; + } + } + case 381: { + stateStack.Push(382); + goto case 267; + } + case 382: { + if (la == null) { currentState = 382; break; } + if (la.kind == 21) { + currentState = 386; + break; + } else { + if (la.kind == 111) { + currentState = 383; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + } + case 383: { + nextTokenIsPotentialStartOfExpression = true; + goto case 384; + } + case 384: { + if (la == null) { currentState = 384; break; } + if (set[50].Get(la.kind)) { + stateStack.Push(385); + goto case 267; + } else { + goto case 385; + } + } + case 385: { + if (la == null) { currentState = 385; break; } + if (la.kind == 21) { + currentState = 383; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 386: { + nextTokenIsPotentialStartOfExpression = true; + goto case 387; + } + case 387: { + if (la == null) { currentState = 387; break; } + if (set[50].Get(la.kind)) { + goto case 381; + } else { + goto case 382; + } + } + case 388: { + stateStack.Push(389); + goto case 101; + } + case 389: { + if (la == null) { currentState = 389; break; } + if (la.kind == 37) { + currentState = 390; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 390: { + PushContext(Context.Expression, la, t); + nextTokenIsPotentialStartOfExpression = true; + goto case 391; + } + case 391: { + if (la == null) { currentState = 391; break; } + if (set[21].Get(la.kind)) { + stateStack.Push(392); + goto case 47; + } else { + goto case 392; + } + } + case 392: { + PopContext(); + goto case 46; + } + case 393: { + stateStack.Push(394); + goto case 55; + } + case 394: { + if (la == null) { currentState = 394; break; } + Expect(22, la); // "," + currentState = 55; + break; + } + case 395: { + stateStack.Push(396); + goto case 55; + } + case 396: { + stateStack.Push(397); + goto case 259; + } + case 397: { + if (la == null) { currentState = 397; break; } + Expect(113, la); // "End" + currentState = 398; + break; + } + case 398: { + if (la == null) { currentState = 398; break; } + if (la.kind == 233) { + goto case 102; + } else { + if (la.kind == 211) { + goto case 110; + } else { + goto case 6; + } + } + } + case 399: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(400); + goto case 205; + } + case 400: { + PopContext(); + goto case 401; + } + case 401: { + if (la == null) { currentState = 401; break; } + if (la.kind == 33) { + currentState = 402; + break; + } else { + goto case 402; + } + } + case 402: { + if (la == null) { currentState = 402; break; } + if (la.kind == 37) { + currentState = 419; + break; + } else { + if (la.kind == 63) { + currentState = 416; + break; + } else { + goto case 403; + } + } + } + case 403: { + if (la == null) { currentState = 403; break; } + if (la.kind == 20) { + currentState = 415; + break; + } else { + goto case 404; + } + } + case 404: { + if (la == null) { currentState = 404; break; } + if (la.kind == 22) { + currentState = 405; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 405: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(406); + goto case 205; + } + case 406: { + PopContext(); + goto case 407; + } + case 407: { + if (la == null) { currentState = 407; break; } + if (la.kind == 33) { + currentState = 408; + break; + } else { + goto case 408; + } + } + case 408: { + if (la == null) { currentState = 408; break; } + if (la.kind == 37) { + currentState = 412; + break; + } else { + if (la.kind == 63) { + currentState = 409; + break; + } else { + goto case 403; + } + } + } + case 409: { + PushContext(Context.Type, la, t); + goto case 410; + } + case 410: { + if (la == null) { currentState = 410; break; } + if (la.kind == 162) { + stateStack.Push(411); + goto case 85; + } else { + if (set[16].Get(la.kind)) { + stateStack.Push(411); + goto case 37; + } else { + Error(la); + goto case 411; + } + } + } + case 411: { + PopContext(); + goto case 403; + } + case 412: { + nextTokenIsPotentialStartOfExpression = true; + goto case 413; + } + case 413: { + if (la == null) { currentState = 413; break; } + if (set[23].Get(la.kind)) { + stateStack.Push(414); + goto case 55; + } else { + goto case 414; + } + } + case 414: { + if (la == null) { currentState = 414; break; } + if (la.kind == 22) { + currentState = 412; + break; + } else { + Expect(38, la); // ")" + currentState = 408; + break; + } + } + case 415: { + stateStack.Push(404); + goto case 55; + } + case 416: { + PushContext(Context.Type, la, t); + goto case 417; + } + case 417: { + if (la == null) { currentState = 417; break; } + if (la.kind == 162) { + stateStack.Push(418); + goto case 85; + } else { + if (set[16].Get(la.kind)) { + stateStack.Push(418); + goto case 37; + } else { + Error(la); + goto case 418; + } + } + } + case 418: { + PopContext(); + goto case 403; + } + case 419: { + nextTokenIsPotentialStartOfExpression = true; + goto case 420; + } + case 420: { + if (la == null) { currentState = 420; break; } + if (set[23].Get(la.kind)) { + stateStack.Push(421); + goto case 55; + } else { + goto case 421; + } + } + case 421: { + if (la == null) { currentState = 421; break; } + if (la.kind == 22) { + currentState = 419; + break; + } else { + Expect(38, la); // ")" + currentState = 402; + break; + } + } + case 422: { + PushContext(Context.Type, la, t); + stateStack.Push(423); + goto case 37; + } + case 423: { + PopContext(); + goto case 256; + } + case 424: { + if (la == null) { currentState = 424; break; } + Expect(37, la); // "(" + currentState = 425; + break; + } + case 425: { + PushContext(Context.Default, la, t); + SetIdentifierExpected(la); + goto case 426; + } + case 426: { + if (la == null) { currentState = 426; break; } + if (set[77].Get(la.kind)) { + stateStack.Push(427); + goto case 428; + } else { + goto case 427; + } + } + case 427: { + PopContext(); + goto case 46; + } + case 428: { + stateStack.Push(429); + PushContext(Context.Parameter, la, t); + goto case 430; + } + case 429: { + if (la == null) { currentState = 429; break; } + if (la.kind == 22) { + currentState = 428; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 430: { + SetIdentifierExpected(la); + goto case 431; + } + case 431: { + if (la == null) { currentState = 431; break; } + if (la.kind == 40) { + stateStack.Push(430); + goto case 443; + } else { + goto case 432; + } + } + case 432: { + SetIdentifierExpected(la); + goto case 433; + } + case 433: { + if (la == null) { currentState = 433; break; } + if (set[143].Get(la.kind)) { + currentState = 432; + break; + } else { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(434); + goto case 205; + } + } + case 434: { + PopContext(); + goto case 435; + } + case 435: { + if (la == null) { currentState = 435; break; } + if (la.kind == 33) { + currentState = 436; + break; + } else { + goto case 436; + } + } + case 436: { + if (la == null) { currentState = 436; break; } + if (la.kind == 37) { + currentState = 442; + break; + } else { + if (la.kind == 63) { + currentState = 440; + break; + } else { + goto case 437; + } + } + } + case 437: { + if (la == null) { currentState = 437; break; } + if (la.kind == 20) { + currentState = 439; + break; + } else { + goto case 438; + } + } + case 438: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 439: { + stateStack.Push(438); + goto case 55; + } + case 440: { + PushContext(Context.Type, la, t); + stateStack.Push(441); + goto case 37; + } + case 441: { + PopContext(); + goto case 437; + } + case 442: { + if (la == null) { currentState = 442; break; } + if (la.kind == 22) { + currentState = 442; + break; + } else { + Expect(38, la); // ")" + currentState = 436; + break; + } + } + case 443: { + if (la == null) { currentState = 443; break; } + Expect(40, la); // "<" + currentState = 444; + break; + } + case 444: { + wasNormalAttribute = true; PushContext(Context.Attribute, la, t); + goto case 445; + } + case 445: { + stateStack.Push(446); + goto case 449; + } + case 446: { + if (la == null) { currentState = 446; break; } + if (la.kind == 22) { + currentState = 445; + break; + } else { + Expect(39, la); // ">" + currentState = 447; + break; + } + } + case 447: { + PopContext(); + goto case 448; + } + case 448: { + if (la == null) { currentState = 448; break; } + if (la.kind == 1) { + goto case 25; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 449: { + if (la == null) { currentState = 449; break; } + if (la.kind == 65 || la.kind == 155) { + currentState = 450; + break; + } else { + goto case 37; + } + } + case 450: { + if (la == null) { currentState = 450; break; } + Expect(21, la); // ":" + currentState = 451; + break; + } + case 451: { + wasNormalAttribute = false; + goto case 37; + } + case 452: { + stateStack.Push(453); + goto case 424; + } + case 453: { + nextTokenIsPotentialStartOfExpression = true; + goto case 454; + } + case 454: { + if (la == null) { currentState = 454; break; } + if (set[50].Get(la.kind)) { + goto case 267; + } else { + if (la.kind == 1 || la.kind == 21) { + stateStack.Push(455); + goto case 259; + } else { + goto case 6; + } + } + } + case 455: { + if (la == null) { currentState = 455; break; } + Expect(113, la); // "End" + currentState = 456; + break; + } + case 456: { + if (la == null) { currentState = 456; break; } + Expect(210, la); // "Sub" + currentState = stateStack.Pop(); + break; + } + case 457: { + if (la == null) { currentState = 457; break; } + if (la.kind == 17 || la.kind == 18 || la.kind == 19) { + currentState = 470; + break; + } else { + if (la.kind == 10) { + stateStack.Push(459); + goto case 461; + } else { + Error(la); + goto case 458; + } + } + } + case 458: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 459: { + if (la == null) { currentState = 459; break; } + if (la.kind == 17) { + currentState = 460; + break; + } else { + goto case 458; + } + } + case 460: { + if (la == null) { currentState = 460; break; } + if (la.kind == 16) { + currentState = 459; + break; + } else { + goto case 459; + } + } + case 461: { + PushContext(Context.Xml, la, t); + goto case 462; + } + case 462: { + if (la == null) { currentState = 462; break; } + Expect(10, la); // XmlOpenTag + currentState = 463; + break; + } + case 463: { + if (la == null) { currentState = 463; break; } + if (set[144].Get(la.kind)) { + if (set[145].Get(la.kind)) { + currentState = 463; + break; + } else { + if (la.kind == 12) { + stateStack.Push(463); + goto case 467; + } else { + Error(la); + goto case 463; + } + } + } else { + if (la.kind == 14) { + currentState = 464; + break; + } else { + if (la.kind == 11) { + currentState = 465; + break; + } else { + Error(la); + goto case 464; + } + } + } + } + case 464: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 465: { + if (la == null) { currentState = 465; break; } + if (set[146].Get(la.kind)) { + if (set[147].Get(la.kind)) { + currentState = 465; + break; + } else { + if (la.kind == 12) { + stateStack.Push(465); + goto case 467; + } else { + if (la.kind == 10) { + stateStack.Push(465); + goto case 461; + } else { + Error(la); + goto case 465; + } + } + } + } else { + Expect(15, la); // XmlOpenEndTag + currentState = 466; + break; + } + } + case 466: { + if (la == null) { currentState = 466; break; } + if (set[148].Get(la.kind)) { + if (set[149].Get(la.kind)) { + currentState = 466; + break; + } else { + if (la.kind == 12) { + stateStack.Push(466); + goto case 467; + } else { + Error(la); + goto case 466; + } + } + } else { + Expect(11, la); // XmlCloseTag + currentState = 464; + break; + } + } + case 467: { + if (la == null) { currentState = 467; break; } + Expect(12, la); // XmlStartInlineVB + currentState = 468; + break; + } + case 468: { + stateStack.Push(469); + goto case 55; + } + case 469: { + if (la == null) { currentState = 469; break; } + Expect(13, la); // XmlEndInlineVB + currentState = stateStack.Pop(); + break; + } + case 470: { + if (la == null) { currentState = 470; break; } + if (la.kind == 16) { + currentState = 471; + break; + } else { + goto case 471; + } + } + case 471: { + if (la == null) { currentState = 471; break; } + if (la.kind == 17 || la.kind == 19) { + currentState = 470; + break; + } else { + if (la.kind == 10) { + stateStack.Push(472); + goto case 461; + } else { + goto case 458; + } + } + } + case 472: { + if (la == null) { currentState = 472; break; } + if (la.kind == 17) { + currentState = 473; + break; + } else { + goto case 458; + } + } + case 473: { + if (la == null) { currentState = 473; break; } + if (la.kind == 16) { + currentState = 472; + break; + } else { + goto case 472; + } + } + case 474: { + if (la == null) { currentState = 474; break; } + Expect(37, la); // "(" + currentState = 475; + break; + } + case 475: { + readXmlIdentifier = true; + stateStack.Push(476); + goto case 205; + } + case 476: { + if (la == null) { currentState = 476; break; } + Expect(38, la); // ")" + currentState = 175; + break; + } + case 477: { + if (la == null) { currentState = 477; break; } + Expect(37, la); // "(" + currentState = 478; + break; + } + case 478: { + PushContext(Context.Type, la, t); + stateStack.Push(479); + goto case 37; + } + case 479: { + PopContext(); + goto case 476; + } + case 480: { + nextTokenIsStartOfImportsOrAccessExpression = true; wasQualifierTokenAtStart = true; + goto case 481; + } + case 481: { + if (la == null) { currentState = 481; break; } + if (la.kind == 10) { + currentState = 482; + break; + } else { + goto case 482; + } + } + case 482: { + stateStack.Push(483); + goto case 101; + } + case 483: { + if (la == null) { currentState = 483; break; } + if (la.kind == 11) { + currentState = 175; + break; + } else { + goto case 175; + } + } + case 484: { + activeArgument = 0; + goto case 485; + } + case 485: { + stateStack.Push(486); + goto case 55; + } + case 486: { + if (la == null) { currentState = 486; break; } + if (la.kind == 22) { + currentState = 487; + break; + } else { + goto case 476; + } + } + case 487: { + activeArgument++; + goto case 485; + } + case 488: { + stateStack.Push(489); + goto case 55; + } + case 489: { + if (la == null) { currentState = 489; break; } + if (la.kind == 22) { + currentState = 490; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 490: { + activeArgument++; + nextTokenIsPotentialStartOfExpression = true; + goto case 491; + } + case 491: { + if (la == null) { currentState = 491; break; } + if (set[23].Get(la.kind)) { + goto case 488; + } else { + goto case 489; + } + } + case 492: { + if (la == null) { currentState = 492; break; } + if (set[16].Get(la.kind)) { + PushContext(Context.Type, la, t); + stateStack.Push(496); + goto case 37; + } else { + goto case 493; + } + } + case 493: { + if (la == null) { currentState = 493; break; } + if (la.kind == 22) { + currentState = 494; + break; + } else { + goto case 45; + } + } + case 494: { + if (la == null) { currentState = 494; break; } + if (set[16].Get(la.kind)) { + PushContext(Context.Type, la, t); + stateStack.Push(495); + goto case 37; + } else { + goto case 493; + } + } + case 495: { + PopContext(); + goto case 493; + } + case 496: { + PopContext(); + goto case 493; + } + case 497: { + SetIdentifierExpected(la); + goto case 498; + } + case 498: { + if (la == null) { currentState = 498; break; } + if (set[150].Get(la.kind)) { + if (la.kind == 169) { + currentState = 500; + break; + } else { + if (set[77].Get(la.kind)) { + stateStack.Push(499); + goto case 428; + } else { + Error(la); + goto case 499; + } + } + } else { + goto case 499; + } + } + case 499: { + if (la == null) { currentState = 499; break; } + Expect(38, la); // ")" + currentState = 34; + break; + } + case 500: { + stateStack.Push(499); + goto case 501; + } + case 501: { + SetIdentifierExpected(la); + goto case 502; + } + case 502: { + if (la == null) { currentState = 502; break; } + if (la.kind == 138 || la.kind == 178) { + currentState = 503; + break; + } else { + goto case 503; + } + } + case 503: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(504); + goto case 518; + } + case 504: { + PopContext(); + goto case 505; + } + case 505: { + if (la == null) { currentState = 505; break; } + if (la.kind == 63) { + currentState = 519; + break; + } else { + goto case 506; + } + } + case 506: { + if (la == null) { currentState = 506; break; } + if (la.kind == 22) { + currentState = 507; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 507: { + SetIdentifierExpected(la); + goto case 508; + } + case 508: { + if (la == null) { currentState = 508; break; } + if (la.kind == 138 || la.kind == 178) { + currentState = 509; + break; + } else { + goto case 509; + } + } + case 509: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(510); + goto case 518; + } + case 510: { + PopContext(); + goto case 511; + } + case 511: { + if (la == null) { currentState = 511; break; } + if (la.kind == 63) { + currentState = 512; + break; + } else { + goto case 506; + } + } + case 512: { + PushContext(Context.Type, la, t); + stateStack.Push(513); + goto case 514; + } + case 513: { + PopContext(); + goto case 506; + } + case 514: { + if (la == null) { currentState = 514; break; } + if (set[94].Get(la.kind)) { + goto case 517; + } else { + if (la.kind == 35) { + currentState = 515; + break; + } else { + goto case 6; + } + } + } + case 515: { + stateStack.Push(516); + goto case 517; + } + case 516: { + if (la == null) { currentState = 516; break; } + if (la.kind == 22) { + currentState = 515; + break; + } else { + goto case 82; + } + } + case 517: { + if (la == null) { currentState = 517; break; } + if (set[16].Get(la.kind)) { + currentState = 38; + break; + } else { + if (la.kind == 162) { + goto case 121; + } else { + if (la.kind == 84) { + goto case 137; + } else { + if (la.kind == 209) { + goto case 112; + } else { + goto case 6; + } + } + } + } + } + case 518: { + if (la == null) { currentState = 518; break; } + if (la.kind == 2) { + goto case 145; + } else { + if (la.kind == 62) { + goto case 143; + } else { + if (la.kind == 64) { + goto case 142; + } else { + if (la.kind == 65) { + goto case 141; + } else { + if (la.kind == 66) { + goto case 140; + } else { + if (la.kind == 67) { + goto case 139; + } else { + if (la.kind == 70) { + goto case 138; + } else { + if (la.kind == 87) { + goto case 136; + } else { + if (la.kind == 104) { + goto case 134; + } else { + if (la.kind == 107) { + goto case 133; + } else { + if (la.kind == 116) { + goto case 131; + } else { + if (la.kind == 121) { + goto case 130; + } else { + if (la.kind == 133) { + goto case 126; + } else { + if (la.kind == 139) { + goto case 125; + } else { + if (la.kind == 143) { + goto case 124; + } else { + if (la.kind == 146) { + goto case 123; + } else { + if (la.kind == 147) { + goto case 122; + } else { + if (la.kind == 170) { + goto case 119; + } else { + if (la.kind == 176) { + goto case 118; + } else { + if (la.kind == 184) { + goto case 117; + } else { + if (la.kind == 203) { + goto case 114; + } else { + if (la.kind == 212) { + goto case 109; + } else { + if (la.kind == 213) { + goto case 108; + } else { + if (la.kind == 223) { + goto case 106; + } else { + if (la.kind == 224) { + goto case 105; + } else { + if (la.kind == 230) { + goto case 104; + } else { + goto case 6; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + case 519: { + PushContext(Context.Type, la, t); + stateStack.Push(520); + goto case 514; + } + case 520: { + PopContext(); + goto case 506; + } + case 521: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(522); + goto case 205; + } + case 522: { + PopContext(); + goto case 523; + } + case 523: { + if (la == null) { currentState = 523; break; } + if (la.kind == 37) { + stateStack.Push(524); + goto case 424; + } else { + goto case 524; + } + } + case 524: { + if (la == null) { currentState = 524; break; } + if (la.kind == 63) { + currentState = 525; + break; + } else { + goto case 23; + } + } + case 525: { + PushContext(Context.Type, la, t); + goto case 526; + } + case 526: { + if (la == null) { currentState = 526; break; } + if (la.kind == 40) { + stateStack.Push(526); + goto case 443; + } else { + stateStack.Push(527); + goto case 37; + } + } + case 527: { + PopContext(); + goto case 23; + } + case 528: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(529); + goto case 205; + } + case 529: { + PopContext(); + goto case 530; + } + case 530: { + if (la == null) { currentState = 530; break; } + if (la.kind == 37 || la.kind == 63) { + if (la.kind == 63) { + currentState = 532; + break; + } else { + if (la.kind == 37) { + stateStack.Push(23); + goto case 424; + } else { + goto case 531; + } + } + } else { + goto case 23; + } + } + case 531: { + Error(la); + goto case 23; + } + case 532: { + PushContext(Context.Type, la, t); + stateStack.Push(533); + goto case 37; + } + case 533: { + PopContext(); + goto case 23; + } + case 534: { + PushContext(Context.TypeDeclaration, la, t); + goto case 535; + } + case 535: { + if (la == null) { currentState = 535; break; } + Expect(115, la); // "Enum" + currentState = 536; + break; + } + case 536: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(537); + goto case 205; + } + case 537: { + PopContext(); + goto case 538; + } + case 538: { + if (la == null) { currentState = 538; break; } + if (la.kind == 63) { + currentState = 550; + break; + } else { + goto case 539; + } + } + case 539: { + stateStack.Push(540); + goto case 23; + } + case 540: { + SetIdentifierExpected(la); + goto case 541; + } + case 541: { + if (la == null) { currentState = 541; break; } + if (set[97].Get(la.kind)) { + goto case 545; + } else { + Expect(113, la); // "End" + currentState = 542; + break; + } + } + case 542: { + if (la == null) { currentState = 542; break; } + Expect(115, la); // "Enum" + currentState = 543; + break; + } + case 543: { + stateStack.Push(544); + goto case 23; + } + case 544: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 545: { + SetIdentifierExpected(la); + goto case 546; + } + case 546: { + if (la == null) { currentState = 546; break; } + if (la.kind == 40) { + stateStack.Push(545); + goto case 443; + } else { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(547); + goto case 205; + } + } + case 547: { + PopContext(); + goto case 548; + } + case 548: { + if (la == null) { currentState = 548; break; } + if (la.kind == 20) { + currentState = 549; + break; + } else { + goto case 539; + } + } + case 549: { + stateStack.Push(539); + goto case 55; + } + case 550: { + PushContext(Context.Type, la, t); + stateStack.Push(551); + goto case 37; + } + case 551: { + PopContext(); + goto case 539; + } + case 552: { + if (la == null) { currentState = 552; break; } + Expect(103, la); // "Delegate" + currentState = 553; + break; + } + case 553: { + if (la == null) { currentState = 553; break; } + if (la.kind == 210) { + currentState = 554; + break; + } else { + if (la.kind == 127) { + currentState = 554; + break; + } else { + Error(la); + goto case 554; + } + } + } + case 554: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + goto case 555; + } + case 555: { + if (la == null) { currentState = 555; break; } + currentState = 556; + break; + } + case 556: { + PopContext(); + goto case 557; + } + case 557: { + if (la == null) { currentState = 557; break; } + if (la.kind == 37) { + currentState = 560; + break; + } else { + if (la.kind == 63) { + currentState = 558; + break; + } else { + goto case 23; + } + } + } + case 558: { + PushContext(Context.Type, la, t); + stateStack.Push(559); + goto case 37; + } + case 559: { + PopContext(); + goto case 23; + } + case 560: { + SetIdentifierExpected(la); + goto case 561; + } + case 561: { + if (la == null) { currentState = 561; break; } + if (set[150].Get(la.kind)) { + if (la.kind == 169) { + currentState = 563; + break; + } else { + if (set[77].Get(la.kind)) { + stateStack.Push(562); + goto case 428; + } else { + Error(la); + goto case 562; + } + } + } else { + goto case 562; + } + } + case 562: { + if (la == null) { currentState = 562; break; } + Expect(38, la); // ")" + currentState = 557; + break; + } + case 563: { + stateStack.Push(562); + goto case 501; + } + case 564: { + PushContext(Context.TypeDeclaration, la, t); + goto case 565; + } + case 565: { + if (la == null) { currentState = 565; break; } + if (la.kind == 155) { + currentState = 566; + break; + } else { + if (la.kind == 84) { + currentState = 566; + break; + } else { + if (la.kind == 209) { + currentState = 566; + break; + } else { + Error(la); + goto case 566; + } + } + } + } + case 566: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(567); + goto case 205; + } + case 567: { + PopContext(); + goto case 568; + } + case 568: { + if (la == null) { currentState = 568; break; } + if (la.kind == 37) { + currentState = 718; + break; + } else { + goto case 569; + } + } + case 569: { + stateStack.Push(570); + goto case 23; + } + case 570: { + SetIdentifierExpected(la); + isMissingModifier = true; + goto case 571; + } + case 571: { + if (la == null) { currentState = 571; break; } + if (la.kind == 140) { + isMissingModifier = false; + goto case 715; + } else { + goto case 572; + } + } + case 572: { + SetIdentifierExpected(la); + isMissingModifier = true; + goto case 573; + } + case 573: { + if (la == null) { currentState = 573; break; } + if (la.kind == 136) { + isMissingModifier = false; + goto case 709; + } else { + goto case 574; + } + } + case 574: { + SetIdentifierExpected(la); + isMissingModifier = true; + goto case 575; + } + case 575: { + if (la == null) { currentState = 575; break; } + if (set[101].Get(la.kind)) { + goto case 580; + } else { + isMissingModifier = false; + goto case 576; + } + } + case 576: { + if (la == null) { currentState = 576; break; } + Expect(113, la); // "End" + currentState = 577; + break; + } + case 577: { + if (la == null) { currentState = 577; break; } + if (la.kind == 155) { + currentState = 578; + break; + } else { + if (la.kind == 84) { + currentState = 578; + break; + } else { + if (la.kind == 209) { + currentState = 578; + break; + } else { + Error(la); + goto case 578; + } + } + } + } + case 578: { + stateStack.Push(579); + goto case 23; + } + case 579: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 580: { + SetIdentifierExpected(la); + isMissingModifier = true; + goto case 581; + } + case 581: { + if (la == null) { currentState = 581; break; } + if (la.kind == 40) { + stateStack.Push(580); + goto case 443; + } else { + isMissingModifier = true; + goto case 582; + } + } + case 582: { + SetIdentifierExpected(la); + goto case 583; + } + case 583: { + if (la == null) { currentState = 583; break; } + if (set[132].Get(la.kind)) { + currentState = 708; + break; + } else { + isMissingModifier = false; + SetIdentifierExpected(la); + goto case 584; + } + } + case 584: { + if (la == null) { currentState = 584; break; } + if (la.kind == 84 || la.kind == 155 || la.kind == 209) { + stateStack.Push(574); + goto case 564; + } else { + if (la.kind == 103) { + stateStack.Push(574); + goto case 552; + } else { + if (la.kind == 115) { + stateStack.Push(574); + goto case 534; + } else { + if (la.kind == 142) { + stateStack.Push(574); + goto case 9; + } else { + if (set[104].Get(la.kind)) { + stateStack.Push(574); + PushContext(Context.Member, la, t); + SetIdentifierExpected(la); + goto case 585; + } else { + Error(la); + goto case 574; + } + } + } + } + } + } + case 585: { + if (la == null) { currentState = 585; break; } + if (set[122].Get(la.kind)) { + stateStack.Push(586); + goto case 693; + } else { + if (la.kind == 127 || la.kind == 210) { + stateStack.Push(586); + goto case 675; + } else { + if (la.kind == 101) { + stateStack.Push(586); + goto case 662; + } else { + if (la.kind == 119) { + stateStack.Push(586); + goto case 650; + } else { + if (la.kind == 98) { + stateStack.Push(586); + goto case 638; + } else { + if (la.kind == 186) { + stateStack.Push(586); + goto case 601; + } else { + if (la.kind == 172) { + stateStack.Push(586); + goto case 587; + } else { + Error(la); + goto case 586; + } + } + } + } + } + } + } + } + case 586: { + PopContext(); + currentState = stateStack.Pop(); + goto switchlbl; + } + case 587: { + if (la == null) { currentState = 587; break; } + Expect(172, la); // "Operator" + currentState = 588; + break; + } + case 588: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + goto case 589; + } + case 589: { + if (la == null) { currentState = 589; break; } + currentState = 590; + break; + } + case 590: { + PopContext(); + goto case 591; + } + case 591: { + if (la == null) { currentState = 591; break; } + Expect(37, la); // "(" + currentState = 592; + break; + } + case 592: { + stateStack.Push(593); + goto case 428; + } + case 593: { + if (la == null) { currentState = 593; break; } + Expect(38, la); // ")" + currentState = 594; + break; + } + case 594: { + if (la == null) { currentState = 594; break; } + if (la.kind == 63) { + currentState = 598; + break; + } else { + goto case 595; + } + } + case 595: { + stateStack.Push(596); + goto case 259; + } + case 596: { + if (la == null) { currentState = 596; break; } + Expect(113, la); // "End" + currentState = 597; + break; + } + case 597: { + if (la == null) { currentState = 597; break; } + Expect(172, la); // "Operator" + currentState = 23; + break; + } + case 598: { + PushContext(Context.Type, la, t); + goto case 599; + } + case 599: { + if (la == null) { currentState = 599; break; } + if (la.kind == 40) { + stateStack.Push(599); + goto case 443; + } else { + stateStack.Push(600); + goto case 37; + } + } + case 600: { + PopContext(); + goto case 595; + } + case 601: { + if (la == null) { currentState = 601; break; } + Expect(186, la); // "Property" + currentState = 602; + break; + } + case 602: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(603); + goto case 205; + } + case 603: { + PopContext(); + goto case 604; + } + case 604: { + if (la == null) { currentState = 604; break; } + if (la.kind == 37) { + stateStack.Push(605); + goto case 424; + } else { + goto case 605; + } + } + case 605: { + if (la == null) { currentState = 605; break; } + if (la.kind == 63) { + currentState = 635; + break; + } else { + goto case 606; + } + } + case 606: { + if (la == null) { currentState = 606; break; } + if (la.kind == 136) { + currentState = 630; + break; + } else { + goto case 607; + } + } + case 607: { + if (la == null) { currentState = 607; break; } + if (la.kind == 20) { + currentState = 629; + break; + } else { + goto case 608; + } + } + case 608: { + stateStack.Push(609); + goto case 23; + } + case 609: { + PopContext(); + goto case 610; + } + case 610: { + if (la == null) { currentState = 610; break; } + if (la.kind == 40) { + stateStack.Push(610); + goto case 443; + } else { + goto case 611; + } + } + case 611: { + if (la == null) { currentState = 611; break; } + if (set[151].Get(la.kind)) { + currentState = 628; + break; + } else { + if (la.kind == 128 || la.kind == 198) { + PushContext(Context.Member, la, t); + goto case 612; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + } + case 612: { + if (la == null) { currentState = 612; break; } + if (la.kind == 128) { + currentState = 613; + break; + } else { + if (la.kind == 198) { + currentState = 613; + break; + } else { + Error(la); + goto case 613; + } + } + } + case 613: { + if (la == null) { currentState = 613; break; } + if (la.kind == 37) { + stateStack.Push(614); + goto case 424; + } else { + goto case 614; + } + } + case 614: { + stateStack.Push(615); + goto case 259; + } + case 615: { + if (la == null) { currentState = 615; break; } + Expect(113, la); // "End" + currentState = 616; + break; + } + case 616: { + if (la == null) { currentState = 616; break; } + if (la.kind == 128) { + currentState = 617; + break; + } else { + if (la.kind == 198) { + currentState = 617; + break; + } else { + Error(la); + goto case 617; + } + } + } + case 617: { + stateStack.Push(618); + goto case 23; + } + case 618: { + if (la == null) { currentState = 618; break; } + if (set[110].Get(la.kind)) { + goto case 621; + } else { + goto case 619; + } + } + case 619: { + if (la == null) { currentState = 619; break; } + Expect(113, la); // "End" + currentState = 620; + break; + } + case 620: { + if (la == null) { currentState = 620; break; } + Expect(186, la); // "Property" + currentState = 23; + break; + } + case 621: { + if (la == null) { currentState = 621; break; } + if (la.kind == 40) { + stateStack.Push(621); + goto case 443; + } else { + goto case 622; + } + } + case 622: { + if (la == null) { currentState = 622; break; } + if (set[151].Get(la.kind)) { + currentState = 622; + break; + } else { + if (la.kind == 128) { + currentState = 623; + break; + } else { + if (la.kind == 198) { + currentState = 623; + break; + } else { + Error(la); + goto case 623; + } + } + } + } + case 623: { + if (la == null) { currentState = 623; break; } + if (la.kind == 37) { + stateStack.Push(624); + goto case 424; + } else { + goto case 624; + } + } + case 624: { + stateStack.Push(625); + goto case 259; + } + case 625: { + if (la == null) { currentState = 625; break; } + Expect(113, la); // "End" + currentState = 626; + break; + } + case 626: { + if (la == null) { currentState = 626; break; } + if (la.kind == 128) { + currentState = 627; + break; + } else { + if (la.kind == 198) { + currentState = 627; + break; + } else { + Error(la); + goto case 627; + } + } + } + case 627: { + stateStack.Push(619); + goto case 23; + } + case 628: { + SetIdentifierExpected(la); + goto case 611; + } + case 629: { + stateStack.Push(608); + goto case 55; + } + case 630: { + PushContext(Context.Type, la, t); + stateStack.Push(631); + goto case 37; + } + case 631: { + PopContext(); + goto case 632; + } + case 632: { + if (la == null) { currentState = 632; break; } + if (la.kind == 22) { + currentState = 633; + break; + } else { + goto case 607; + } + } + case 633: { + PushContext(Context.Type, la, t); + stateStack.Push(634); + goto case 37; + } + case 634: { + PopContext(); + goto case 632; + } + case 635: { + PushContext(Context.Type, la, t); + goto case 636; + } + case 636: { + if (la == null) { currentState = 636; break; } + if (la.kind == 40) { + stateStack.Push(636); + goto case 443; + } else { + if (la.kind == 162) { + stateStack.Push(637); + goto case 85; + } else { + if (set[16].Get(la.kind)) { + stateStack.Push(637); + goto case 37; + } else { + Error(la); + goto case 637; + } + } + } + } + case 637: { + PopContext(); + goto case 606; + } + case 638: { + if (la == null) { currentState = 638; break; } + Expect(98, la); // "Custom" + currentState = 639; + break; + } + case 639: { + stateStack.Push(640); + goto case 650; + } + case 640: { + if (la == null) { currentState = 640; break; } + if (set[115].Get(la.kind)) { + goto case 642; + } else { + Expect(113, la); // "End" + currentState = 641; + break; + } + } + case 641: { + if (la == null) { currentState = 641; break; } + Expect(119, la); // "Event" + currentState = 23; + break; + } + case 642: { + if (la == null) { currentState = 642; break; } + if (la.kind == 40) { + stateStack.Push(642); + goto case 443; + } else { + if (la.kind == 56) { + currentState = 643; + break; + } else { + if (la.kind == 193) { + currentState = 643; + break; + } else { + if (la.kind == 189) { + currentState = 643; + break; + } else { + Error(la); + goto case 643; + } + } + } + } + } + case 643: { + if (la == null) { currentState = 643; break; } + Expect(37, la); // "(" + currentState = 644; + break; + } + case 644: { + stateStack.Push(645); + goto case 428; + } + case 645: { + if (la == null) { currentState = 645; break; } + Expect(38, la); // ")" + currentState = 646; + break; + } + case 646: { + stateStack.Push(647); + goto case 259; + } + case 647: { + if (la == null) { currentState = 647; break; } + Expect(113, la); // "End" + currentState = 648; + break; + } + case 648: { + if (la == null) { currentState = 648; break; } + if (la.kind == 56) { + currentState = 649; + break; + } else { + if (la.kind == 193) { + currentState = 649; + break; + } else { + if (la.kind == 189) { + currentState = 649; + break; + } else { + Error(la); + goto case 649; + } + } + } + } + case 649: { + stateStack.Push(640); + goto case 23; + } + case 650: { + if (la == null) { currentState = 650; break; } + Expect(119, la); // "Event" + currentState = 651; + break; + } + case 651: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(652); + goto case 205; + } + case 652: { + PopContext(); + goto case 653; + } + case 653: { + if (la == null) { currentState = 653; break; } + if (la.kind == 63) { + currentState = 660; + break; + } else { + if (set[152].Get(la.kind)) { + if (la.kind == 37) { + stateStack.Push(654); + goto case 424; + } else { + goto case 654; + } + } else { + Error(la); + goto case 654; + } + } + } + case 654: { + if (la == null) { currentState = 654; break; } + if (la.kind == 136) { + currentState = 655; + break; + } else { + goto case 23; + } + } + case 655: { + PushContext(Context.Type, la, t); + stateStack.Push(656); + goto case 37; + } + case 656: { + PopContext(); + goto case 657; + } + case 657: { + if (la == null) { currentState = 657; break; } + if (la.kind == 22) { + currentState = 658; + break; + } else { + goto case 23; + } + } + case 658: { + PushContext(Context.Type, la, t); + stateStack.Push(659); + goto case 37; + } + case 659: { + PopContext(); + goto case 657; + } + case 660: { + PushContext(Context.Type, la, t); + stateStack.Push(661); + goto case 37; + } + case 661: { + PopContext(); + goto case 654; + } + case 662: { + if (la == null) { currentState = 662; break; } + Expect(101, la); // "Declare" + currentState = 663; + break; + } + case 663: { + if (la == null) { currentState = 663; break; } + if (la.kind == 62 || la.kind == 66 || la.kind == 223) { + currentState = 664; + break; + } else { + goto case 664; + } + } + case 664: { + if (la == null) { currentState = 664; break; } + if (la.kind == 210) { + currentState = 665; + break; + } else { + if (la.kind == 127) { + currentState = 665; + break; + } else { + Error(la); + goto case 665; + } + } + } + case 665: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(666); + goto case 205; + } + case 666: { + PopContext(); + goto case 667; + } + case 667: { + if (la == null) { currentState = 667; break; } + Expect(149, la); // "Lib" + currentState = 668; + break; + } + case 668: { + if (la == null) { currentState = 668; break; } + Expect(3, la); // LiteralString + currentState = 669; + break; + } + case 669: { + if (la == null) { currentState = 669; break; } + if (la.kind == 59) { + currentState = 674; + break; + } else { + goto case 670; + } + } + case 670: { + if (la == null) { currentState = 670; break; } + if (la.kind == 37) { + stateStack.Push(671); + goto case 424; + } else { + goto case 671; + } + } + case 671: { + if (la == null) { currentState = 671; break; } + if (la.kind == 63) { + currentState = 672; + break; + } else { + goto case 23; + } + } + case 672: { + PushContext(Context.Type, la, t); + stateStack.Push(673); + goto case 37; + } + case 673: { + PopContext(); + goto case 23; + } + case 674: { + if (la == null) { currentState = 674; break; } + Expect(3, la); // LiteralString + currentState = 670; + break; + } + case 675: { + if (la == null) { currentState = 675; break; } + if (la.kind == 210) { + currentState = 676; + break; + } else { + if (la.kind == 127) { + currentState = 676; + break; + } else { + Error(la); + goto case 676; + } + } + } + case 676: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + goto case 677; + } + case 677: { + if (la == null) { currentState = 677; break; } + currentState = 678; + break; + } + case 678: { + PopContext(); + goto case 679; + } + case 679: { + if (la == null) { currentState = 679; break; } + if (la.kind == 37) { + currentState = 689; + break; + } else { + if (la.kind == 63) { + currentState = 687; + break; + } else { + goto case 680; + } + } + } + case 680: { + if (la == null) { currentState = 680; break; } + if (la.kind == 134 || la.kind == 136) { + currentState = 684; + break; + } else { + goto case 681; + } + } + case 681: { + stateStack.Push(682); + goto case 259; + } + case 682: { + if (la == null) { currentState = 682; break; } + Expect(113, la); // "End" + currentState = 683; + break; + } + case 683: { + if (la == null) { currentState = 683; break; } + if (la.kind == 210) { + currentState = 23; + break; + } else { + if (la.kind == 127) { + currentState = 23; + break; + } else { + goto case 531; + } + } + } + case 684: { + if (la == null) { currentState = 684; break; } + if (la.kind == 153 || la.kind == 158 || la.kind == 159) { + currentState = 686; + break; + } else { + goto case 685; + } + } + case 685: { + stateStack.Push(681); + goto case 37; + } + case 686: { + if (la == null) { currentState = 686; break; } + Expect(26, la); // "." + currentState = 685; + break; + } + case 687: { + PushContext(Context.Type, la, t); + stateStack.Push(688); + goto case 37; + } + case 688: { + PopContext(); + goto case 680; + } + case 689: { + SetIdentifierExpected(la); + goto case 690; + } + case 690: { + if (la == null) { currentState = 690; break; } + if (set[150].Get(la.kind)) { + if (la.kind == 169) { + currentState = 692; + break; + } else { + if (set[77].Get(la.kind)) { + stateStack.Push(691); + goto case 428; + } else { + Error(la); + goto case 691; + } + } + } else { + goto case 691; + } + } + case 691: { + if (la == null) { currentState = 691; break; } + Expect(38, la); // ")" + currentState = 679; + break; + } + case 692: { + stateStack.Push(691); + goto case 501; + } + case 693: { + stateStack.Push(694); + SetIdentifierExpected(la); + goto case 695; + } + case 694: { + if (la == null) { currentState = 694; break; } + if (la.kind == 22) { + currentState = 693; + break; + } else { + goto case 23; + } + } + case 695: { + if (la == null) { currentState = 695; break; } + if (la.kind == 88) { + currentState = 696; + break; + } else { + goto case 696; + } + } + case 696: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + stateStack.Push(697); + goto case 707; + } + case 697: { + PopContext(); + goto case 698; + } + case 698: { + if (la == null) { currentState = 698; break; } + if (la.kind == 33) { + currentState = 699; + break; + } else { + goto case 699; + } + } + case 699: { + if (la == null) { currentState = 699; break; } + if (la.kind == 37) { + currentState = 704; + break; + } else { + if (la.kind == 63) { + currentState = 701; + break; + } else { + goto case 700; + } + } + } + case 700: { + if (la == null) { currentState = 700; break; } + if (la.kind == 20) { + currentState = 55; + break; + } else { + currentState = stateStack.Pop(); + goto switchlbl; + } + } + case 701: { + PushContext(Context.Type, la, t); + goto case 702; + } + case 702: { + if (la == null) { currentState = 702; break; } + if (la.kind == 162) { + stateStack.Push(703); + goto case 85; + } else { + if (set[16].Get(la.kind)) { + stateStack.Push(703); + goto case 37; + } else { + Error(la); + goto case 703; + } + } + } + case 703: { + PopContext(); + goto case 700; + } + case 704: { + nextTokenIsPotentialStartOfExpression = true; + goto case 705; + } + case 705: { + if (la == null) { currentState = 705; break; } + if (set[23].Get(la.kind)) { + stateStack.Push(706); + goto case 55; + } else { + goto case 706; + } + } + case 706: { + if (la == null) { currentState = 706; break; } + if (la.kind == 22) { + currentState = 704; + break; + } else { + Expect(38, la); // ")" + currentState = 699; + break; + } + } + case 707: { + if (la == null) { currentState = 707; break; } + if (set[137].Get(la.kind)) { + currentState = stateStack.Pop(); + break; + } else { + if (la.kind == 58) { + goto case 144; + } else { + if (la.kind == 126) { + goto case 128; + } else { + goto case 6; + } + } + } + } + case 708: { + isMissingModifier = false; + goto case 582; + } + case 709: { + if (la == null) { currentState = 709; break; } + Expect(136, la); // "Implements" + currentState = 710; + break; + } + case 710: { + PushContext(Context.Type, la, t); + stateStack.Push(711); + goto case 37; + } + case 711: { + PopContext(); + goto case 712; + } + case 712: { + if (la == null) { currentState = 712; break; } + if (la.kind == 22) { + currentState = 713; + break; + } else { + stateStack.Push(574); + goto case 23; + } + } + case 713: { + PushContext(Context.Type, la, t); + stateStack.Push(714); + goto case 37; + } + case 714: { + PopContext(); + goto case 712; + } + case 715: { + if (la == null) { currentState = 715; break; } + Expect(140, la); // "Inherits" + currentState = 716; + break; + } + case 716: { + PushContext(Context.Type, la, t); + stateStack.Push(717); + goto case 37; + } + case 717: { + PopContext(); + stateStack.Push(572); + goto case 23; + } + case 718: { + if (la == null) { currentState = 718; break; } + Expect(169, la); // "Of" + currentState = 719; + break; + } + case 719: { + stateStack.Push(720); + goto case 501; + } + case 720: { + if (la == null) { currentState = 720; break; } + Expect(38, la); // ")" + currentState = 569; + break; + } + case 721: { + isMissingModifier = false; + goto case 28; + } + case 722: { + PushContext(Context.Type, la, t); + stateStack.Push(723); + goto case 37; + } + case 723: { + PopContext(); + goto case 724; + } + case 724: { + if (la == null) { currentState = 724; break; } + if (la.kind == 22) { + currentState = 725; + break; + } else { + stateStack.Push(17); + goto case 23; + } + } + case 725: { + PushContext(Context.Type, la, t); + stateStack.Push(726); + goto case 37; + } + case 726: { + PopContext(); + goto case 724; + } + case 727: { + if (la == null) { currentState = 727; break; } + Expect(169, la); // "Of" + currentState = 728; + break; + } + case 728: { + stateStack.Push(729); + goto case 501; + } + case 729: { + if (la == null) { currentState = 729; break; } + Expect(38, la); // ")" + currentState = 14; + break; + } + case 730: { + PushContext(Context.Identifier, la, t); + SetIdentifierExpected(la); + goto case 731; + } + case 731: { + if (la == null) { currentState = 731; break; } + if (set[49].Get(la.kind)) { + currentState = 731; + break; + } else { + PopContext(); + stateStack.Push(732); + goto case 23; + } + } + case 732: { + if (la == null) { currentState = 732; break; } + if (set[3].Get(la.kind)) { + stateStack.Push(732); + goto case 5; + } else { + Expect(113, la); // "End" + currentState = 733; + break; + } + } + case 733: { + if (la == null) { currentState = 733; break; } + Expect(160, la); // "Namespace" + currentState = 23; + break; + } + case 734: { + if (la == null) { currentState = 734; break; } + Expect(137, la); // "Imports" + currentState = 735; + break; + } + case 735: { + PushContext(Context.Importable, la, t); + nextTokenIsStartOfImportsOrAccessExpression = true; + goto case 736; + } + case 736: { + if (la == null) { currentState = 736; break; } + if (set[153].Get(la.kind)) { + currentState = 742; + break; + } else { + if (la.kind == 10) { + currentState = 738; + break; + } else { + Error(la); + goto case 737; + } + } + } + case 737: { + PopContext(); + goto case 23; + } + case 738: { + stateStack.Push(739); + goto case 205; + } + case 739: { + if (la == null) { currentState = 739; break; } + Expect(20, la); // "=" + currentState = 740; + break; + } + case 740: { + if (la == null) { currentState = 740; break; } + Expect(3, la); // LiteralString + currentState = 741; + break; + } + case 741: { + if (la == null) { currentState = 741; break; } + Expect(11, la); // XmlCloseTag + currentState = 737; + break; + } + case 742: { + if (la == null) { currentState = 742; break; } + if (la.kind == 33 || la.kind == 37) { + stateStack.Push(742); + goto case 42; + } else { + if (la.kind == 20 || la.kind == 26) { + currentState = 743; + break; + } else { + goto case 737; + } + } + } + case 743: { + stateStack.Push(737); + goto case 37; + } + case 744: { + if (la == null) { currentState = 744; break; } + Expect(173, la); // "Option" + currentState = 745; + break; + } + case 745: { + if (la == null) { currentState = 745; break; } + if (la.kind == 121 || la.kind == 139 || la.kind == 207) { + currentState = 747; + break; + } else { + if (la.kind == 87) { + currentState = 746; + break; + } else { + goto case 531; + } + } + } + case 746: { + if (la == null) { currentState = 746; break; } + if (la.kind == 213) { + currentState = 23; + break; + } else { + if (la.kind == 67) { + currentState = 23; + break; + } else { + goto case 531; + } + } + } + case 747: { + if (la == null) { currentState = 747; break; } + if (la.kind == 170 || la.kind == 171) { + currentState = 23; + break; + } else { + goto case 23; + } + } + } + + if (la != null) { + t = la; + nextTokenIsPotentialStartOfExpression = false; + readXmlIdentifier = false; + nextTokenIsStartOfImportsOrAccessExpression = false; + wasQualifierTokenAtStart = false; + identifierExpected = false; + } + } + + public void Advance() + { + //Console.WriteLine("Advance"); + InformToken(null); + } + + public BitArray GetExpectedSet() { return GetExpectedSet(currentState); } + + static readonly BitArray[] set = { + new BitArray(new int[] {1, 256, 1048576, 537395328, 402670080, 444604481, 131200, 0}), + new BitArray(new int[] {1, 256, 1048576, 537395328, 402670080, 444596289, 131200, 0}), + new BitArray(new int[] {1, 256, 1048576, 537395328, 402669568, 444596289, 131200, 0}), + new BitArray(new int[] {0, 256, 1048576, 537395328, 402669568, 444596289, 131200, 0}), + new BitArray(new int[] {0, 256, 1048576, 537395328, 402669568, 444596288, 131200, 0}), + new BitArray(new int[] {0, 0, 1048576, 537395328, 402669568, 444596288, 131200, 0}), + new BitArray(new int[] {4, 1140850688, 8388687, 1108347140, 821280, 17105920, -2144335872, 65}), + new BitArray(new int[] {0, 256, 1048576, -1601568064, 671109120, 1589117122, 393600, 3328}), + new BitArray(new int[] {0, 256, 1048576, -1601568064, 671105024, 1589117122, 393600, 3328}), + new BitArray(new int[] {5, 1140850944, 26214479, -493220892, 940361760, 1606227139, -2143942272, 3393}), + new BitArray(new int[] {0, 256, 1048576, -1601699136, 671105024, 1589117122, 393600, 3328}), + new BitArray(new int[] {0, 0, 1048576, -1601699136, 671105024, 1589117122, 393600, 3328}), + new BitArray(new int[] {0, 0, 1048576, -2138570624, 134234112, 67108864, 393216, 0}), + new BitArray(new int[] {0, 0, 0, -2139095040, 0, 67108864, 262144, 0}), + new BitArray(new int[] {-2, -1, -1, -1, -1, -1, -1, -1}), + new BitArray(new int[] {2097154, -2147483616, 0, 0, 0, 0, 0, 0}), + new BitArray(new int[] {4, 1140850690, 8650975, 1108355356, 9218084, 17106176, -533656048, 67}), + new BitArray(new int[] {-940564478, 889192447, 65, 1074825472, 72844640, 231424, 22030368, 4704}), + new BitArray(new int[] {-940564478, 889192413, 65, 1074825472, 72844640, 231424, 22030368, 4704}), + new BitArray(new int[] {4, -16777216, -1, -1, -1, -1, -1, 16383}), + new BitArray(new int[] {-61995012, 1174405224, -51384097, -972018405, -1030969182, 17106740, -97186288, 8259}), + new BitArray(new int[] {-61995012, 1174405160, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), + new BitArray(new int[] {-61995012, 1174405224, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), + new BitArray(new int[] {-66189316, 1174405160, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), + new BitArray(new int[] {-1007673342, 889192405, 65, 1074825472, 72843296, 231424, 22030368, 4160}), + new BitArray(new int[] {-1013972992, 822083461, 0, 0, 71499776, 163840, 16777216, 4096}), + new BitArray(new int[] {-66189316, 1174405176, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), + new BitArray(new int[] {4, 1140850690, 8650975, 1108355356, 9218084, 17106176, -533656048, 579}), + new BitArray(new int[] {-1007673342, 889192405, 65, 1074825472, 72843552, 231424, 22030368, 4160}), + new BitArray(new int[] {-1007673342, 889192413, 65, 1074825472, 72843552, 231424, 22030368, 4672}), + new BitArray(new int[] {-2, -9, -1, -1, -1, -1, -1, -1}), + new BitArray(new int[] {-1040382, 889192437, 65, 1074825472, 72843296, 231424, 22030368, 4160}), + new BitArray(new int[] {1006632960, 32, 0, 0, 0, 0, 0, 0}), + new BitArray(new int[] {1028, -16777216, -1, -1, -1, -1, -1, 16383}), + new BitArray(new int[] {-1038334, -1258291211, 65, 1074825472, 72844320, 231424, 22030368, 4160}), + new BitArray(new int[] {1007552508, 1140850720, -51384097, -972018405, -1030969182, 17106208, -365621744, 8259}), + new BitArray(new int[] {-1040382, -1258291209, 65, 1074825472, 72844320, 231424, 22030368, 4160}), + new BitArray(new int[] {0, 0, -60035072, 1027, 0, 0, 134217728, 0}), + new BitArray(new int[] {0, 67108864, 0, 1073743872, 1310752, 65536, 1050656, 64}), + new BitArray(new int[] {4194304, 67108864, 0, 1073743872, 1343520, 65536, 1050656, 64}), + new BitArray(new int[] {-66189316, 1174405160, -51384097, -972018401, -1030969182, 17106228, -97186288, 8259}), + new BitArray(new int[] {4194304, 67108864, 64, 1073743872, 1343520, 65536, 1050656, 64}), + new BitArray(new int[] {66189314, -1174405161, 51384096, 972018404, 1030969181, -17106229, 97186287, -8260}), + new BitArray(new int[] {65140738, 973078487, 51384096, 972018404, 1030969181, -17106229, 97186287, -8260}), + new BitArray(new int[] {-66189316, 1174405160, -51384097, -972018405, -1030969182, 17106228, -97186288, 8387}), + new BitArray(new int[] {0, 67108864, 0, 1073743872, 1343520, 65536, 1050656, 64}), + new BitArray(new int[] {-64092162, -973078488, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), + new BitArray(new int[] {-64092162, 1191182376, -1048865, -546062565, -1014191950, -1593504452, -21144002, 8903}), + new BitArray(new int[] {0, 0, 3072, 134447104, 16777216, 8, 0, 0}), + new BitArray(new int[] {-2097156, -1, -1, -1, -1, -1, -1, -1}), + new BitArray(new int[] {-66189316, 1191182376, -1051937, -680509669, -1030969166, -1593504460, -21144002, 8903}), + new BitArray(new int[] {-66189316, 1174405162, -51384097, -972018401, -1030969178, 17106228, -97186288, 8259}), + new BitArray(new int[] {6291458, 0, 0, 32768, 0, 0, 0, 0}), + new BitArray(new int[] {-64092162, 1174405160, -51384097, -971985637, -1030969182, 17106228, -97186288, 8259}), + new BitArray(new int[] {0, 0, 0, -1879044096, 0, 67108864, 67371040, 128}), + new BitArray(new int[] {36, 1140850688, 8388687, 1108347140, 821280, 17105920, -2144335872, 65}), + new BitArray(new int[] {2097158, 1140850688, 8388687, 1108347140, 821280, 17105920, -2144335872, 97}), + new BitArray(new int[] {2097154, -2147483648, 0, 0, 0, 0, 0, 32}), + new BitArray(new int[] {36, 1140850688, 8388687, 1108347140, 821280, 17105928, -2144335872, 65}), + new BitArray(new int[] {-66189316, 1174405160, -51384097, -972018405, -1030969166, 17106228, -97186284, 8259}), + new BitArray(new int[] {1007552508, 1140850720, -51384097, -972002021, -1030969182, 17106208, -365621744, 8259}), + new BitArray(new int[] {1007681536, -2147483614, 0, 0, 1024, 0, 0, 0}), + new BitArray(new int[] {1007681536, -2147483616, 0, 0, 1024, 0, 0, 0}), + new BitArray(new int[] {2097154, 0, 0, 0, 0, 0, 0, 129}), + new BitArray(new int[] {2097154, 0, 0, 32768, 0, 0, 0, 129}), + new BitArray(new int[] {-66189316, 1174405160, -51383073, -972018405, -1030969182, 17106228, -97186288, 8259}), + new BitArray(new int[] {-65140740, 1174409128, -51384097, -971985637, -1030903646, 17106228, -97186288, 8259}), + new BitArray(new int[] {-65140740, 1174409128, -51384097, -972018405, -1030903646, 17106228, -97186288, 8259}), + new BitArray(new int[] {1048576, 3968, 0, 0, 0, 0, 0, 0}), + new BitArray(new int[] {-64092162, 1191182376, -1051937, -680509669, -1030969166, -1593504460, -21144002, 8903}), + new BitArray(new int[] {-64092162, 1191182376, -1051937, -680476901, -1030969166, -1593504460, -21144002, 8903}), + new BitArray(new int[] {2097154, 32, 0, 32768, 0, 0, 0, 0}), + new BitArray(new int[] {7340034, -2147483614, 0, 32768, 0, 0, 0, 0}), + new BitArray(new int[] {7340034, -2147483616, 0, 32768, 0, 0, 0, 0}), + new BitArray(new int[] {7340034, 0, 0, 32768, 0, 0, 0, 0}), + new BitArray(new int[] {4, 1140850690, 8650975, 1108355356, 9218084, 17106180, -533656048, 67}), + new BitArray(new int[] {4, 1140851008, 8388975, 1108347140, 821280, 21316608, -2144335872, 65}), + new BitArray(new int[] {4, 1140850944, 8388975, 1108347140, 821280, 21316608, -2144335872, 65}), + new BitArray(new int[] {4, 1140850688, 8388975, 1108347140, 821280, 21316608, -2144335872, 65}), + new BitArray(new int[] {5242880, -2147483550, 0, 0, 0, 0, 0, 0}), + new BitArray(new int[] {5242880, -2147483552, 0, 0, 0, 0, 0, 0}), + new BitArray(new int[] {4, 1140850690, 8650975, 1108355356, 143435812, 17106176, -533656048, 67}), + new BitArray(new int[] {7, 1157628162, 26477055, -493212676, 948758565, 2147308999, -533262382, 3395}), + new BitArray(new int[] {918528, 0, 0, 0, 0, 0, 0, 0}), + new BitArray(new int[] {-909310, -1258291209, 65, 1074825472, 72844320, 231424, 22030368, 4160}), + new BitArray(new int[] {-843774, -1258291209, 65, 1074825472, 72844320, 231424, 22030368, 4160}), + new BitArray(new int[] {-318462, -1258291209, 65, 1074825472, 72844320, 231424, 22030368, 4160}), + new BitArray(new int[] {-383998, -1258291209, 65, 1074825472, 72844320, 231424, 22030368, 4160}), + new BitArray(new int[] {-1038334, -1258291209, 65, 1074825472, 72844320, 231424, 22030368, 4160}), + new BitArray(new int[] {4194308, 1140850754, 8650975, 1108355356, 9218084, 17106176, -533656048, 67}), + new BitArray(new int[] {4, 1140851008, 8388975, 1108347140, 821280, 21317120, -2144335872, 65}), + new BitArray(new int[] {4, 1073741824, 8388687, 34605312, 822304, 17105920, -2144335872, 65}), + new BitArray(new int[] {4, 1073741824, 8388687, 34605312, 821280, 16843776, -2144335872, 65}), + new BitArray(new int[] {4, 1140850698, 9699551, 1108355356, 9218084, 17106180, -533524976, 67}), + new BitArray(new int[] {4, 1140850690, 9699551, 1108355356, 9218084, 17106180, -533524976, 67}), + new BitArray(new int[] {4, 1140850946, 8650975, 1108355356, 9218084, 17106176, -533656048, 67}), + new BitArray(new int[] {4, 1140850944, 8388687, 1108478212, 821280, 17105920, -2144335872, 65}), + new BitArray(new int[] {4, 1140850944, 8388687, 1108347140, 821280, 17105920, -2144335872, 65}), + new BitArray(new int[] {4, 1140850944, 26214479, -493220892, 671930656, 1606227138, -2143942272, 3393}), + new BitArray(new int[] {4, 1140850944, 26214479, -493220892, 671926560, 1606227138, -2143942272, 3393}), + new BitArray(new int[] {4, 1140850944, 26214479, -493220892, 671926304, 1606227138, -2143942272, 3393}), + new BitArray(new int[] {4, 1140850944, 26214479, -493351964, 671926304, 1606227138, -2143942272, 3393}), + new BitArray(new int[] {4, 1140850688, 26214479, -493351964, 671926304, 1606227138, -2143942272, 3393}), + new BitArray(new int[] {4, 1140850688, 26214479, -1030223452, 135055392, 84218880, -2143942656, 65}), + new BitArray(new int[] {4, 1140850688, 25165903, -1030747868, 821280, 84218880, -2144073728, 65}), + new BitArray(new int[] {3145730, -2147483616, 0, 0, 256, 0, 0, 0}), + new BitArray(new int[] {3145730, -2147483648, 0, 0, 256, 0, 0, 0}), + new BitArray(new int[] {3145730, 0, 0, 0, 256, 0, 0, 0}), + new BitArray(new int[] {4, 1140850944, 26214479, -493220892, 671926305, 1606227138, -2143942208, 3393}), + new BitArray(new int[] {0, 256, 0, 537001984, 1, 436207616, 64, 0}), + new BitArray(new int[] {0, 256, 0, 536870912, 1, 436207616, 64, 0}), + new BitArray(new int[] {0, 0, 0, 536870912, 1, 436207616, 64, 0}), + new BitArray(new int[] {7340034, 0, 0, 0, 0, 0, 0, 0}), + new BitArray(new int[] {4, 1140850946, 8650975, 1108355356, 9218084, 17106180, -533656048, 67}), + new BitArray(new int[] {0, 16777472, 0, 131072, 0, 536870912, 2, 0}), + new BitArray(new int[] {0, 16777472, 0, 0, 0, 536870912, 2, 0}), + new BitArray(new int[] {2097154, -2147483616, 0, 0, 256, 0, 0, 0}), + new BitArray(new int[] {0, 1073741824, 4, -2147483648, 0, 0, -2147221504, 0}), + new BitArray(new int[] {2097154, -2013265888, 0, 0, 0, 0, 0, 0}), + new BitArray(new int[] {2097154, -2147483616, 0, 0, 320, 0, 0, 0}), + new BitArray(new int[] {2097154, 0, 0, 0, 320, 0, 0, 0}), + new BitArray(new int[] {4, 1140850690, 8650975, 1108355356, -1030969308, 17106176, -533656048, 67}), + new BitArray(new int[] {4, 1140850688, 25165903, 1108347136, 821280, 17105920, -2144335872, 65}), + new BitArray(new int[] {4, 1140850688, 8388687, 1108347136, 821280, 17105920, -2144335872, 65}), + new BitArray(new int[] {7340034, -2147483614, 0, 0, 0, 0, 0, 0}), + new BitArray(new int[] {7340034, -2147483616, 0, 0, 0, 0, 0, 0}), + new BitArray(new int[] {0, 256, 1048576, 537526400, 402669568, 444596289, 131200, 0}), + new BitArray(new int[] {1028, 1140850688, 8650975, 1108355356, 9218084, 17106176, -533656048, 67}), + new BitArray(new int[] {70254594, 34, 0, 0, 0, 0, 0, 0}), + new BitArray(new int[] {0, 0, 8388608, 33554432, 2048, 0, 32768, 0}), + new BitArray(new int[] {2097154, 0, 0, 0, 0, 3072, 0, 0}), + new BitArray(new int[] {0, 0, 0, 536870912, 268435456, 444596288, 128, 0}), + new BitArray(new int[] {0, 0, 0, 536871488, 536870912, 1522008258, 384, 3328}), + new BitArray(new int[] {0, 0, 262288, 8216, 8396800, 256, 1610679824, 2}), + new BitArray(new int[] {-1073741824, 33554432, 0, 0, 0, 16, 0, 0}), + new BitArray(new int[] {1006632960, 0, 0, 0, 0, 0, 0, 0}), + new BitArray(new int[] {1016, 0, 0, 67108864, -1040187392, 32, 33554432, 0}), + new BitArray(new int[] {4, 1073741824, 8388687, 34605312, 821280, 17105920, -2144335872, 65}), + new BitArray(new int[] {0, 0, -1133776896, 3, 0, 0, 0, 0}), + new BitArray(new int[] {-64092162, 1191182376, -1051937, -680378597, -1030969166, -1593504460, -21144002, 8903}), + new BitArray(new int[] {0, 0, 33554432, 16777216, 16, 0, 16392, 0}), + new BitArray(new int[] {-66189316, 1174405160, -51383585, -972018405, -1030969182, 17106228, -97186288, 8259}), + new BitArray(new int[] {1048576, 3968, 0, 0, 65536, 0, 0, 0}), + new BitArray(new int[] {0, 0, 288, 0, 0, 4210688, 0, 0}), + new BitArray(new int[] {-18434, -1, -1, -1, -1, -1, -1, -1}), + new BitArray(new int[] {-22530, -1, -1, -1, -1, -1, -1, -1}), + new BitArray(new int[] {-32770, -1, -1, -1, -1, -1, -1, -1}), + new BitArray(new int[] {-37890, -1, -1, -1, -1, -1, -1, -1}), + new BitArray(new int[] {-2050, -1, -1, -1, -1, -1, -1, -1}), + new BitArray(new int[] {-6146, -1, -1, -1, -1, -1, -1, -1}), + new BitArray(new int[] {4, 1140850944, 8388975, 1108347140, 821280, 21317120, -2144335872, 65}), + new BitArray(new int[] {0, 0, 0, 536870912, 0, 436207616, 0, 0}), + new BitArray(new int[] {2097154, 32, 0, 0, 256, 0, 0, 0}), + new BitArray(new int[] {4, 1140850688, 8650975, 1108355356, 9218084, 17106176, -533656048, 67}) + + }; + +} // end Parser + + +} \ No newline at end of file diff --git a/Project/Src/Lexer/VBNet/PushParser.frame b/Project/Src/Lexer/VBNet/PushParser.frame new file mode 100644 index 0000000000..2e7fcca080 --- /dev/null +++ b/Project/Src/Lexer/VBNet/PushParser.frame @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------- +Compiler Generator Coco/R, +Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz +extended by M. Loeberbauer & A. Woess, Univ. of Linz +with improvements by Pat Terry, Rhodes University + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As an exception, it is allowed to write an extension of Coco/R that is +used as a plugin in non-free software. + +If not otherwise stated, any source code generated by Coco/R (other than +Coco/R itself) does not fall under the GNU General Public License. +----------------------------------------------------------------------*/ +-->begin +-->namespace + +partial class ExpressionFinder { +-->constants + const bool T = true; + const bool x = false; + +-->declarations + readonly Stack stateStack = new Stack(); + bool wasQualifierTokenAtStart = false; + bool nextTokenIsPotentialStartOfExpression = false; + bool readXmlIdentifier = false; + bool identifierExpected = false; + bool nextTokenIsStartOfImportsOrAccessExpression = false; + bool isMissingModifier = false; + bool isAlreadyInExpr = false; + bool wasNormalAttribute = false; + int activeArgument = 0; + List errors = new List(); + + public ExpressionFinder() + { + stateStack.Push(-1); // required so that we don't crash when leaving the root production + } + + void Expect(int expectedKind, Token la) + { + if (la.kind != expectedKind) { + Error(la); + output.AppendLine("expected: " + expectedKind); + //Console.WriteLine("expected: " + expectedKind); + } + } + + void Error(Token la) + { + output.AppendLine("not expected: " + la); + //Console.WriteLine("not expected: " + la); + errors.Add(la); + } + + Token t; + + public void InformToken(Token la) + { + -->informToken + if (la != null) { + t = la; + nextTokenIsPotentialStartOfExpression = false; + readXmlIdentifier = false; + nextTokenIsStartOfImportsOrAccessExpression = false; + wasQualifierTokenAtStart = false; + identifierExpected = false; + } + } + + public void Advance() + { + //Console.WriteLine("Advance"); + InformToken(null); + } + + public BitArray GetExpectedSet() { return GetExpectedSet(currentState); } + + static readonly BitArray[] set = { +-->initialization + }; + +} // end Parser + + +$$$ \ No newline at end of file diff --git a/Project/Src/Lexer/VBNet/Tokens.cs b/Project/Src/Lexer/VBNet/Tokens.cs new file mode 100644 index 0000000000..2cf730c48b --- /dev/null +++ b/Project/Src/Lexer/VBNet/Tokens.cs @@ -0,0 +1,530 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +// this file was autogenerated by a tool. +using System; +using System.Collections; + +namespace ICSharpCode.NRefactory.Parser.VB +{ + public static class Tokens + { + // ----- terminal classes ----- + public const int EOF = 0; + public const int EOL = 1; + public const int Identifier = 2; + public const int LiteralString = 3; + public const int LiteralCharacter = 4; + public const int LiteralInteger = 5; + public const int LiteralDouble = 6; + public const int LiteralSingle = 7; + public const int LiteralDecimal = 8; + public const int LiteralDate = 9; + public const int XmlOpenTag = 10; + public const int XmlCloseTag = 11; + public const int XmlStartInlineVB = 12; + public const int XmlEndInlineVB = 13; + public const int XmlCloseTagEmptyElement = 14; + public const int XmlOpenEndTag = 15; + public const int XmlContent = 16; + public const int XmlComment = 17; + public const int XmlCData = 18; + public const int XmlProcessingInstruction = 19; + + // ----- special character ----- + public const int Assign = 20; + public const int Colon = 21; + public const int Comma = 22; + public const int ConcatString = 23; + public const int Div = 24; + public const int DivInteger = 25; + public const int Dot = 26; + public const int TripleDot = 27; + public const int DotAt = 28; + public const int ExclamationMark = 29; + public const int Minus = 30; + public const int Plus = 31; + public const int Power = 32; + public const int QuestionMark = 33; + public const int Times = 34; + public const int OpenCurlyBrace = 35; + public const int CloseCurlyBrace = 36; + public const int OpenParenthesis = 37; + public const int CloseParenthesis = 38; + public const int GreaterThan = 39; + public const int LessThan = 40; + public const int NotEqual = 41; + public const int GreaterEqual = 42; + public const int LessEqual = 43; + public const int ShiftLeft = 44; + public const int ShiftRight = 45; + public const int PlusAssign = 46; + public const int PowerAssign = 47; + public const int MinusAssign = 48; + public const int TimesAssign = 49; + public const int DivAssign = 50; + public const int DivIntegerAssign = 51; + public const int ShiftLeftAssign = 52; + public const int ShiftRightAssign = 53; + public const int ConcatStringAssign = 54; + public const int ColonAssign = 55; + + // ----- keywords ----- + public const int AddHandler = 56; + public const int AddressOf = 57; + public const int Aggregate = 58; + public const int Alias = 59; + public const int And = 60; + public const int AndAlso = 61; + public const int Ansi = 62; + public const int As = 63; + public const int Ascending = 64; + public const int Assembly = 65; + public const int Auto = 66; + public const int Binary = 67; + public const int Boolean = 68; + public const int ByRef = 69; + public const int By = 70; + public const int Byte = 71; + public const int ByVal = 72; + public const int Call = 73; + public const int Case = 74; + public const int Catch = 75; + public const int CBool = 76; + public const int CByte = 77; + public const int CChar = 78; + public const int CDate = 79; + public const int CDbl = 80; + public const int CDec = 81; + public const int Char = 82; + public const int CInt = 83; + public const int Class = 84; + public const int CLng = 85; + public const int CObj = 86; + public const int Compare = 87; + public const int Const = 88; + public const int Continue = 89; + public const int CSByte = 90; + public const int CShort = 91; + public const int CSng = 92; + public const int CStr = 93; + public const int CType = 94; + public const int CUInt = 95; + public const int CULng = 96; + public const int CUShort = 97; + public const int Custom = 98; + public const int Date = 99; + public const int Decimal = 100; + public const int Declare = 101; + public const int Default = 102; + public const int Delegate = 103; + public const int Descending = 104; + public const int Dim = 105; + public const int DirectCast = 106; + public const int Distinct = 107; + public const int Do = 108; + public const int Double = 109; + public const int Each = 110; + public const int Else = 111; + public const int ElseIf = 112; + public const int End = 113; + public const int EndIf = 114; + public const int Enum = 115; + new public const int Equals = 116; + public const int Erase = 117; + public const int Error = 118; + public const int Event = 119; + public const int Exit = 120; + public const int Explicit = 121; + public const int False = 122; + public const int Finally = 123; + public const int For = 124; + public const int Friend = 125; + public const int From = 126; + public const int Function = 127; + public const int Get = 128; + new public const int GetType = 129; + public const int Global = 130; + public const int GoSub = 131; + public const int GoTo = 132; + public const int Group = 133; + public const int Handles = 134; + public const int If = 135; + public const int Implements = 136; + public const int Imports = 137; + public const int In = 138; + public const int Infer = 139; + public const int Inherits = 140; + public const int Integer = 141; + public const int Interface = 142; + public const int Into = 143; + public const int Is = 144; + public const int IsNot = 145; + public const int Join = 146; + public const int Key = 147; + public const int Let = 148; + public const int Lib = 149; + public const int Like = 150; + public const int Long = 151; + public const int Loop = 152; + public const int Me = 153; + public const int Mod = 154; + public const int Module = 155; + public const int MustInherit = 156; + public const int MustOverride = 157; + public const int MyBase = 158; + public const int MyClass = 159; + public const int Namespace = 160; + public const int Narrowing = 161; + public const int New = 162; + public const int Next = 163; + public const int Not = 164; + public const int Nothing = 165; + public const int NotInheritable = 166; + public const int NotOverridable = 167; + public const int Object = 168; + public const int Of = 169; + public const int Off = 170; + public const int On = 171; + public const int Operator = 172; + public const int Option = 173; + public const int Optional = 174; + public const int Or = 175; + public const int Order = 176; + public const int OrElse = 177; + public const int Out = 178; + public const int Overloads = 179; + public const int Overridable = 180; + public const int Overrides = 181; + public const int ParamArray = 182; + public const int Partial = 183; + public const int Preserve = 184; + public const int Private = 185; + public const int Property = 186; + public const int Protected = 187; + public const int Public = 188; + public const int RaiseEvent = 189; + public const int ReadOnly = 190; + public const int ReDim = 191; + public const int Rem = 192; + public const int RemoveHandler = 193; + public const int Resume = 194; + public const int Return = 195; + public const int SByte = 196; + public const int Select = 197; + public const int Set = 198; + public const int Shadows = 199; + public const int Shared = 200; + public const int Short = 201; + public const int Single = 202; + public const int Skip = 203; + public const int Static = 204; + public const int Step = 205; + public const int Stop = 206; + public const int Strict = 207; + public const int String = 208; + public const int Structure = 209; + public const int Sub = 210; + public const int SyncLock = 211; + public const int Take = 212; + public const int Text = 213; + public const int Then = 214; + public const int Throw = 215; + public const int To = 216; + public const int True = 217; + public const int Try = 218; + public const int TryCast = 219; + public const int TypeOf = 220; + public const int UInteger = 221; + public const int ULong = 222; + public const int Unicode = 223; + public const int Until = 224; + public const int UShort = 225; + public const int Using = 226; + public const int Variant = 227; + public const int Wend = 228; + public const int When = 229; + public const int Where = 230; + public const int While = 231; + public const int Widening = 232; + public const int With = 233; + public const int WithEvents = 234; + public const int WriteOnly = 235; + public const int Xor = 236; + public const int GetXmlNamespace = 237; + + public const int MaxToken = 238; + static BitArray NewSet(params int[] values) + { + BitArray bitArray = new BitArray(MaxToken); + foreach (int val in values) { + bitArray[val] = true; + } + return bitArray; + } + public static BitArray Null = NewSet(Nothing); + public static BitArray BlockSucc = NewSet(Case, Catch, Else, ElseIf, End, Finally, Loop, Next); + public static BitArray GlobalLevel = NewSet(Namespace, Module, Class, Structure, Imports, Option); + public static BitArray TypeLevel = NewSet(Sub, Function, Property); + public static BitArray IdentifierTokens = NewSet(Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Out, Key, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate); + public static BitArray ExpressionStart = NewSet(Me, MyBase, MyClass, True, False, Not, From, Aggregate, New, Nothing, AddressOf, GetType, TypeOf, GetXmlNamespace, Global, Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte, Sub, Function, DirectCast, TryCast, CType, CBool, CByte, CChar, CDate, CDec, CDbl, CInt, CLng, CObj, CSByte, CShort, CSng, CStr, CUInt, CULng, CUShort); + public static BitArray StatementStart = NewSet(Nothing, Me, MyBase, MyClass, True, False, Not, From, Aggregate, New, Nothing, AddressOf, GetType, TypeOf, GetXmlNamespace, Global, Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte, Sub, Function, DirectCast, TryCast, CType, CBool, CByte, CChar, CDate, CDec, CDbl, CInt, CLng, CObj, CSByte, CShort, CSng, CStr, CUInt, CULng, CUShort, Dim, Const, Static, For, While, Do, Select); + public static BitArray SimpleTypeName = NewSet(Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte, Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Out, Key, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate); + public static BitArray CastExpressions = NewSet(DirectCast, TryCast, CType, CBool, CByte, CChar, CDate, CDec, CDbl, CInt, CLng, CObj, CSByte, CShort, CSng, CStr, CUInt, CULng, CUShort); + public static BitArray BooleanExpressions = NewSet(True, False); + public static BitArray LambdaStart = NewSet(Sub, Function); + public static BitArray OperatorsAtStart = NewSet(Not, From, Aggregate); + public static BitArray TypeKW = NewSet(Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte); + + static string[] tokenList = new string[] { + // ----- terminal classes ----- + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + // ----- special character ----- + "=", + ":", + ",", + "&", + "/", + "\\", + ".", + "...", + ".@", + "!", + "-", + "+", + "^", + "?", + "*", + "{", + "}", + "(", + ")", + ">", + "<", + "<>", + ">=", + "<=", + "<<", + ">>", + "+=", + "^=", + "-=", + "*=", + "/=", + "\\=", + "<<=", + ">>=", + "&=", + ":=", + // ----- keywords ----- + "AddHandler", + "AddressOf", + "Aggregate", + "Alias", + "And", + "AndAlso", + "Ansi", + "As", + "Ascending", + "Assembly", + "Auto", + "Binary", + "Boolean", + "ByRef", + "By", + "Byte", + "ByVal", + "Call", + "Case", + "Catch", + "CBool", + "CByte", + "CChar", + "CDate", + "CDbl", + "CDec", + "Char", + "CInt", + "Class", + "CLng", + "CObj", + "Compare", + "Const", + "Continue", + "CSByte", + "CShort", + "CSng", + "CStr", + "CType", + "CUInt", + "CULng", + "CUShort", + "Custom", + "Date", + "Decimal", + "Declare", + "Default", + "Delegate", + "Descending", + "Dim", + "DirectCast", + "Distinct", + "Do", + "Double", + "Each", + "Else", + "ElseIf", + "End", + "EndIf", + "Enum", + "Equals", + "Erase", + "Error", + "Event", + "Exit", + "Explicit", + "False", + "Finally", + "For", + "Friend", + "From", + "Function", + "Get", + "GetType", + "Global", + "GoSub", + "GoTo", + "Group", + "Handles", + "If", + "Implements", + "Imports", + "In", + "Infer", + "Inherits", + "Integer", + "Interface", + "Into", + "Is", + "IsNot", + "Join", + "Key", + "Let", + "Lib", + "Like", + "Long", + "Loop", + "Me", + "Mod", + "Module", + "MustInherit", + "MustOverride", + "MyBase", + "MyClass", + "Namespace", + "Narrowing", + "New", + "Next", + "Not", + "Nothing", + "NotInheritable", + "NotOverridable", + "Object", + "Of", + "Off", + "On", + "Operator", + "Option", + "Optional", + "Or", + "Order", + "OrElse", + "Out", + "Overloads", + "Overridable", + "Overrides", + "ParamArray", + "Partial", + "Preserve", + "Private", + "Property", + "Protected", + "Public", + "RaiseEvent", + "ReadOnly", + "ReDim", + "Rem", + "RemoveHandler", + "Resume", + "Return", + "SByte", + "Select", + "Set", + "Shadows", + "Shared", + "Short", + "Single", + "Skip", + "Static", + "Step", + "Stop", + "Strict", + "String", + "Structure", + "Sub", + "SyncLock", + "Take", + "Text", + "Then", + "Throw", + "To", + "True", + "Try", + "TryCast", + "TypeOf", + "UInteger", + "ULong", + "Unicode", + "Until", + "UShort", + "Using", + "Variant", + "Wend", + "When", + "Where", + "While", + "Widening", + "With", + "WithEvents", + "WriteOnly", + "Xor", + "GetXmlNamespace", + }; + public static string GetTokenString(int token) + { + if (token >= 0 && token < tokenList.Length) { + return tokenList[token]; + } + throw new System.NotSupportedException("Unknown token:" + token); + } + } +} diff --git a/Project/Src/Lexer/VBNet/VBLexerMemento.cs b/Project/Src/Lexer/VBNet/VBLexerMemento.cs new file mode 100644 index 0000000000..61a2c01787 --- /dev/null +++ b/Project/Src/Lexer/VBNet/VBLexerMemento.cs @@ -0,0 +1,19 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.Parser.VB +{ + public sealed class VBLexerMemento : LexerMemento + { + public bool LineEnd { get; set; } + public bool IsAtLineBegin { get; set; } + public bool MisreadExclamationMarkAsTypeCharacter { get; set; } + public bool EncounteredLineContinuation { get; set; } + public ExpressionFinderState ExpressionFinder { get; set; } + public Stack XmlModeInfoStack { get; set; } + public bool InXmlMode { get; set; } + } +} diff --git a/Project/Src/Lexer/VBNet/XmlModeInfo.cs b/Project/Src/Lexer/VBNet/XmlModeInfo.cs new file mode 100644 index 0000000000..20bfcc8a7e --- /dev/null +++ b/Project/Src/Lexer/VBNet/XmlModeInfo.cs @@ -0,0 +1,29 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory.Parser.VB +{ + public class XmlModeInfo : ICloneable + { + public bool inXmlTag, inXmlCloseTag, isDocumentStart; + public int level; + + public XmlModeInfo(bool isSpecial) + { + level = isSpecial ? -1 : 0; + inXmlTag = inXmlCloseTag = isDocumentStart = false; + } + + public object Clone() + { + return new XmlModeInfo(false) { + inXmlCloseTag = this.inXmlCloseTag, + inXmlTag = this.inXmlTag, + isDocumentStart = this.isDocumentStart, + level = this.level + }; + } + } +} diff --git a/Project/Src/Location.cs b/Project/Src/Location.cs new file mode 100644 index 0000000000..7bd2f2195d --- /dev/null +++ b/Project/Src/Location.cs @@ -0,0 +1,121 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.NRefactory +{ + /// + /// A line/column position. + /// NRefactory lines/columns are counting from one. + /// + public struct Location : IComparable, IEquatable + { + public static readonly Location Empty = new Location(-1, -1); + + public Location(int column, int line) + { + x = column; + y = line; + } + + int x, y; + + public int X { + get { return x; } + set { x = value; } + } + + public int Y { + get { return y; } + set { y = value; } + } + + public int Line { + get { return y; } + set { y = value; } + } + + public int Column { + get { return x; } + set { x = value; } + } + + public bool IsEmpty { + get { + return x <= 0 && y <= 0; + } + } + + public override string ToString() + { + return string.Format("(Line {1}, Col {0})", this.x, this.y); + } + + public override int GetHashCode() + { + return unchecked (87 * x.GetHashCode() ^ y.GetHashCode()); + } + + public override bool Equals(object obj) + { + if (!(obj is Location)) return false; + return (Location)obj == this; + } + + public bool Equals(Location other) + { + return this == other; + } + + public static bool operator ==(Location a, Location b) + { + return a.x == b.x && a.y == b.y; + } + + public static bool operator !=(Location a, Location b) + { + return a.x != b.x || a.y != b.y; + } + + public static bool operator <(Location a, Location b) + { + if (a.y < b.y) + return true; + else if (a.y == b.y) + return a.x < b.x; + else + return false; + } + + public static bool operator >(Location a, Location b) + { + if (a.y > b.y) + return true; + else if (a.y == b.y) + return a.x > b.x; + else + return false; + } + + public static bool operator <=(Location a, Location b) + { + return !(a > b); + } + + public static bool operator >=(Location a, Location b) + { + return !(a < b); + } + + public int CompareTo(Location other) + { + if (this == other) + return 0; + if (this < other) + return -1; + else + return 1; + } + } +} diff --git a/Project/Src/OperatorPrecedence.cs b/Project/Src/OperatorPrecedence.cs new file mode 100644 index 0000000000..8a5c60617c --- /dev/null +++ b/Project/Src/OperatorPrecedence.cs @@ -0,0 +1,84 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using ICSharpCode.NRefactory.Ast; + +namespace ICSharpCode.NRefactory +{ + /// + /// Stores the operator precedences for the output visitor. + /// + static class OperatorPrecedence + { + static readonly Dictionary vbDict = MakePrecedenceTable( + new BinaryOperatorType[] { BinaryOperatorType.Power }, + new BinaryOperatorType[] { BinaryOperatorType.Multiply, BinaryOperatorType.Divide }, + new BinaryOperatorType[] { BinaryOperatorType.DivideInteger }, + new BinaryOperatorType[] { BinaryOperatorType.Modulus }, + new BinaryOperatorType[] { BinaryOperatorType.Add, BinaryOperatorType.Subtract }, + new BinaryOperatorType[] { BinaryOperatorType.Concat }, + new BinaryOperatorType[] { BinaryOperatorType.ShiftLeft, BinaryOperatorType.ShiftRight }, + new BinaryOperatorType[] { + BinaryOperatorType.Equality, BinaryOperatorType.InEquality, + BinaryOperatorType.LessThan, BinaryOperatorType.LessThanOrEqual, + BinaryOperatorType.GreaterThan, BinaryOperatorType.GreaterThanOrEqual, + BinaryOperatorType.ReferenceEquality, BinaryOperatorType.ReferenceInequality, + BinaryOperatorType.Like + }, + new BinaryOperatorType[] { BinaryOperatorType.LogicalAnd, BinaryOperatorType.BitwiseAnd }, + new BinaryOperatorType[] { BinaryOperatorType.LogicalOr, BinaryOperatorType.BitwiseOr }, + new BinaryOperatorType[] { BinaryOperatorType.ExclusiveOr } + ); + + static readonly Dictionary csharpDict = MakePrecedenceTable( + new BinaryOperatorType[] { BinaryOperatorType.Multiply, BinaryOperatorType.Divide, BinaryOperatorType.Modulus }, + new BinaryOperatorType[] { BinaryOperatorType.Add, BinaryOperatorType.Subtract }, + new BinaryOperatorType[] { BinaryOperatorType.ShiftLeft, BinaryOperatorType.ShiftRight }, + new BinaryOperatorType[] { + BinaryOperatorType.LessThan, BinaryOperatorType.LessThanOrEqual, + BinaryOperatorType.GreaterThan, BinaryOperatorType.GreaterThanOrEqual, + }, + new BinaryOperatorType[] { BinaryOperatorType.Equality, BinaryOperatorType.InEquality }, + new BinaryOperatorType[] { BinaryOperatorType.BitwiseAnd }, + new BinaryOperatorType[] { BinaryOperatorType.ExclusiveOr }, + new BinaryOperatorType[] { BinaryOperatorType.BitwiseOr }, + new BinaryOperatorType[] { BinaryOperatorType.LogicalAnd, BinaryOperatorType.LogicalOr }, + new BinaryOperatorType[] { BinaryOperatorType.NullCoalescing } + ); + + // create a dictionary operator->precedence (higher value = higher precedence) + static Dictionary MakePrecedenceTable(params BinaryOperatorType[][] input) + { + Dictionary dict = new Dictionary(); + for (int i = 0; i < input.Length; i++) { + foreach (BinaryOperatorType op in input[i]) { + dict.Add(op, input.Length - i); + } + } + return dict; + } + + public static int ComparePrecedenceVB(BinaryOperatorType op1, BinaryOperatorType op2) + { + int p1 = GetOperatorPrecedence(vbDict, op1); + int p2 = GetOperatorPrecedence(vbDict, op2); + return p1.CompareTo(p2); + } + + public static int ComparePrecedenceCSharp(BinaryOperatorType op1, BinaryOperatorType op2) + { + int p1 = GetOperatorPrecedence(csharpDict, op1); + int p2 = GetOperatorPrecedence(csharpDict, op2); + return p1.CompareTo(p2); + } + + static int GetOperatorPrecedence(Dictionary dict, BinaryOperatorType op) + { + int p; + dict.TryGetValue(op, out p); + return p; + } + } +} diff --git a/Project/Src/Parser/AbstractParser.cs b/Project/Src/Parser/AbstractParser.cs new file mode 100644 index 0000000000..049e52496c --- /dev/null +++ b/Project/Src/Parser/AbstractParser.cs @@ -0,0 +1,106 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using ICSharpCode.NRefactory.Ast; + +namespace ICSharpCode.NRefactory.Parser +{ + public abstract class AbstractParser : IParser + { + protected const int MinErrDist = 2; + protected const string ErrMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text + + + private Errors errors; + private ILexer lexer; + + protected int errDist = MinErrDist; + + [CLSCompliant(false)] + protected CompilationUnit compilationUnit; + + bool parseMethodContents = true; + + public bool ParseMethodBodies { + get { + return parseMethodContents; + } + set { + parseMethodContents = value; + } + } + + public ILexer Lexer { + get { + return lexer; + } + } + + public Errors Errors { + get { + return errors; + } + } + + public CompilationUnit CompilationUnit { + get { + return compilationUnit; + } + } + + internal AbstractParser(ILexer lexer) + { + this.errors = lexer.Errors; + this.lexer = lexer; + errors.SynErr = new ErrorCodeProc(SynErr); + } + + public abstract void Parse(); + + public abstract TypeReference ParseTypeReference (); + public abstract Expression ParseExpression(); + public abstract BlockStatement ParseBlock(); + public abstract List ParseTypeMembers(); + + protected abstract void SynErr(int line, int col, int errorNumber); + + protected void SynErr(int n) + { + if (errDist >= MinErrDist) { + errors.SynErr(lexer.LookAhead.line, lexer.LookAhead.col, n); + } + errDist = 0; + } + + protected void SemErr(string msg) + { + if (errDist >= MinErrDist) { + errors.Error(lexer.Token.line, lexer.Token.col, msg); + } + errDist = 0; + } + + protected void Expect(int n) + { + if (lexer.LookAhead.kind == n) { + lexer.NextToken(); + } else { + SynErr(n); + } + } + + #region System.IDisposable interface implementation + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")] + public void Dispose() + { + errors = null; + if (lexer != null) { + lexer.Dispose(); + } + lexer = null; + } + #endregion + } +} diff --git a/Project/Src/Parser/CSharp/CSharpParser.cs b/Project/Src/Parser/CSharp/CSharpParser.cs new file mode 100644 index 0000000000..b66199d3e3 --- /dev/null +++ b/Project/Src/Parser/CSharp/CSharpParser.cs @@ -0,0 +1,695 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using ICSharpCode.NRefactory.Visitors; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using ICSharpCode.NRefactory.Ast; + +namespace ICSharpCode.NRefactory.Parser.CSharp +{ + internal sealed partial class Parser : AbstractParser + { + Lexer lexer; + Stack blockStack; + + public Parser(ILexer lexer) : base(lexer) + { + this.lexer = (Lexer)lexer; + this.blockStack = new Stack(); + } + + void BlockStart(INode block) + { + blockStack.Push(block); + } + + void BlockEnd() + { + blockStack.Pop(); + } + + void AddChild(INode childNode) + { + if (childNode != null) { + INode parent = (INode)blockStack.Peek(); + parent.Children.Add(childNode); + childNode.Parent = parent; + } + } + + StringBuilder qualidentBuilder = new StringBuilder(); + + Token t { + [System.Diagnostics.DebuggerStepThrough] + get { + return lexer.Token; + } + } + + Token la { + [System.Diagnostics.DebuggerStepThrough] + get { + return lexer.LookAhead; + } + } + + public void Error(string s) + { + if (errDist >= MinErrDist) { + this.Errors.Error(la.line, la.col, s); + } + errDist = 0; + } + + public override void Parse() + { + ParseRoot(); + compilationUnit.AcceptVisitor(new SetParentVisitor(), null); + } + + public override TypeReference ParseTypeReference () + { + lexer.NextToken(); + TypeReference type; + Type(out type); + return type; + } + + public override Expression ParseExpression() + { + lexer.NextToken(); + Location startLocation = la.Location; + Expression expr; + Expr(out expr); + // SEMICOLON HACK : without a trailing semicolon, parsing expressions does not work correctly + if (la.kind == Tokens.Semicolon) lexer.NextToken(); + if (expr != null) { + if (expr.StartLocation.IsEmpty) + expr.StartLocation = startLocation; + if (expr.EndLocation.IsEmpty) + expr.EndLocation = (t ?? la).EndLocation; + expr.AcceptVisitor(new SetParentVisitor(), null); + } + Expect(Tokens.EOF); + return expr; + } + + public override BlockStatement ParseBlock() + { + lexer.NextToken(); + compilationUnit = new CompilationUnit(); + + BlockStatement blockStmt = new BlockStatement(); + blockStmt.StartLocation = la.Location; + BlockStart(blockStmt); + + while (la.kind != Tokens.EOF) { + Token oldLa = la; + Statement(); + if (la == oldLa) { + // did not advance lexer position, we cannot parse this as a statement block + return null; + } + } + + BlockEnd(); + // if lexer didn't return any tokens, use position of the EOF token in "la" + blockStmt.EndLocation = (t ?? la).EndLocation; + Expect(Tokens.EOF); + blockStmt.AcceptVisitor(new SetParentVisitor(), null); + return blockStmt; + } + + public override List ParseTypeMembers() + { + lexer.NextToken(); + compilationUnit = new CompilationUnit(); + + TypeDeclaration newType = new TypeDeclaration(Modifiers.None, null); + BlockStart(newType); + ClassBody(); + BlockEnd(); + Expect(Tokens.EOF); + newType.AcceptVisitor(new SetParentVisitor(), null); + return newType.Children; + } + + // Begin ISTypeCast + bool IsTypeCast() + { + if (la.kind != Tokens.OpenParenthesis) { + return false; + } + bool isPossibleExpression = true; + + lexer.StartPeek(); + Token pt = lexer.Peek(); + + if (!IsTypeNameOrKWForTypeCast(ref pt, ref isPossibleExpression)) { + return false; + } + + // ")" + if (pt.kind != Tokens.CloseParenthesis) { + return false; + } + if (isPossibleExpression) { + // check successor + pt = lexer.Peek(); + return Tokens.CastFollower[pt.kind]; + } else { + // not possibly an expression: don't check cast follower + return true; + } + } + + /* !!! Proceeds from current peek position !!! */ + bool IsTypeKWForTypeCast(ref Token pt) + { + if (Tokens.TypeKW[pt.kind]) { + pt = lexer.Peek(); + return IsPointerOrDims(ref pt) && SkipQuestionMark(ref pt); + } else if (pt.kind == Tokens.Void) { + pt = lexer.Peek(); + return IsPointerOrDims(ref pt); + } + return false; + } + + /* !!! Proceeds from current peek position !!! */ + bool IsTypeNameOrKWForTypeCast(ref Token pt, ref bool isPossibleExpression) + { + if (Tokens.TypeKW[pt.kind] || pt.kind == Tokens.Void) { + isPossibleExpression = false; + return IsTypeKWForTypeCast(ref pt); + } else { + return IsTypeNameForTypeCast(ref pt, ref isPossibleExpression); + } + } + + bool IsTypeNameOrKWForTypeCast(ref Token pt) + { + bool tmp = false; + return IsTypeNameOrKWForTypeCast(ref pt, ref tmp); + } + + // TypeName = ident [ "::" ident ] { ["<" TypeNameOrKW { "," TypeNameOrKW } ">" ] "." ident } ["?"] PointerOrDims + /* !!! Proceeds from current peek position !!! */ + bool IsTypeNameForTypeCast(ref Token pt, ref bool isPossibleExpression) + { + // ident + if (!IsIdentifierToken(pt)) { + return false; + } + pt = Peek(); + // "::" ident + if (pt.kind == Tokens.DoubleColon) { + pt = Peek(); + if (!IsIdentifierToken(pt)) { + return false; + } + pt = Peek(); + } + // { ["<" TypeNameOrKW { "," TypeNameOrKW } ">" ] "." ident } + while (true) { + if (pt.kind == Tokens.LessThan) { + do { + pt = Peek(); + if (!IsTypeNameOrKWForTypeCast(ref pt)) { + return false; + } + } while (pt.kind == Tokens.Comma); + if (pt.kind != Tokens.GreaterThan) { + return false; + } + pt = Peek(); + } + if (pt.kind != Tokens.Dot) + break; + pt = Peek(); + if (pt.kind != Tokens.Identifier) { + return false; + } + pt = Peek(); + } + // ["?"] + if (pt.kind == Tokens.Question) { + pt = Peek(); + } + if (pt.kind == Tokens.Times || pt.kind == Tokens.OpenSquareBracket) { + isPossibleExpression = false; + return IsPointerOrDims(ref pt); + } + return true; + } + // END IsTypeCast + + // Gets if the token is a possible token for an expression start + // Is used to determine if "a is Type ? token" a the start of a ternary + // expression or a type test for Nullable + bool IsPossibleExpressionStart(int token) + { + return Tokens.CastFollower[token] || Tokens.UnaryOp[token]; + } + + // ( { [TypeNameOrKWForTypeCast] ident "," } ) + bool IsLambdaExpression() + { + if (la.kind != Tokens.OpenParenthesis) { + return false; + } + StartPeek(); + Token pt = Peek(); + while (pt.kind != Tokens.CloseParenthesis) { + if (pt.kind == Tokens.Out || pt.kind == Tokens.Ref) { + pt = Peek(); + } + if (!IsTypeNameOrKWForTypeCast(ref pt)) { + return false; + } + if (IsIdentifierToken(pt)) { + // make ident optional: if implicitly typed lambda arguments are used, IsTypeNameForTypeCast + // has already accepted the identifier + pt = Peek(); + } + if (pt.kind == Tokens.CloseParenthesis) { + break; + } + // require comma between parameters: + if (pt.kind == Tokens.Comma) { + pt = Peek(); + } else { + return false; + } + } + pt = Peek(); + return pt.kind == Tokens.LambdaArrow; + } + + /* Checks whether the next sequences of tokens is a qualident * + * and returns the qualident string */ + /* !!! Proceeds from current peek position !!! */ + bool IsQualident(ref Token pt, out string qualident) + { + if (IsIdentifierToken(pt)) { + qualidentBuilder.Length = 0; qualidentBuilder.Append(pt.val); + pt = Peek(); + while (pt.kind == Tokens.Dot || pt.kind == Tokens.DoubleColon) { + pt = Peek(); + if (!IsIdentifierToken(pt)) { + qualident = String.Empty; + return false; + } + qualidentBuilder.Append('.'); + qualidentBuilder.Append(pt.val); + pt = Peek(); + } + qualident = qualidentBuilder.ToString(); + return true; + } + qualident = String.Empty; + return false; + } + + /* Skips generic type extensions */ + /* !!! Proceeds from current peek position !!! */ + + /* skip: { "*" | "[" { "," } "]" } */ + /* !!! Proceeds from current peek position !!! */ + bool IsPointerOrDims (ref Token pt) + { + for (;;) { + if (pt.kind == Tokens.OpenSquareBracket) { + do pt = Peek(); + while (pt.kind == Tokens.Comma); + if (pt.kind != Tokens.CloseSquareBracket) return false; + } else if (pt.kind != Tokens.Times) break; + pt = Peek(); + } + return true; + } + + /* Return the n-th token after the current lookahead token */ + void StartPeek() + { + lexer.StartPeek(); + } + + Token Peek() + { + return lexer.Peek(); + } + + Token Peek (int n) + { + lexer.StartPeek(); + Token x = la; + while (n > 0) { + x = lexer.Peek(); + n--; + } + return x; + } + + /*-----------------------------------------------------------------* + * Resolver routines to resolve LL(1) conflicts: * * + * These resolution routine return a boolean value that indicates * + * whether the alternative at hand shall be choosen or not. * + * They are used in IF ( ... ) expressions. * + *-----------------------------------------------------------------*/ + + /* True, if ident is followed by "=" */ + bool IdentAndAsgn () + { + return IsIdentifierToken(la) && Peek(1).kind == Tokens.Assign; + } + + bool IdentAndDoubleColon () + { + return IsIdentifierToken(la) && Peek(1).kind == Tokens.DoubleColon; + } + + bool IsAssignment () { return IdentAndAsgn(); } + + /* True, if ident is followed by ",", "=", "[" or ";" */ + bool IsVarDecl () { + int peek = Peek(1).kind; + return IsIdentifierToken(la) && + (peek == Tokens.Comma || peek == Tokens.Assign || peek == Tokens.Semicolon || peek == Tokens.OpenSquareBracket); + } + + /* True, if the comma is not a trailing one, * + * like the last one in: a, b, c, */ + bool NotFinalComma () { + int peek = Peek(1).kind; + return la.kind == Tokens.Comma && + peek != Tokens.CloseCurlyBrace && peek != Tokens.CloseSquareBracket; + } + + /* True, if "void" is followed by "*" */ + bool NotVoidPointer () { + return la.kind == Tokens.Void && Peek(1).kind != Tokens.Times; + } + + /* True, if "checked" or "unchecked" are followed by "{" */ + bool UnCheckedAndLBrace () { + return (la.kind == Tokens.Checked || la.kind == Tokens.Unchecked) && + Peek(1).kind == Tokens.OpenCurlyBrace; + } + + /* True, if "." is followed by an ident */ + bool DotAndIdent () { + return la.kind == Tokens.Dot && IsIdentifierToken(Peek(1)); + } + + /* True, if ident is followed by ":" */ + bool IdentAndColon () { + return IsIdentifierToken(la) && Peek(1).kind == Tokens.Colon; + } + + bool IsLabel () { return IdentAndColon(); } + + /* True, if ident is followed by "(" */ + bool IdentAndLPar () { + return IsIdentifierToken(la) && Peek(1).kind == Tokens.OpenParenthesis; + } + + /* True, if "catch" is followed by "(" */ + bool CatchAndLPar () { + return la.kind == Tokens.Catch && Peek(1).kind == Tokens.OpenParenthesis; + } + bool IsTypedCatch () { return CatchAndLPar(); } + + /* True, if "[" is followed by the ident "assembly" */ + bool IsGlobalAttrTarget () { + Token pt = Peek(1); + return la.kind == Tokens.OpenSquareBracket && + IsIdentifierToken(pt) && (pt.val == "assembly" || pt.val == "module"); + } + + /* True, if "[" is followed by "," or "]" */ + bool LBrackAndCommaOrRBrack () { + int peek = Peek(1).kind; + return la.kind == Tokens.OpenSquareBracket && + (peek == Tokens.Comma || peek == Tokens.CloseSquareBracket); + } + + /* True, if "[" is followed by "," or "]" */ + /* or if the current token is "*" */ + bool TimesOrLBrackAndCommaOrRBrack () { + return la.kind == Tokens.Times || LBrackAndCommaOrRBrack(); + } + bool IsPointerOrDims () { return TimesOrLBrackAndCommaOrRBrack(); } + bool IsPointer () { return la.kind == Tokens.Times; } + + + bool SkipGeneric(ref Token pt) + { + if (pt.kind == Tokens.LessThan) { + do { + pt = Peek(); + if (!IsTypeNameOrKWForTypeCast(ref pt)) return false; + } while (pt.kind == Tokens.Comma); + if (pt.kind != Tokens.GreaterThan) return false; + pt = Peek(); + } + return true; + } + bool SkipQuestionMark(ref Token pt) + { + if (pt.kind == Tokens.Question) { + pt = Peek(); + } + return true; + } + + /* True, if lookahead is a primitive type keyword, or */ + /* if it is a type declaration followed by an ident */ + bool IsLocalVarDecl () { + if (IsYieldStatement()) { + return false; + } + if ((Tokens.TypeKW[la.kind] && Peek(1).kind != Tokens.Dot) || la.kind == Tokens.Void) { + return true; + } + + StartPeek(); + Token pt = la; + return IsTypeNameOrKWForTypeCast(ref pt) && IsIdentifierToken(pt); + } + + /* True if lookahead is a type argument list (<...>) followed by + * one of "( ) ] } : ; , . ? == !=" */ + bool IsGenericInSimpleNameOrMemberAccess() + { + Token t = la; + if (t.kind != Tokens.LessThan) return false; + StartPeek(); + return SkipGeneric(ref t) && Tokens.GenericFollower[t.kind]; + } + + bool IsExplicitInterfaceImplementation() + { + StartPeek(); + Token pt = la; + pt = Peek(); + if (pt.kind == Tokens.Dot || pt.kind == Tokens.DoubleColon) + return true; + if (pt.kind == Tokens.LessThan) { + if (SkipGeneric(ref pt)) + return pt.kind == Tokens.Dot; + } + return false; + } + + /* True, if lookahead ident is "yield" and than follows a break or return */ + bool IsYieldStatement () { + return la.kind == Tokens.Yield && (Peek(1).kind == Tokens.Return || Peek(1).kind == Tokens.Break); + } + + /* True, if lookahead is a local attribute target specifier, * + * i.e. one of "event", "return", "field", "method", * + * "module", "param", "property", or "type" */ + bool IsLocalAttrTarget () { + int cur = la.kind; + string val = la.val; + + return (cur == Tokens.Event || cur == Tokens.Return || + Tokens.IdentifierTokens[cur]) && + Peek(1).kind == Tokens.Colon; + } + + bool IsShiftRight() + { + Token next = Peek(1); + // TODO : Add col test (seems not to work, lexer bug...) : && la.col == next.col - 1 + return (la.kind == Tokens.GreaterThan && next.kind == Tokens.GreaterThan); + } + + bool IsGenericExpression(Expression expr) + { + if (expr is IdentifierExpression) + return ((IdentifierExpression)expr).TypeArguments.Count > 0; + else if (expr is MemberReferenceExpression) + return ((MemberReferenceExpression)expr).TypeArguments.Count > 0; + else + return false; + } + + bool ShouldConvertTargetExpressionToTypeReference(Expression targetExpr) + { + if (targetExpr is IdentifierExpression) + return ((IdentifierExpression)targetExpr).TypeArguments.Count > 0; + else if (targetExpr is MemberReferenceExpression) + return ((MemberReferenceExpression)targetExpr).TypeArguments.Count > 0; + else + return false; + } + + TypeReference GetTypeReferenceFromExpression(Expression expr) + { + if (expr is TypeReferenceExpression) + return (expr as TypeReferenceExpression).TypeReference; + + IdentifierExpression ident = expr as IdentifierExpression; + if (ident != null) { + return new TypeReference(ident.Identifier, ident.TypeArguments); + } + + MemberReferenceExpression member = expr as MemberReferenceExpression; + if (member != null) { + TypeReference targetType = GetTypeReferenceFromExpression(member.TargetObject); + if (targetType != null) { + if (targetType.GenericTypes.Count == 0 && targetType.IsArrayType == false) { + TypeReference tr = targetType.Clone(); + tr.Type = tr.Type + "." + member.MemberName; + tr.GenericTypes.AddRange(member.TypeArguments); + return tr; + } else { + return new InnerClassTypeReference(targetType, member.MemberName, member.TypeArguments); + } + } + } + return null; + } + + bool IsMostNegativeIntegerWithoutTypeSuffix() + { + Token token = la; + if (token.kind == Tokens.Literal) { + return token.val == "2147483648" || token.val == "9223372036854775808"; + } else { + return false; + } + } + + bool LastExpressionIsUnaryMinus(System.Collections.ArrayList expressions) + { + if (expressions.Count == 0) return false; + UnaryOperatorExpression uoe = expressions[expressions.Count - 1] as UnaryOperatorExpression; + if (uoe != null) { + return uoe.Op == UnaryOperatorType.Minus; + } else { + return false; + } + } + + bool StartOfQueryExpression() + { + if (la.kind == Tokens.From) { + Token p = Peek(1); + if (IsIdentifierToken(p) || Tokens.TypeKW[p.kind]) + return true; + } + return false; + } + + static bool IsIdentifierToken(Token tk) + { + return Tokens.IdentifierTokens[tk.kind]; + } + + /// + /// Adds a child item to a collection stored in the parent node. + /// Also set's the item's parent to . + /// Does nothing if item is null. + /// + static void SafeAdd(INode parent, List list, T item) where T : class, INode + { + Debug.Assert(parent != null); + Debug.Assert((parent is INullable) ? !(parent as INullable).IsNull : true); + if (item != null) { + list.Add(item); + item.Parent = parent; + } + } + + internal static string GetReflectionNameForOperator(OverloadableOperatorType op) + { + switch (op) { + case OverloadableOperatorType.Add: + return "op_Addition"; + case OverloadableOperatorType.BitNot: + return "op_OnesComplement"; + case OverloadableOperatorType.BitwiseAnd: + return "op_BitwiseAnd"; + case OverloadableOperatorType.BitwiseOr: + return "op_BitwiseOr"; + case OverloadableOperatorType.Concat: + case OverloadableOperatorType.CType: + return "op_unknown"; + case OverloadableOperatorType.Decrement: + return "op_Decrement"; + case OverloadableOperatorType.Divide: + return "op_Division"; + case OverloadableOperatorType.DivideInteger: + return "op_unknown"; + case OverloadableOperatorType.Equality: + return "op_Equality"; + case OverloadableOperatorType.ExclusiveOr: + return "op_ExclusiveOr"; + case OverloadableOperatorType.GreaterThan: + return "op_GreaterThan"; + case OverloadableOperatorType.GreaterThanOrEqual: + return "op_GreaterThanOrEqual"; + case OverloadableOperatorType.Increment: + return "op_Increment"; + case OverloadableOperatorType.InEquality: + return "op_Inequality"; + case OverloadableOperatorType.IsFalse: + return "op_False"; + case OverloadableOperatorType.IsTrue: + return "op_True"; + case OverloadableOperatorType.LessThan: + return "op_LessThan"; + case OverloadableOperatorType.LessThanOrEqual: + return "op_LessThanOrEqual"; + case OverloadableOperatorType.Like: + return "op_unknown"; + case OverloadableOperatorType.Modulus: + return "op_Modulus"; + case OverloadableOperatorType.Multiply: + return "op_Multiply"; + case OverloadableOperatorType.Not: + return "op_LogicalNot"; + case OverloadableOperatorType.Power: + return "op_unknown"; + case OverloadableOperatorType.ShiftLeft: + return "op_LeftShift"; + case OverloadableOperatorType.ShiftRight: + return "op_RightShift"; + case OverloadableOperatorType.Subtract: + return "op_Subtraction"; + case OverloadableOperatorType.UnaryMinus: + return "op_UnaryNegation"; + case OverloadableOperatorType.UnaryPlus: + return "op_UnaryPlus"; + default: + return "op_unknown"; + } + } + } +} diff --git a/Project/Src/Parser/CSharp/Parser.cs b/Project/Src/Parser/CSharp/Parser.cs new file mode 100644 index 0000000000..89562922a8 --- /dev/null +++ b/Project/Src/Parser/CSharp/Parser.cs @@ -0,0 +1,6225 @@ + +#line 1 "cs.ATG" +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Text; +using ICSharpCode.NRefactory.Parser; +using ICSharpCode.NRefactory.Ast; +using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute; +using Types = ICSharpCode.NRefactory.Ast.ClassType; +/* + Parser.frame file for NRefactory. + */ +using System; +using System.Reflection; + +namespace ICSharpCode.NRefactory.Parser.CSharp { + + + +partial class Parser : AbstractParser +{ + const int maxT = 145; + + const bool T = true; + const bool x = false; + + +#line 18 "cs.ATG" + + +/* + +*/ + + void CS() { + +#line 180 "cs.ATG" + lexer.NextToken(); // get the first token + compilationUnit = new CompilationUnit(); + BlockStart(compilationUnit); + + while (la.kind == 71) { + ExternAliasDirective(); + } + while (la.kind == 121) { + UsingDirective(); + } + while ( +#line 187 "cs.ATG" +IsGlobalAttrTarget()) { + GlobalAttributeSection(); + } + while (StartOf(1)) { + NamespaceMemberDecl(); + } + Expect(0); + } + + void ExternAliasDirective() { + +#line 360 "cs.ATG" + ExternAliasDirective ead = new ExternAliasDirective { StartLocation = la.Location }; + Expect(71); + Identifier(); + +#line 363 "cs.ATG" + if (t.val != "alias") Error("Expected 'extern alias'."); + Identifier(); + +#line 364 "cs.ATG" + ead.Name = t.val; + Expect(11); + +#line 365 "cs.ATG" + ead.EndLocation = t.EndLocation; + +#line 366 "cs.ATG" + AddChild(ead); + } + + void UsingDirective() { + +#line 194 "cs.ATG" + string qualident = null; TypeReference aliasedType = null; + string alias = null; + + Expect(121); + +#line 198 "cs.ATG" + Location startPos = t.Location; + if ( +#line 199 "cs.ATG" +IdentAndDoubleColon()) { + Identifier(); + +#line 199 "cs.ATG" + alias = t.val; + Expect(10); + } + Qualident( +#line 200 "cs.ATG" +out qualident); + if (la.kind == 3) { + lexer.NextToken(); + NonArrayType( +#line 201 "cs.ATG" +out aliasedType); + } + Expect(11); + +#line 203 "cs.ATG" + if (qualident != null && qualident.Length > 0) { + string name = (alias != null && alias != "global") ? alias + "." + qualident : qualident; + INode node; + if (aliasedType != null) { + node = new UsingDeclaration(name, aliasedType); + } else { + node = new UsingDeclaration(name); + } + node.StartLocation = startPos; + node.EndLocation = t.EndLocation; + AddChild(node); + } + + } + + void GlobalAttributeSection() { + Expect(18); + +#line 220 "cs.ATG" + Location startPos = t.Location; + Identifier(); + +#line 221 "cs.ATG" + if (t.val != "assembly" && t.val != "module") Error("global attribute target specifier (assembly or module) expected"); + string attributeTarget = t.val; + List attributes = new List(); + ASTAttribute attribute; + + Expect(9); + Attribute( +#line 226 "cs.ATG" +out attribute); + +#line 226 "cs.ATG" + attributes.Add(attribute); + while ( +#line 227 "cs.ATG" +NotFinalComma()) { + Expect(14); + Attribute( +#line 227 "cs.ATG" +out attribute); + +#line 227 "cs.ATG" + attributes.Add(attribute); + } + if (la.kind == 14) { + lexer.NextToken(); + } + Expect(19); + +#line 229 "cs.ATG" + AttributeSection section = new AttributeSection { + AttributeTarget = attributeTarget, + Attributes = attributes, + StartLocation = startPos, + EndLocation = t.EndLocation + }; + AddChild(section); + + } + + void NamespaceMemberDecl() { + +#line 333 "cs.ATG" + AttributeSection section; + List attributes = new List(); + ModifierList m = new ModifierList(); + string qualident; + + if (la.kind == 88) { + lexer.NextToken(); + +#line 339 "cs.ATG" + Location startPos = t.Location; + Qualident( +#line 340 "cs.ATG" +out qualident); + +#line 340 "cs.ATG" + INode node = new NamespaceDeclaration(qualident); + node.StartLocation = startPos; + AddChild(node); + BlockStart(node); + + Expect(16); + while (la.kind == 71) { + ExternAliasDirective(); + } + while (la.kind == 121) { + UsingDirective(); + } + while (StartOf(1)) { + NamespaceMemberDecl(); + } + Expect(17); + if (la.kind == 11) { + lexer.NextToken(); + } + +#line 350 "cs.ATG" + node.EndLocation = t.EndLocation; + BlockEnd(); + + } else if (StartOf(2)) { + while (la.kind == 18) { + AttributeSection( +#line 354 "cs.ATG" +out section); + +#line 354 "cs.ATG" + attributes.Add(section); + } + while (StartOf(3)) { + TypeModifier( +#line 355 "cs.ATG" +m); + } + TypeDecl( +#line 356 "cs.ATG" +m, attributes); + } else SynErr(146); + } + + void Identifier() { + switch (la.kind) { + case 1: { + lexer.NextToken(); + break; + } + case 126: { + lexer.NextToken(); + break; + } + case 127: { + lexer.NextToken(); + break; + } + case 128: { + lexer.NextToken(); + break; + } + case 129: { + lexer.NextToken(); + break; + } + case 130: { + lexer.NextToken(); + break; + } + case 131: { + lexer.NextToken(); + break; + } + case 132: { + lexer.NextToken(); + break; + } + case 133: { + lexer.NextToken(); + break; + } + case 134: { + lexer.NextToken(); + break; + } + case 135: { + lexer.NextToken(); + break; + } + case 136: { + lexer.NextToken(); + break; + } + case 137: { + lexer.NextToken(); + break; + } + case 138: { + lexer.NextToken(); + break; + } + case 139: { + lexer.NextToken(); + break; + } + case 140: { + lexer.NextToken(); + break; + } + case 141: { + lexer.NextToken(); + break; + } + case 142: { + lexer.NextToken(); + break; + } + case 143: { + lexer.NextToken(); + break; + } + case 144: { + lexer.NextToken(); + break; + } + default: SynErr(147); break; + } + } + + void Qualident( +#line 490 "cs.ATG" +out string qualident) { + Identifier(); + +#line 492 "cs.ATG" + qualidentBuilder.Length = 0; qualidentBuilder.Append(t.val); + while ( +#line 493 "cs.ATG" +DotAndIdent()) { + Expect(15); + Identifier(); + +#line 493 "cs.ATG" + qualidentBuilder.Append('.'); + qualidentBuilder.Append(t.val); + + } + +#line 496 "cs.ATG" + qualident = qualidentBuilder.ToString(); + } + + void NonArrayType( +#line 608 "cs.ATG" +out TypeReference type) { + +#line 610 "cs.ATG" + Location startPos = la.Location; + string name; + int pointer = 0; + type = null; + + if (StartOf(4)) { + ClassType( +#line 616 "cs.ATG" +out type, false); + } else if (StartOf(5)) { + SimpleType( +#line 617 "cs.ATG" +out name); + +#line 617 "cs.ATG" + type = new TypeReference(name, true); + } else if (la.kind == 123) { + lexer.NextToken(); + Expect(6); + +#line 618 "cs.ATG" + pointer = 1; type = new TypeReference("System.Void", true); + } else SynErr(148); + if (la.kind == 12) { + NullableQuestionMark( +#line 621 "cs.ATG" +ref type); + } + while ( +#line 623 "cs.ATG" +IsPointer()) { + Expect(6); + +#line 624 "cs.ATG" + ++pointer; + } + +#line 626 "cs.ATG" + if (type != null) { + type.PointerNestingLevel = pointer; + type.EndLocation = t.EndLocation; + type.StartLocation = startPos; + } + + } + + void Attribute( +#line 239 "cs.ATG" +out ASTAttribute attribute) { + +#line 240 "cs.ATG" + string qualident; + string alias = null; + + +#line 244 "cs.ATG" + Location startPos = la.Location; + if ( +#line 245 "cs.ATG" +IdentAndDoubleColon()) { + Identifier(); + +#line 246 "cs.ATG" + alias = t.val; + Expect(10); + } + Qualident( +#line 249 "cs.ATG" +out qualident); + +#line 250 "cs.ATG" + List positional = new List(); + List named = new List(); + string name = (alias != null && alias != "global") ? alias + "." + qualident : qualident; + + if (la.kind == 20) { + AttributeArguments( +#line 254 "cs.ATG" +positional, named); + } + +#line 255 "cs.ATG" + attribute = new ASTAttribute(name, positional, named); + attribute.StartLocation = startPos; + attribute.EndLocation = t.EndLocation; + + } + + void AttributeArguments( +#line 261 "cs.ATG" +List positional, List named) { + Expect(20); + if (StartOf(6)) { + AttributeArgument( +#line 265 "cs.ATG" +positional, named); + while (la.kind == 14) { + lexer.NextToken(); + AttributeArgument( +#line 268 "cs.ATG" +positional, named); + } + } + Expect(21); + } + + void AttributeArgument( +#line 274 "cs.ATG" +List positional, List named) { + +#line 275 "cs.ATG" + string name = null; bool isNamed = false; Expression expr; Location startLocation = la.Location; + if ( +#line 278 "cs.ATG" +IsAssignment()) { + +#line 278 "cs.ATG" + isNamed = true; + Identifier(); + +#line 279 "cs.ATG" + name = t.val; + Expect(3); + } else if ( +#line 282 "cs.ATG" +IdentAndColon()) { + Identifier(); + +#line 283 "cs.ATG" + name = t.val; + Expect(9); + } else if (StartOf(6)) { + } else SynErr(149); + Expr( +#line 287 "cs.ATG" +out expr); + +#line 289 "cs.ATG" + if (expr != null) { + if (isNamed) { + named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }); + } else { + if (named.Count > 0) + Error("positional argument after named argument is not allowed"); + if (name != null) + expr = new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + positional.Add(expr); + } + } + + } + + void Expr( +#line 1805 "cs.ATG" +out Expression expr) { + +#line 1806 "cs.ATG" + expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; + +#line 1808 "cs.ATG" + Location startLocation = la.Location; + UnaryExpr( +#line 1809 "cs.ATG" +out expr); + if (StartOf(7)) { + AssignmentOperator( +#line 1812 "cs.ATG" +out op); + Expr( +#line 1812 "cs.ATG" +out expr1); + +#line 1812 "cs.ATG" + expr = new AssignmentExpression(expr, op, expr1); + } else if ( +#line 1813 "cs.ATG" +la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { + AssignmentOperator( +#line 1814 "cs.ATG" +out op); + Expr( +#line 1814 "cs.ATG" +out expr1); + +#line 1814 "cs.ATG" + expr = new AssignmentExpression(expr, op, expr1); + } else if (StartOf(8)) { + ConditionalOrExpr( +#line 1816 "cs.ATG" +ref expr); + if (la.kind == 13) { + lexer.NextToken(); + Expr( +#line 1817 "cs.ATG" +out expr1); + +#line 1817 "cs.ATG" + expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); + } + if (la.kind == 12) { + lexer.NextToken(); + Expr( +#line 1818 "cs.ATG" +out expr1); + Expect(9); + Expr( +#line 1818 "cs.ATG" +out expr2); + +#line 1818 "cs.ATG" + expr = new ConditionalExpression(expr, expr1, expr2); + } + } else SynErr(150); + +#line 1821 "cs.ATG" + if (expr != null) { + if (expr.StartLocation.IsEmpty) + expr.StartLocation = startLocation; + if (expr.EndLocation.IsEmpty) + expr.EndLocation = t.EndLocation; + } + + } + + void AttributeSection( +#line 303 "cs.ATG" +out AttributeSection section) { + +#line 305 "cs.ATG" + string attributeTarget = ""; + List attributes = new List(); + ASTAttribute attribute; + + + Expect(18); + +#line 311 "cs.ATG" + Location startPos = t.Location; + if ( +#line 312 "cs.ATG" +IsLocalAttrTarget()) { + if (la.kind == 69) { + lexer.NextToken(); + +#line 313 "cs.ATG" + attributeTarget = "event"; + } else if (la.kind == 101) { + lexer.NextToken(); + +#line 314 "cs.ATG" + attributeTarget = "return"; + } else { + Identifier(); + +#line 315 "cs.ATG" + attributeTarget = t.val; + } + Expect(9); + } + Attribute( +#line 319 "cs.ATG" +out attribute); + +#line 319 "cs.ATG" + attributes.Add(attribute); + while ( +#line 320 "cs.ATG" +NotFinalComma()) { + Expect(14); + Attribute( +#line 320 "cs.ATG" +out attribute); + +#line 320 "cs.ATG" + attributes.Add(attribute); + } + if (la.kind == 14) { + lexer.NextToken(); + } + Expect(19); + +#line 322 "cs.ATG" + section = new AttributeSection { + AttributeTarget = attributeTarget, + Attributes = attributes, + StartLocation = startPos, + EndLocation = t.EndLocation + }; + + } + + void TypeModifier( +#line 693 "cs.ATG" +ModifierList m) { + switch (la.kind) { + case 89: { + lexer.NextToken(); + +#line 695 "cs.ATG" + m.Add(Modifiers.New, t.Location); + break; + } + case 98: { + lexer.NextToken(); + +#line 696 "cs.ATG" + m.Add(Modifiers.Public, t.Location); + break; + } + case 97: { + lexer.NextToken(); + +#line 697 "cs.ATG" + m.Add(Modifiers.Protected, t.Location); + break; + } + case 84: { + lexer.NextToken(); + +#line 698 "cs.ATG" + m.Add(Modifiers.Internal, t.Location); + break; + } + case 96: { + lexer.NextToken(); + +#line 699 "cs.ATG" + m.Add(Modifiers.Private, t.Location); + break; + } + case 119: { + lexer.NextToken(); + +#line 700 "cs.ATG" + m.Add(Modifiers.Unsafe, t.Location); + break; + } + case 49: { + lexer.NextToken(); + +#line 701 "cs.ATG" + m.Add(Modifiers.Abstract, t.Location); + break; + } + case 103: { + lexer.NextToken(); + +#line 702 "cs.ATG" + m.Add(Modifiers.Sealed, t.Location); + break; + } + case 107: { + lexer.NextToken(); + +#line 703 "cs.ATG" + m.Add(Modifiers.Static, t.Location); + break; + } + case 126: { + lexer.NextToken(); + +#line 704 "cs.ATG" + m.Add(Modifiers.Partial, t.Location); + break; + } + default: SynErr(151); break; + } + } + + void TypeDecl( +#line 369 "cs.ATG" +ModifierList m, List attributes) { + +#line 371 "cs.ATG" + TypeReference type; + List names; + List p = new List(); + string name; + List templates; + + if (la.kind == 59) { + +#line 377 "cs.ATG" + m.Check(Modifiers.Classes); + lexer.NextToken(); + +#line 378 "cs.ATG" + TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + templates = newType.Templates; + AddChild(newType); + BlockStart(newType); + newType.StartLocation = m.GetDeclarationLocation(t.Location); + + newType.Type = Types.Class; + + Identifier(); + +#line 386 "cs.ATG" + newType.Name = t.val; + if (la.kind == 23) { + TypeParameterList( +#line 389 "cs.ATG" +templates); + } + if (la.kind == 9) { + ClassBase( +#line 391 "cs.ATG" +out names); + +#line 391 "cs.ATG" + newType.BaseTypes = names; + } + while (la.kind == 127) { + TypeParameterConstraintsClause( +#line 394 "cs.ATG" +templates); + } + +#line 396 "cs.ATG" + newType.BodyStartLocation = t.EndLocation; + Expect(16); + ClassBody(); + Expect(17); + if (la.kind == 11) { + lexer.NextToken(); + } + +#line 400 "cs.ATG" + newType.EndLocation = t.EndLocation; + BlockEnd(); + + } else if (StartOf(9)) { + +#line 403 "cs.ATG" + m.Check(Modifiers.StructsInterfacesEnumsDelegates); + if (la.kind == 109) { + lexer.NextToken(); + +#line 404 "cs.ATG" + TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + templates = newType.Templates; + newType.StartLocation = m.GetDeclarationLocation(t.Location); + AddChild(newType); + BlockStart(newType); + newType.Type = Types.Struct; + + Identifier(); + +#line 411 "cs.ATG" + newType.Name = t.val; + if (la.kind == 23) { + TypeParameterList( +#line 414 "cs.ATG" +templates); + } + if (la.kind == 9) { + StructInterfaces( +#line 416 "cs.ATG" +out names); + +#line 416 "cs.ATG" + newType.BaseTypes = names; + } + while (la.kind == 127) { + TypeParameterConstraintsClause( +#line 419 "cs.ATG" +templates); + } + +#line 422 "cs.ATG" + newType.BodyStartLocation = t.EndLocation; + StructBody(); + if (la.kind == 11) { + lexer.NextToken(); + } + +#line 424 "cs.ATG" + newType.EndLocation = t.EndLocation; + BlockEnd(); + + } else if (la.kind == 83) { + lexer.NextToken(); + +#line 428 "cs.ATG" + TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + templates = newType.Templates; + AddChild(newType); + BlockStart(newType); + newType.StartLocation = m.GetDeclarationLocation(t.Location); + newType.Type = Types.Interface; + + Identifier(); + +#line 435 "cs.ATG" + newType.Name = t.val; + if (la.kind == 23) { + TypeParameterList( +#line 438 "cs.ATG" +templates); + } + if (la.kind == 9) { + InterfaceBase( +#line 440 "cs.ATG" +out names); + +#line 440 "cs.ATG" + newType.BaseTypes = names; + } + while (la.kind == 127) { + TypeParameterConstraintsClause( +#line 443 "cs.ATG" +templates); + } + +#line 445 "cs.ATG" + newType.BodyStartLocation = t.EndLocation; + InterfaceBody(); + if (la.kind == 11) { + lexer.NextToken(); + } + +#line 447 "cs.ATG" + newType.EndLocation = t.EndLocation; + BlockEnd(); + + } else if (la.kind == 68) { + lexer.NextToken(); + +#line 451 "cs.ATG" + TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + AddChild(newType); + BlockStart(newType); + newType.StartLocation = m.GetDeclarationLocation(t.Location); + newType.Type = Types.Enum; + + Identifier(); + +#line 457 "cs.ATG" + newType.Name = t.val; + if (la.kind == 9) { + lexer.NextToken(); + IntegralType( +#line 458 "cs.ATG" +out name); + +#line 458 "cs.ATG" + newType.BaseTypes.Add(new TypeReference(name, true)); + } + +#line 460 "cs.ATG" + newType.BodyStartLocation = t.EndLocation; + EnumBody(); + if (la.kind == 11) { + lexer.NextToken(); + } + +#line 462 "cs.ATG" + newType.EndLocation = t.EndLocation; + BlockEnd(); + + } else { + lexer.NextToken(); + +#line 466 "cs.ATG" + DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes); + templates = delegateDeclr.Templates; + delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location); + + if ( +#line 470 "cs.ATG" +NotVoidPointer()) { + Expect(123); + +#line 470 "cs.ATG" + delegateDeclr.ReturnType = new TypeReference("System.Void", true); + } else if (StartOf(10)) { + Type( +#line 471 "cs.ATG" +out type); + +#line 471 "cs.ATG" + delegateDeclr.ReturnType = type; + } else SynErr(152); + Identifier(); + +#line 473 "cs.ATG" + delegateDeclr.Name = t.val; + if (la.kind == 23) { + TypeParameterList( +#line 476 "cs.ATG" +templates); + } + Expect(20); + if (StartOf(11)) { + FormalParameterList( +#line 478 "cs.ATG" +p); + +#line 478 "cs.ATG" + delegateDeclr.Parameters = p; + } + Expect(21); + while (la.kind == 127) { + TypeParameterConstraintsClause( +#line 482 "cs.ATG" +templates); + } + Expect(11); + +#line 484 "cs.ATG" + delegateDeclr.EndLocation = t.EndLocation; + AddChild(delegateDeclr); + + } + } else SynErr(153); + } + + void TypeParameterList( +#line 2377 "cs.ATG" +List templates) { + +#line 2379 "cs.ATG" + TemplateDefinition template; + + Expect(23); + VariantTypeParameter( +#line 2383 "cs.ATG" +out template); + +#line 2383 "cs.ATG" + templates.Add(template); + while (la.kind == 14) { + lexer.NextToken(); + VariantTypeParameter( +#line 2385 "cs.ATG" +out template); + +#line 2385 "cs.ATG" + templates.Add(template); + } + Expect(22); + } + + void ClassBase( +#line 499 "cs.ATG" +out List names) { + +#line 501 "cs.ATG" + TypeReference typeRef; + names = new List(); + + Expect(9); + ClassType( +#line 505 "cs.ATG" +out typeRef, false); + +#line 505 "cs.ATG" + if (typeRef != null) { names.Add(typeRef); } + while (la.kind == 14) { + lexer.NextToken(); + TypeName( +#line 506 "cs.ATG" +out typeRef, false); + +#line 506 "cs.ATG" + if (typeRef != null) { names.Add(typeRef); } + } + } + + void TypeParameterConstraintsClause( +#line 2405 "cs.ATG" +List templates) { + +#line 2406 "cs.ATG" + string name = ""; TypeReference type; + Expect(127); + Identifier(); + +#line 2409 "cs.ATG" + name = t.val; + Expect(9); + TypeParameterConstraintsClauseBase( +#line 2411 "cs.ATG" +out type); + +#line 2412 "cs.ATG" + TemplateDefinition td = null; + foreach (TemplateDefinition d in templates) { + if (d.Name == name) { + td = d; + break; + } + } + if ( td != null && type != null) { td.Bases.Add(type); } + + while (la.kind == 14) { + lexer.NextToken(); + TypeParameterConstraintsClauseBase( +#line 2421 "cs.ATG" +out type); + +#line 2422 "cs.ATG" + td = null; + foreach (TemplateDefinition d in templates) { + if (d.Name == name) { + td = d; + break; + } + } + if ( td != null && type != null) { td.Bases.Add(type); } + + } + } + + void ClassBody() { + +#line 510 "cs.ATG" + AttributeSection section; + while (StartOf(12)) { + +#line 512 "cs.ATG" + List attributes = new List(); + ModifierList m = new ModifierList(); + + while (!(StartOf(13))) {SynErr(154); lexer.NextToken(); } + while (la.kind == 18) { + AttributeSection( +#line 516 "cs.ATG" +out section); + +#line 516 "cs.ATG" + attributes.Add(section); + } + MemberModifiers( +#line 517 "cs.ATG" +m); + ClassMemberDecl( +#line 518 "cs.ATG" +m, attributes); + } + } + + void StructInterfaces( +#line 522 "cs.ATG" +out List names) { + +#line 524 "cs.ATG" + TypeReference typeRef; + names = new List(); + + Expect(9); + TypeName( +#line 528 "cs.ATG" +out typeRef, false); + +#line 528 "cs.ATG" + if (typeRef != null) { names.Add(typeRef); } + while (la.kind == 14) { + lexer.NextToken(); + TypeName( +#line 529 "cs.ATG" +out typeRef, false); + +#line 529 "cs.ATG" + if (typeRef != null) { names.Add(typeRef); } + } + } + + void StructBody() { + +#line 533 "cs.ATG" + AttributeSection section; + Expect(16); + while (StartOf(14)) { + +#line 536 "cs.ATG" + List attributes = new List(); + ModifierList m = new ModifierList(); + + while (la.kind == 18) { + AttributeSection( +#line 539 "cs.ATG" +out section); + +#line 539 "cs.ATG" + attributes.Add(section); + } + MemberModifiers( +#line 540 "cs.ATG" +m); + StructMemberDecl( +#line 541 "cs.ATG" +m, attributes); + } + Expect(17); + } + + void InterfaceBase( +#line 546 "cs.ATG" +out List names) { + +#line 548 "cs.ATG" + TypeReference typeRef; + names = new List(); + + Expect(9); + TypeName( +#line 552 "cs.ATG" +out typeRef, false); + +#line 552 "cs.ATG" + if (typeRef != null) { names.Add(typeRef); } + while (la.kind == 14) { + lexer.NextToken(); + TypeName( +#line 553 "cs.ATG" +out typeRef, false); + +#line 553 "cs.ATG" + if (typeRef != null) { names.Add(typeRef); } + } + } + + void InterfaceBody() { + Expect(16); + while (StartOf(15)) { + while (!(StartOf(16))) {SynErr(155); lexer.NextToken(); } + InterfaceMemberDecl(); + } + Expect(17); + } + + void IntegralType( +#line 715 "cs.ATG" +out string name) { + +#line 715 "cs.ATG" + name = ""; + switch (la.kind) { + case 102: { + lexer.NextToken(); + +#line 717 "cs.ATG" + name = "System.SByte"; + break; + } + case 54: { + lexer.NextToken(); + +#line 718 "cs.ATG" + name = "System.Byte"; + break; + } + case 104: { + lexer.NextToken(); + +#line 719 "cs.ATG" + name = "System.Int16"; + break; + } + case 120: { + lexer.NextToken(); + +#line 720 "cs.ATG" + name = "System.UInt16"; + break; + } + case 82: { + lexer.NextToken(); + +#line 721 "cs.ATG" + name = "System.Int32"; + break; + } + case 116: { + lexer.NextToken(); + +#line 722 "cs.ATG" + name = "System.UInt32"; + break; + } + case 87: { + lexer.NextToken(); + +#line 723 "cs.ATG" + name = "System.Int64"; + break; + } + case 117: { + lexer.NextToken(); + +#line 724 "cs.ATG" + name = "System.UInt64"; + break; + } + case 57: { + lexer.NextToken(); + +#line 725 "cs.ATG" + name = "System.Char"; + break; + } + default: SynErr(156); break; + } + } + + void EnumBody() { + +#line 562 "cs.ATG" + FieldDeclaration f; + Expect(16); + if (StartOf(17)) { + EnumMemberDecl( +#line 565 "cs.ATG" +out f); + +#line 565 "cs.ATG" + AddChild(f); + while ( +#line 566 "cs.ATG" +NotFinalComma()) { + Expect(14); + EnumMemberDecl( +#line 567 "cs.ATG" +out f); + +#line 567 "cs.ATG" + AddChild(f); + } + if (la.kind == 14) { + lexer.NextToken(); + } + } + Expect(17); + } + + void Type( +#line 573 "cs.ATG" +out TypeReference type) { + TypeWithRestriction( +#line 575 "cs.ATG" +out type, true, false); + } + + void FormalParameterList( +#line 645 "cs.ATG" +List parameter) { + +#line 648 "cs.ATG" + ParameterDeclarationExpression p; + AttributeSection section; + List attributes = new List(); + + while (la.kind == 18) { + AttributeSection( +#line 653 "cs.ATG" +out section); + +#line 653 "cs.ATG" + attributes.Add(section); + } + FixedParameter( +#line 654 "cs.ATG" +out p); + +#line 654 "cs.ATG" + p.Attributes = attributes; + parameter.Add(p); + + while (la.kind == 14) { + lexer.NextToken(); + +#line 658 "cs.ATG" + attributes = new List(); + while (la.kind == 18) { + AttributeSection( +#line 659 "cs.ATG" +out section); + +#line 659 "cs.ATG" + attributes.Add(section); + } + FixedParameter( +#line 660 "cs.ATG" +out p); + +#line 660 "cs.ATG" + p.Attributes = attributes; parameter.Add(p); + } + } + + void ClassType( +#line 707 "cs.ATG" +out TypeReference typeRef, bool canBeUnbound) { + +#line 708 "cs.ATG" + TypeReference r; typeRef = null; + if (StartOf(18)) { + TypeName( +#line 710 "cs.ATG" +out r, canBeUnbound); + +#line 710 "cs.ATG" + typeRef = r; + } else if (la.kind == 91) { + lexer.NextToken(); + +#line 711 "cs.ATG" + typeRef = new TypeReference("System.Object", true); typeRef.StartLocation = t.Location; typeRef.EndLocation = t.EndLocation; + } else if (la.kind == 108) { + lexer.NextToken(); + +#line 712 "cs.ATG" + typeRef = new TypeReference("System.String", true); typeRef.StartLocation = t.Location; typeRef.EndLocation = t.EndLocation; + } else SynErr(157); + } + + void TypeName( +#line 2318 "cs.ATG" +out TypeReference typeRef, bool canBeUnbound) { + +#line 2319 "cs.ATG" + List typeArguments = null; + string alias = null; + string qualident; + Location startLocation = la.Location; + + if ( +#line 2325 "cs.ATG" +IdentAndDoubleColon()) { + Identifier(); + +#line 2326 "cs.ATG" + alias = t.val; + Expect(10); + } + Qualident( +#line 2329 "cs.ATG" +out qualident); + if (la.kind == 23) { + TypeArgumentList( +#line 2330 "cs.ATG" +out typeArguments, canBeUnbound); + } + +#line 2332 "cs.ATG" + if (alias == null) { + typeRef = new TypeReference(qualident, typeArguments); + } else if (alias == "global") { + typeRef = new TypeReference(qualident, typeArguments); + typeRef.IsGlobal = true; + } else { + typeRef = new TypeReference(alias + "." + qualident, typeArguments); + } + + while ( +#line 2341 "cs.ATG" +DotAndIdent()) { + Expect(15); + +#line 2342 "cs.ATG" + typeArguments = null; + Qualident( +#line 2343 "cs.ATG" +out qualident); + if (la.kind == 23) { + TypeArgumentList( +#line 2344 "cs.ATG" +out typeArguments, canBeUnbound); + } + +#line 2345 "cs.ATG" + typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); + } + +#line 2347 "cs.ATG" + typeRef.StartLocation = startLocation; typeRef.EndLocation = t.EndLocation; + } + + void MemberModifiers( +#line 728 "cs.ATG" +ModifierList m) { + while (StartOf(19)) { + switch (la.kind) { + case 49: { + lexer.NextToken(); + +#line 731 "cs.ATG" + m.Add(Modifiers.Abstract, t.Location); + break; + } + case 71: { + lexer.NextToken(); + +#line 732 "cs.ATG" + m.Add(Modifiers.Extern, t.Location); + break; + } + case 84: { + lexer.NextToken(); + +#line 733 "cs.ATG" + m.Add(Modifiers.Internal, t.Location); + break; + } + case 89: { + lexer.NextToken(); + +#line 734 "cs.ATG" + m.Add(Modifiers.New, t.Location); + break; + } + case 94: { + lexer.NextToken(); + +#line 735 "cs.ATG" + m.Add(Modifiers.Override, t.Location); + break; + } + case 96: { + lexer.NextToken(); + +#line 736 "cs.ATG" + m.Add(Modifiers.Private, t.Location); + break; + } + case 97: { + lexer.NextToken(); + +#line 737 "cs.ATG" + m.Add(Modifiers.Protected, t.Location); + break; + } + case 98: { + lexer.NextToken(); + +#line 738 "cs.ATG" + m.Add(Modifiers.Public, t.Location); + break; + } + case 99: { + lexer.NextToken(); + +#line 739 "cs.ATG" + m.Add(Modifiers.ReadOnly, t.Location); + break; + } + case 103: { + lexer.NextToken(); + +#line 740 "cs.ATG" + m.Add(Modifiers.Sealed, t.Location); + break; + } + case 107: { + lexer.NextToken(); + +#line 741 "cs.ATG" + m.Add(Modifiers.Static, t.Location); + break; + } + case 74: { + lexer.NextToken(); + +#line 742 "cs.ATG" + m.Add(Modifiers.Fixed, t.Location); + break; + } + case 119: { + lexer.NextToken(); + +#line 743 "cs.ATG" + m.Add(Modifiers.Unsafe, t.Location); + break; + } + case 122: { + lexer.NextToken(); + +#line 744 "cs.ATG" + m.Add(Modifiers.Virtual, t.Location); + break; + } + case 124: { + lexer.NextToken(); + +#line 745 "cs.ATG" + m.Add(Modifiers.Volatile, t.Location); + break; + } + case 126: { + lexer.NextToken(); + +#line 746 "cs.ATG" + m.Add(Modifiers.Partial, t.Location); + break; + } + } + } + } + + void ClassMemberDecl( +#line 1081 "cs.ATG" +ModifierList m, List attributes) { + +#line 1082 "cs.ATG" + BlockStatement stmt = null; + if (StartOf(20)) { + StructMemberDecl( +#line 1084 "cs.ATG" +m, attributes); + } else if (la.kind == 27) { + +#line 1085 "cs.ATG" + m.Check(Modifiers.Destructors); Location startPos = la.Location; + lexer.NextToken(); + Identifier(); + +#line 1086 "cs.ATG" + DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); + d.Modifier = m.Modifier; + d.StartLocation = m.GetDeclarationLocation(startPos); + + Expect(20); + Expect(21); + +#line 1090 "cs.ATG" + d.EndLocation = t.EndLocation; + if (la.kind == 16) { + Block( +#line 1090 "cs.ATG" +out stmt); + } else if (la.kind == 11) { + lexer.NextToken(); + } else SynErr(158); + +#line 1091 "cs.ATG" + d.Body = stmt; + AddChild(d); + + } else SynErr(159); + } + + void StructMemberDecl( +#line 750 "cs.ATG" +ModifierList m, List attributes) { + +#line 752 "cs.ATG" + string qualident = null; + TypeReference type; + Expression expr; + List p = new List(); + BlockStatement stmt = null; + List templates = new List(); + TypeReference explicitInterface = null; + bool isExtensionMethod = false; + + if (la.kind == 60) { + +#line 762 "cs.ATG" + m.Check(Modifiers.Constants); + lexer.NextToken(); + +#line 763 "cs.ATG" + Location startPos = t.Location; + Type( +#line 764 "cs.ATG" +out type); + Identifier(); + +#line 764 "cs.ATG" + FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifiers.Const); + fd.StartLocation = m.GetDeclarationLocation(startPos); + VariableDeclaration f = new VariableDeclaration(t.val); + f.StartLocation = t.Location; + f.TypeReference = type; + SafeAdd(fd, fd.Fields, f); + + Expect(3); + Expr( +#line 771 "cs.ATG" +out expr); + +#line 771 "cs.ATG" + f.Initializer = expr; + while (la.kind == 14) { + lexer.NextToken(); + Identifier(); + +#line 772 "cs.ATG" + f = new VariableDeclaration(t.val); + f.StartLocation = t.Location; + f.TypeReference = type; + SafeAdd(fd, fd.Fields, f); + + Expect(3); + Expr( +#line 777 "cs.ATG" +out expr); + +#line 777 "cs.ATG" + f.EndLocation = t.EndLocation; f.Initializer = expr; + } + Expect(11); + +#line 778 "cs.ATG" + fd.EndLocation = t.EndLocation; AddChild(fd); + } else if ( +#line 782 "cs.ATG" +NotVoidPointer()) { + +#line 782 "cs.ATG" + m.Check(Modifiers.PropertysEventsMethods); + Expect(123); + +#line 783 "cs.ATG" + Location startPos = t.Location; + if ( +#line 784 "cs.ATG" +IsExplicitInterfaceImplementation()) { + TypeName( +#line 785 "cs.ATG" +out explicitInterface, false); + +#line 786 "cs.ATG" + if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { + qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); + } + } else if (StartOf(18)) { + Identifier(); + +#line 789 "cs.ATG" + qualident = t.val; + } else SynErr(160); + if (la.kind == 23) { + TypeParameterList( +#line 792 "cs.ATG" +templates); + } + Expect(20); + if (la.kind == 111) { + lexer.NextToken(); + +#line 795 "cs.ATG" + isExtensionMethod = true; /* C# 3.0 */ + } + if (StartOf(11)) { + FormalParameterList( +#line 796 "cs.ATG" +p); + } + Expect(21); + +#line 797 "cs.ATG" + MethodDeclaration methodDeclaration = new MethodDeclaration { + Name = qualident, + Modifier = m.Modifier, + TypeReference = new TypeReference("System.Void", true), + Parameters = p, + Attributes = attributes, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = t.EndLocation, + Templates = templates, + IsExtensionMethod = isExtensionMethod + }; + if (explicitInterface != null) + SafeAdd(methodDeclaration, methodDeclaration.InterfaceImplementations, new InterfaceImplementation(explicitInterface, qualident)); + AddChild(methodDeclaration); + BlockStart(methodDeclaration); + + while (la.kind == 127) { + TypeParameterConstraintsClause( +#line 815 "cs.ATG" +templates); + } + if (la.kind == 16) { + Block( +#line 817 "cs.ATG" +out stmt); + } else if (la.kind == 11) { + lexer.NextToken(); + } else SynErr(161); + +#line 817 "cs.ATG" + BlockEnd(); + methodDeclaration.Body = (BlockStatement)stmt; + + } else if (la.kind == 69) { + +#line 821 "cs.ATG" + m.Check(Modifiers.PropertysEventsMethods); + lexer.NextToken(); + +#line 823 "cs.ATG" + EventDeclaration eventDecl = new EventDeclaration { + Modifier = m.Modifier, + Attributes = attributes, + StartLocation = t.Location + }; + AddChild(eventDecl); + BlockStart(eventDecl); + EventAddRegion addBlock = null; + EventRemoveRegion removeBlock = null; + + Type( +#line 833 "cs.ATG" +out type); + +#line 833 "cs.ATG" + eventDecl.TypeReference = type; + if ( +#line 834 "cs.ATG" +IsExplicitInterfaceImplementation()) { + TypeName( +#line 835 "cs.ATG" +out explicitInterface, false); + +#line 836 "cs.ATG" + qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); + +#line 837 "cs.ATG" + eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); + } else if (StartOf(18)) { + Identifier(); + +#line 839 "cs.ATG" + qualident = t.val; + if (la.kind == 3) { + lexer.NextToken(); + Expr( +#line 840 "cs.ATG" +out expr); + +#line 840 "cs.ATG" + eventDecl.Initializer = expr; + } + while (la.kind == 14) { + lexer.NextToken(); + +#line 844 "cs.ATG" + eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; BlockEnd(); + +#line 846 "cs.ATG" + eventDecl = new EventDeclaration { + Modifier = eventDecl.Modifier, + Attributes = eventDecl.Attributes, + StartLocation = eventDecl.StartLocation, + TypeReference = eventDecl.TypeReference.Clone() + }; + AddChild(eventDecl); + BlockStart(eventDecl); + + Identifier(); + +#line 855 "cs.ATG" + qualident = t.val; + if (la.kind == 3) { + lexer.NextToken(); + Expr( +#line 856 "cs.ATG" +out expr); + +#line 856 "cs.ATG" + eventDecl.Initializer = expr; + } + } + } else SynErr(162); + +#line 859 "cs.ATG" + eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; + if (la.kind == 16) { + lexer.NextToken(); + +#line 860 "cs.ATG" + eventDecl.BodyStart = t.Location; + EventAccessorDecls( +#line 861 "cs.ATG" +out addBlock, out removeBlock); + Expect(17); + +#line 862 "cs.ATG" + eventDecl.BodyEnd = t.EndLocation; + } + if (la.kind == 11) { + lexer.NextToken(); + } + +#line 865 "cs.ATG" + BlockEnd(); + eventDecl.AddRegion = addBlock; + eventDecl.RemoveRegion = removeBlock; + + } else if ( +#line 871 "cs.ATG" +IdentAndLPar()) { + +#line 871 "cs.ATG" + m.Check(Modifiers.Constructors | Modifiers.StaticConstructors); + Identifier(); + +#line 872 "cs.ATG" + string name = t.val; Location startPos = t.Location; + Expect(20); + if (StartOf(11)) { + +#line 872 "cs.ATG" + m.Check(Modifiers.Constructors); + FormalParameterList( +#line 873 "cs.ATG" +p); + } + Expect(21); + +#line 875 "cs.ATG" + ConstructorInitializer init = null; + if (la.kind == 9) { + +#line 876 "cs.ATG" + m.Check(Modifiers.Constructors); + ConstructorInitializer( +#line 877 "cs.ATG" +out init); + } + +#line 879 "cs.ATG" + ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); + cd.StartLocation = startPos; + cd.EndLocation = t.EndLocation; + + if (la.kind == 16) { + Block( +#line 884 "cs.ATG" +out stmt); + } else if (la.kind == 11) { + lexer.NextToken(); + } else SynErr(163); + +#line 884 "cs.ATG" + cd.Body = (BlockStatement)stmt; AddChild(cd); + } else if (la.kind == 70 || la.kind == 80) { + +#line 887 "cs.ATG" + m.Check(Modifiers.Operators); + if (m.isNone) Error("at least one modifier must be set"); + bool isImplicit = true; + Location startPos = Location.Empty; + + if (la.kind == 80) { + lexer.NextToken(); + +#line 892 "cs.ATG" + startPos = t.Location; + } else { + lexer.NextToken(); + +#line 892 "cs.ATG" + isImplicit = false; startPos = t.Location; + } + Expect(92); + Type( +#line 893 "cs.ATG" +out type); + +#line 893 "cs.ATG" + TypeReference operatorType = type; + Expect(20); + Type( +#line 894 "cs.ATG" +out type); + Identifier(); + +#line 894 "cs.ATG" + string varName = t.val; + Expect(21); + +#line 895 "cs.ATG" + Location endPos = t.Location; + if (la.kind == 16) { + Block( +#line 896 "cs.ATG" +out stmt); + } else if (la.kind == 11) { + lexer.NextToken(); + +#line 896 "cs.ATG" + stmt = null; + } else SynErr(164); + +#line 899 "cs.ATG" + List parameters = new List(); + parameters.Add(new ParameterDeclarationExpression(type, varName)); + OperatorDeclaration operatorDeclaration = new OperatorDeclaration { + Name = (isImplicit ? "op_Implicit" : "op_Explicit"), + Modifier = m.Modifier, + Attributes = attributes, + Parameters = parameters, + TypeReference = operatorType, + ConversionType = isImplicit ? ConversionType.Implicit : ConversionType.Explicit, + Body = (BlockStatement)stmt, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = endPos + }; + AddChild(operatorDeclaration); + + } else if (StartOf(21)) { + TypeDecl( +#line 917 "cs.ATG" +m, attributes); + } else if (StartOf(10)) { + Type( +#line 919 "cs.ATG" +out type); + +#line 919 "cs.ATG" + Location startPos = t.Location; + if (la.kind == 92) { + +#line 921 "cs.ATG" + OverloadableOperatorType op; + m.Check(Modifiers.Operators); + if (m.isNone) Error("at least one modifier must be set"); + + lexer.NextToken(); + OverloadableOperator( +#line 925 "cs.ATG" +out op); + +#line 925 "cs.ATG" + TypeReference firstType, secondType = null; string secondName = null; + Expect(20); + +#line 926 "cs.ATG" + Location firstStart = la.Location, secondStart = Location.Empty, secondEnd = Location.Empty; + Type( +#line 926 "cs.ATG" +out firstType); + Identifier(); + +#line 926 "cs.ATG" + string firstName = t.val; Location firstEnd = t.EndLocation; + if (la.kind == 14) { + lexer.NextToken(); + +#line 927 "cs.ATG" + secondStart = la.Location; + Type( +#line 927 "cs.ATG" +out secondType); + Identifier(); + +#line 927 "cs.ATG" + secondName = t.val; secondEnd = t.EndLocation; + } else if (la.kind == 21) { + } else SynErr(165); + +#line 935 "cs.ATG" + Location endPos = t.Location; + Expect(21); + if (la.kind == 16) { + Block( +#line 936 "cs.ATG" +out stmt); + } else if (la.kind == 11) { + lexer.NextToken(); + } else SynErr(166); + +#line 938 "cs.ATG" + if (op == OverloadableOperatorType.Add && secondType == null) + op = OverloadableOperatorType.UnaryPlus; + if (op == OverloadableOperatorType.Subtract && secondType == null) + op = OverloadableOperatorType.UnaryMinus; + OperatorDeclaration operatorDeclaration = new OperatorDeclaration { + Modifier = m.Modifier, + Attributes = attributes, + TypeReference = type, + OverloadableOperator = op, + Name = GetReflectionNameForOperator(op), + Body = (BlockStatement)stmt, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = endPos + }; + SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(firstType, firstName) { StartLocation = firstStart, EndLocation = firstEnd }); + if (secondType != null) { + SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(secondType, secondName) { StartLocation = secondStart, EndLocation = secondEnd }); + } + AddChild(operatorDeclaration); + + } else if ( +#line 960 "cs.ATG" +IsVarDecl()) { + +#line 961 "cs.ATG" + m.Check(Modifiers.Fields); + FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); + fd.StartLocation = m.GetDeclarationLocation(startPos); + + if ( +#line 965 "cs.ATG" +m.Contains(Modifiers.Fixed)) { + VariableDeclarator( +#line 966 "cs.ATG" +fd); + Expect(18); + Expr( +#line 968 "cs.ATG" +out expr); + +#line 968 "cs.ATG" + if (fd.Fields.Count > 0) + fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; + Expect(19); + while (la.kind == 14) { + lexer.NextToken(); + VariableDeclarator( +#line 972 "cs.ATG" +fd); + Expect(18); + Expr( +#line 974 "cs.ATG" +out expr); + +#line 974 "cs.ATG" + if (fd.Fields.Count > 0) + fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; + Expect(19); + } + } else if (StartOf(18)) { + VariableDeclarator( +#line 979 "cs.ATG" +fd); + while (la.kind == 14) { + lexer.NextToken(); + VariableDeclarator( +#line 980 "cs.ATG" +fd); + } + } else SynErr(167); + Expect(11); + +#line 982 "cs.ATG" + fd.EndLocation = t.EndLocation; AddChild(fd); + } else if (la.kind == 111) { + +#line 985 "cs.ATG" + m.Check(Modifiers.Indexers); + lexer.NextToken(); + Expect(18); + FormalParameterList( +#line 986 "cs.ATG" +p); + Expect(19); + +#line 986 "cs.ATG" + Location endLocation = t.EndLocation; + Expect(16); + +#line 987 "cs.ATG" + PropertyDeclaration indexer = new PropertyDeclaration(m.Modifier | Modifiers.Default, attributes, "Item", p); + indexer.StartLocation = startPos; + indexer.EndLocation = endLocation; + indexer.BodyStart = t.Location; + indexer.TypeReference = type; + PropertyGetRegion getRegion; + PropertySetRegion setRegion; + + AccessorDecls( +#line 995 "cs.ATG" +out getRegion, out setRegion); + Expect(17); + +#line 996 "cs.ATG" + indexer.BodyEnd = t.EndLocation; + indexer.GetRegion = getRegion; + indexer.SetRegion = setRegion; + AddChild(indexer); + + } else if ( +#line 1001 "cs.ATG" +IsIdentifierToken(la)) { + if ( +#line 1002 "cs.ATG" +IsExplicitInterfaceImplementation()) { + TypeName( +#line 1003 "cs.ATG" +out explicitInterface, false); + +#line 1004 "cs.ATG" + if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { + qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); + } + } else if (StartOf(18)) { + Identifier(); + +#line 1007 "cs.ATG" + qualident = t.val; + } else SynErr(168); + +#line 1009 "cs.ATG" + Location qualIdentEndLocation = t.EndLocation; + if (la.kind == 16 || la.kind == 20 || la.kind == 23) { + if (la.kind == 20 || la.kind == 23) { + +#line 1013 "cs.ATG" + m.Check(Modifiers.PropertysEventsMethods); + if (la.kind == 23) { + TypeParameterList( +#line 1015 "cs.ATG" +templates); + } + Expect(20); + if (la.kind == 111) { + lexer.NextToken(); + +#line 1017 "cs.ATG" + isExtensionMethod = true; + } + if (StartOf(11)) { + FormalParameterList( +#line 1018 "cs.ATG" +p); + } + Expect(21); + +#line 1020 "cs.ATG" + MethodDeclaration methodDeclaration = new MethodDeclaration { + Name = qualident, + Modifier = m.Modifier, + TypeReference = type, + Parameters = p, + Attributes = attributes + }; + if (explicitInterface != null) + methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); + methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); + methodDeclaration.EndLocation = t.EndLocation; + methodDeclaration.IsExtensionMethod = isExtensionMethod; + methodDeclaration.Templates = templates; + AddChild(methodDeclaration); + + while (la.kind == 127) { + TypeParameterConstraintsClause( +#line 1035 "cs.ATG" +templates); + } + if (la.kind == 16) { + Block( +#line 1036 "cs.ATG" +out stmt); + } else if (la.kind == 11) { + lexer.NextToken(); + } else SynErr(169); + +#line 1036 "cs.ATG" + methodDeclaration.Body = (BlockStatement)stmt; + } else { + lexer.NextToken(); + +#line 1039 "cs.ATG" + PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); + if (explicitInterface != null) + pDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); + pDecl.StartLocation = m.GetDeclarationLocation(startPos); + pDecl.EndLocation = qualIdentEndLocation; + pDecl.BodyStart = t.Location; + PropertyGetRegion getRegion; + PropertySetRegion setRegion; + + AccessorDecls( +#line 1048 "cs.ATG" +out getRegion, out setRegion); + Expect(17); + +#line 1050 "cs.ATG" + pDecl.GetRegion = getRegion; + pDecl.SetRegion = setRegion; + pDecl.BodyEnd = t.EndLocation; + AddChild(pDecl); + + } + } else if (la.kind == 15) { + +#line 1058 "cs.ATG" + m.Check(Modifiers.Indexers); + lexer.NextToken(); + Expect(111); + Expect(18); + FormalParameterList( +#line 1059 "cs.ATG" +p); + Expect(19); + +#line 1060 "cs.ATG" + PropertyDeclaration indexer = new PropertyDeclaration(m.Modifier | Modifiers.Default, attributes, "Item", p); + indexer.StartLocation = m.GetDeclarationLocation(startPos); + indexer.EndLocation = t.EndLocation; + indexer.TypeReference = type; + if (explicitInterface != null) + SafeAdd(indexer, indexer.InterfaceImplementations, new InterfaceImplementation(explicitInterface, "this")); + PropertyGetRegion getRegion; + PropertySetRegion setRegion; + + Expect(16); + +#line 1069 "cs.ATG" + Location bodyStart = t.Location; + AccessorDecls( +#line 1070 "cs.ATG" +out getRegion, out setRegion); + Expect(17); + +#line 1071 "cs.ATG" + indexer.BodyStart = bodyStart; + indexer.BodyEnd = t.EndLocation; + indexer.GetRegion = getRegion; + indexer.SetRegion = setRegion; + AddChild(indexer); + + } else SynErr(170); + } else SynErr(171); + } else SynErr(172); + } + + void InterfaceMemberDecl() { + +#line 1098 "cs.ATG" + TypeReference type; + + AttributeSection section; + Modifiers mod = Modifiers.None; + List attributes = new List(); + List parameters = new List(); + string name; + PropertyGetRegion getBlock; + PropertySetRegion setBlock; + Location startLocation = new Location(-1, -1); + List templates = new List(); + + while (la.kind == 18) { + AttributeSection( +#line 1111 "cs.ATG" +out section); + +#line 1111 "cs.ATG" + attributes.Add(section); + } + if (la.kind == 89) { + lexer.NextToken(); + +#line 1112 "cs.ATG" + mod = Modifiers.New; startLocation = t.Location; + } + if ( +#line 1115 "cs.ATG" +NotVoidPointer()) { + Expect(123); + +#line 1115 "cs.ATG" + if (startLocation.IsEmpty) startLocation = t.Location; + Identifier(); + +#line 1116 "cs.ATG" + name = t.val; + if (la.kind == 23) { + TypeParameterList( +#line 1117 "cs.ATG" +templates); + } + Expect(20); + if (StartOf(11)) { + FormalParameterList( +#line 1118 "cs.ATG" +parameters); + } + Expect(21); + while (la.kind == 127) { + TypeParameterConstraintsClause( +#line 1119 "cs.ATG" +templates); + } + Expect(11); + +#line 1121 "cs.ATG" + MethodDeclaration md = new MethodDeclaration { + Name = name, Modifier = mod, TypeReference = new TypeReference("System.Void", true), + Parameters = parameters, Attributes = attributes, Templates = templates, + StartLocation = startLocation, EndLocation = t.EndLocation + }; + AddChild(md); + + } else if (StartOf(22)) { + if (StartOf(10)) { + Type( +#line 1129 "cs.ATG" +out type); + +#line 1129 "cs.ATG" + if (startLocation.IsEmpty) startLocation = t.Location; + if (StartOf(18)) { + Identifier(); + +#line 1131 "cs.ATG" + name = t.val; Location qualIdentEndLocation = t.EndLocation; + if (la.kind == 20 || la.kind == 23) { + if (la.kind == 23) { + TypeParameterList( +#line 1135 "cs.ATG" +templates); + } + Expect(20); + if (StartOf(11)) { + FormalParameterList( +#line 1136 "cs.ATG" +parameters); + } + Expect(21); + while (la.kind == 127) { + TypeParameterConstraintsClause( +#line 1138 "cs.ATG" +templates); + } + Expect(11); + +#line 1139 "cs.ATG" + MethodDeclaration md = new MethodDeclaration { + Name = name, Modifier = mod, TypeReference = type, + Parameters = parameters, Attributes = attributes, Templates = templates, + StartLocation = startLocation, EndLocation = t.EndLocation + }; + AddChild(md); + + } else if (la.kind == 16) { + +#line 1148 "cs.ATG" + PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); + AddChild(pd); + lexer.NextToken(); + +#line 1151 "cs.ATG" + Location bodyStart = t.Location; + InterfaceAccessors( +#line 1152 "cs.ATG" +out getBlock, out setBlock); + Expect(17); + +#line 1153 "cs.ATG" + pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; + } else SynErr(173); + } else if (la.kind == 111) { + lexer.NextToken(); + Expect(18); + FormalParameterList( +#line 1156 "cs.ATG" +parameters); + Expect(19); + +#line 1157 "cs.ATG" + Location bracketEndLocation = t.EndLocation; + +#line 1158 "cs.ATG" + PropertyDeclaration id = new PropertyDeclaration(mod | Modifiers.Default, attributes, "Item", parameters); + id.TypeReference = type; + AddChild(id); + Expect(16); + +#line 1161 "cs.ATG" + Location bodyStart = t.Location; + InterfaceAccessors( +#line 1162 "cs.ATG" +out getBlock, out setBlock); + Expect(17); + +#line 1164 "cs.ATG" + id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; + } else SynErr(174); + } else { + lexer.NextToken(); + +#line 1167 "cs.ATG" + if (startLocation.IsEmpty) startLocation = t.Location; + Type( +#line 1168 "cs.ATG" +out type); + Identifier(); + +#line 1169 "cs.ATG" + EventDeclaration ed = new EventDeclaration { + TypeReference = type, Name = t.val, Modifier = mod, Attributes = attributes + }; + AddChild(ed); + + Expect(11); + +#line 1175 "cs.ATG" + ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; + } + } else SynErr(175); + } + + void EnumMemberDecl( +#line 1180 "cs.ATG" +out FieldDeclaration f) { + +#line 1182 "cs.ATG" + Expression expr = null; + List attributes = new List(); + AttributeSection section = null; + VariableDeclaration varDecl = null; + + while (la.kind == 18) { + AttributeSection( +#line 1188 "cs.ATG" +out section); + +#line 1188 "cs.ATG" + attributes.Add(section); + } + Identifier(); + +#line 1189 "cs.ATG" + f = new FieldDeclaration(attributes); + varDecl = new VariableDeclaration(t.val); + f.Fields.Add(varDecl); + f.StartLocation = t.Location; + f.EndLocation = t.EndLocation; + + if (la.kind == 3) { + lexer.NextToken(); + Expr( +#line 1195 "cs.ATG" +out expr); + +#line 1195 "cs.ATG" + varDecl.Initializer = expr; + } + } + + void TypeWithRestriction( +#line 578 "cs.ATG" +out TypeReference type, bool allowNullable, bool canBeUnbound) { + +#line 580 "cs.ATG" + Location startPos = la.Location; + string name; + int pointer = 0; + type = null; + + if (StartOf(4)) { + ClassType( +#line 586 "cs.ATG" +out type, canBeUnbound); + } else if (StartOf(5)) { + SimpleType( +#line 587 "cs.ATG" +out name); + +#line 587 "cs.ATG" + type = new TypeReference(name, true); type.StartLocation = startPos; type.EndLocation = t.EndLocation; + } else if (la.kind == 123) { + lexer.NextToken(); + Expect(6); + +#line 588 "cs.ATG" + pointer = 1; type = new TypeReference("System.Void", true); type.StartLocation = startPos; type.EndLocation = t.EndLocation; + } else SynErr(176); + +#line 589 "cs.ATG" + List r = new List(); + if ( +#line 591 "cs.ATG" +allowNullable && la.kind == Tokens.Question) { + NullableQuestionMark( +#line 591 "cs.ATG" +ref type); + } + while ( +#line 593 "cs.ATG" +IsPointerOrDims()) { + +#line 593 "cs.ATG" + int i = 0; + if (la.kind == 6) { + lexer.NextToken(); + +#line 594 "cs.ATG" + ++pointer; + } else if (la.kind == 18) { + lexer.NextToken(); + while (la.kind == 14) { + lexer.NextToken(); + +#line 595 "cs.ATG" + ++i; + } + Expect(19); + +#line 595 "cs.ATG" + r.Add(i); + } else SynErr(177); + } + +#line 598 "cs.ATG" + if (type != null) { + type.RankSpecifier = r.ToArray(); + type.PointerNestingLevel = pointer; + type.EndLocation = t.EndLocation; + type.StartLocation = startPos; + } + + } + + void SimpleType( +#line 634 "cs.ATG" +out string name) { + +#line 635 "cs.ATG" + name = String.Empty; + if (StartOf(23)) { + IntegralType( +#line 637 "cs.ATG" +out name); + } else if (la.kind == 75) { + lexer.NextToken(); + +#line 638 "cs.ATG" + name = "System.Single"; + } else if (la.kind == 66) { + lexer.NextToken(); + +#line 639 "cs.ATG" + name = "System.Double"; + } else if (la.kind == 62) { + lexer.NextToken(); + +#line 640 "cs.ATG" + name = "System.Decimal"; + } else if (la.kind == 52) { + lexer.NextToken(); + +#line 641 "cs.ATG" + name = "System.Boolean"; + } else SynErr(178); + } + + void NullableQuestionMark( +#line 2351 "cs.ATG" +ref TypeReference typeRef) { + +#line 2352 "cs.ATG" + List typeArguments = new List(1); + Expect(12); + +#line 2356 "cs.ATG" + if (typeRef != null) typeArguments.Add(typeRef); + typeRef = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; + + } + + void FixedParameter( +#line 664 "cs.ATG" +out ParameterDeclarationExpression p) { + +#line 666 "cs.ATG" + TypeReference type; + ParameterModifiers mod = ParameterModifiers.In; + Location start = la.Location; + Expression expr; + + if (la.kind == 93 || la.kind == 95 || la.kind == 100) { + if (la.kind == 100) { + lexer.NextToken(); + +#line 673 "cs.ATG" + mod = ParameterModifiers.Ref; + } else if (la.kind == 93) { + lexer.NextToken(); + +#line 674 "cs.ATG" + mod = ParameterModifiers.Out; + } else { + lexer.NextToken(); + +#line 675 "cs.ATG" + mod = ParameterModifiers.Params; + } + } + Type( +#line 677 "cs.ATG" +out type); + Identifier(); + +#line 678 "cs.ATG" + p = new ParameterDeclarationExpression(type, t.val, mod); + if (la.kind == 3) { + lexer.NextToken(); + Expr( +#line 679 "cs.ATG" +out expr); + +#line 679 "cs.ATG" + p.DefaultValue = expr; p.ParamModifier |= ParameterModifiers.Optional; + } + +#line 680 "cs.ATG" + p.StartLocation = start; p.EndLocation = t.EndLocation; + } + + void AccessorModifiers( +#line 683 "cs.ATG" +out ModifierList m) { + +#line 684 "cs.ATG" + m = new ModifierList(); + if (la.kind == 96) { + lexer.NextToken(); + +#line 686 "cs.ATG" + m.Add(Modifiers.Private, t.Location); + } else if (la.kind == 97) { + lexer.NextToken(); + +#line 687 "cs.ATG" + m.Add(Modifiers.Protected, t.Location); + if (la.kind == 84) { + lexer.NextToken(); + +#line 688 "cs.ATG" + m.Add(Modifiers.Internal, t.Location); + } + } else if (la.kind == 84) { + lexer.NextToken(); + +#line 689 "cs.ATG" + m.Add(Modifiers.Internal, t.Location); + if (la.kind == 97) { + lexer.NextToken(); + +#line 690 "cs.ATG" + m.Add(Modifiers.Protected, t.Location); + } + } else SynErr(179); + } + + void Block( +#line 1315 "cs.ATG" +out BlockStatement stmt) { + Expect(16); + +#line 1317 "cs.ATG" + BlockStatement blockStmt = new BlockStatement(); + blockStmt.StartLocation = t.Location; + BlockStart(blockStmt); + if (!ParseMethodBodies) lexer.SkipCurrentBlock(0); + + while (StartOf(24)) { + Statement(); + } + while (!(la.kind == 0 || la.kind == 17)) {SynErr(180); lexer.NextToken(); } + Expect(17); + +#line 1325 "cs.ATG" + stmt = blockStmt; + blockStmt.EndLocation = t.EndLocation; + BlockEnd(); + + } + + void EventAccessorDecls( +#line 1252 "cs.ATG" +out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { + +#line 1253 "cs.ATG" + AttributeSection section; + List attributes = new List(); + BlockStatement stmt; + addBlock = null; + removeBlock = null; + + while (la.kind == 18) { + AttributeSection( +#line 1260 "cs.ATG" +out section); + +#line 1260 "cs.ATG" + attributes.Add(section); + } + if (la.kind == 130) { + +#line 1262 "cs.ATG" + addBlock = new EventAddRegion(attributes); + AddAccessorDecl( +#line 1263 "cs.ATG" +out stmt); + +#line 1263 "cs.ATG" + attributes = new List(); addBlock.Block = stmt; + while (la.kind == 18) { + AttributeSection( +#line 1264 "cs.ATG" +out section); + +#line 1264 "cs.ATG" + attributes.Add(section); + } + RemoveAccessorDecl( +#line 1265 "cs.ATG" +out stmt); + +#line 1265 "cs.ATG" + removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = stmt; + } else if (la.kind == 131) { + RemoveAccessorDecl( +#line 1267 "cs.ATG" +out stmt); + +#line 1267 "cs.ATG" + removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = stmt; attributes = new List(); + while (la.kind == 18) { + AttributeSection( +#line 1268 "cs.ATG" +out section); + +#line 1268 "cs.ATG" + attributes.Add(section); + } + AddAccessorDecl( +#line 1269 "cs.ATG" +out stmt); + +#line 1269 "cs.ATG" + addBlock = new EventAddRegion(attributes); addBlock.Block = stmt; + } else SynErr(181); + } + + void ConstructorInitializer( +#line 1345 "cs.ATG" +out ConstructorInitializer ci) { + +#line 1346 "cs.ATG" + Expression expr; ci = new ConstructorInitializer(); + Expect(9); + if (la.kind == 51) { + lexer.NextToken(); + +#line 1350 "cs.ATG" + ci.ConstructorInitializerType = ConstructorInitializerType.Base; + } else if (la.kind == 111) { + lexer.NextToken(); + +#line 1351 "cs.ATG" + ci.ConstructorInitializerType = ConstructorInitializerType.This; + } else SynErr(182); + Expect(20); + if (StartOf(25)) { + Argument( +#line 1354 "cs.ATG" +out expr); + +#line 1354 "cs.ATG" + SafeAdd(ci, ci.Arguments, expr); + while (la.kind == 14) { + lexer.NextToken(); + Argument( +#line 1355 "cs.ATG" +out expr); + +#line 1355 "cs.ATG" + SafeAdd(ci, ci.Arguments, expr); + } + } + Expect(21); + } + + void OverloadableOperator( +#line 1368 "cs.ATG" +out OverloadableOperatorType op) { + +#line 1369 "cs.ATG" + op = OverloadableOperatorType.None; + switch (la.kind) { + case 4: { + lexer.NextToken(); + +#line 1371 "cs.ATG" + op = OverloadableOperatorType.Add; + break; + } + case 5: { + lexer.NextToken(); + +#line 1372 "cs.ATG" + op = OverloadableOperatorType.Subtract; + break; + } + case 24: { + lexer.NextToken(); + +#line 1374 "cs.ATG" + op = OverloadableOperatorType.Not; + break; + } + case 27: { + lexer.NextToken(); + +#line 1375 "cs.ATG" + op = OverloadableOperatorType.BitNot; + break; + } + case 31: { + lexer.NextToken(); + +#line 1377 "cs.ATG" + op = OverloadableOperatorType.Increment; + break; + } + case 32: { + lexer.NextToken(); + +#line 1378 "cs.ATG" + op = OverloadableOperatorType.Decrement; + break; + } + case 113: { + lexer.NextToken(); + +#line 1380 "cs.ATG" + op = OverloadableOperatorType.IsTrue; + break; + } + case 72: { + lexer.NextToken(); + +#line 1381 "cs.ATG" + op = OverloadableOperatorType.IsFalse; + break; + } + case 6: { + lexer.NextToken(); + +#line 1383 "cs.ATG" + op = OverloadableOperatorType.Multiply; + break; + } + case 7: { + lexer.NextToken(); + +#line 1384 "cs.ATG" + op = OverloadableOperatorType.Divide; + break; + } + case 8: { + lexer.NextToken(); + +#line 1385 "cs.ATG" + op = OverloadableOperatorType.Modulus; + break; + } + case 28: { + lexer.NextToken(); + +#line 1387 "cs.ATG" + op = OverloadableOperatorType.BitwiseAnd; + break; + } + case 29: { + lexer.NextToken(); + +#line 1388 "cs.ATG" + op = OverloadableOperatorType.BitwiseOr; + break; + } + case 30: { + lexer.NextToken(); + +#line 1389 "cs.ATG" + op = OverloadableOperatorType.ExclusiveOr; + break; + } + case 37: { + lexer.NextToken(); + +#line 1391 "cs.ATG" + op = OverloadableOperatorType.ShiftLeft; + break; + } + case 33: { + lexer.NextToken(); + +#line 1392 "cs.ATG" + op = OverloadableOperatorType.Equality; + break; + } + case 34: { + lexer.NextToken(); + +#line 1393 "cs.ATG" + op = OverloadableOperatorType.InEquality; + break; + } + case 23: { + lexer.NextToken(); + +#line 1394 "cs.ATG" + op = OverloadableOperatorType.LessThan; + break; + } + case 35: { + lexer.NextToken(); + +#line 1395 "cs.ATG" + op = OverloadableOperatorType.GreaterThanOrEqual; + break; + } + case 36: { + lexer.NextToken(); + +#line 1396 "cs.ATG" + op = OverloadableOperatorType.LessThanOrEqual; + break; + } + case 22: { + lexer.NextToken(); + +#line 1397 "cs.ATG" + op = OverloadableOperatorType.GreaterThan; + if (la.kind == 22) { + lexer.NextToken(); + +#line 1397 "cs.ATG" + op = OverloadableOperatorType.ShiftRight; + } + break; + } + default: SynErr(183); break; + } + } + + void VariableDeclarator( +#line 1307 "cs.ATG" +FieldDeclaration parentFieldDeclaration) { + +#line 1308 "cs.ATG" + Expression expr = null; + Identifier(); + +#line 1310 "cs.ATG" + VariableDeclaration f = new VariableDeclaration(t.val); f.StartLocation = t.Location; + if (la.kind == 3) { + lexer.NextToken(); + VariableInitializer( +#line 1311 "cs.ATG" +out expr); + +#line 1311 "cs.ATG" + f.Initializer = expr; + } + +#line 1312 "cs.ATG" + f.EndLocation = t.EndLocation; SafeAdd(parentFieldDeclaration, parentFieldDeclaration.Fields, f); + } + + void AccessorDecls( +#line 1199 "cs.ATG" +out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { + +#line 1201 "cs.ATG" + List attributes = new List(); + AttributeSection section; + getBlock = null; + setBlock = null; + ModifierList modifiers = null; + + while (la.kind == 18) { + AttributeSection( +#line 1208 "cs.ATG" +out section); + +#line 1208 "cs.ATG" + attributes.Add(section); + } + if (la.kind == 84 || la.kind == 96 || la.kind == 97) { + AccessorModifiers( +#line 1209 "cs.ATG" +out modifiers); + } + if (la.kind == 128) { + GetAccessorDecl( +#line 1211 "cs.ATG" +out getBlock, attributes); + +#line 1212 "cs.ATG" + if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } + if (StartOf(26)) { + +#line 1213 "cs.ATG" + attributes = new List(); modifiers = null; + while (la.kind == 18) { + AttributeSection( +#line 1214 "cs.ATG" +out section); + +#line 1214 "cs.ATG" + attributes.Add(section); + } + if (la.kind == 84 || la.kind == 96 || la.kind == 97) { + AccessorModifiers( +#line 1215 "cs.ATG" +out modifiers); + } + SetAccessorDecl( +#line 1216 "cs.ATG" +out setBlock, attributes); + +#line 1217 "cs.ATG" + if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } + } + } else if (la.kind == 129) { + SetAccessorDecl( +#line 1220 "cs.ATG" +out setBlock, attributes); + +#line 1221 "cs.ATG" + if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } + if (StartOf(27)) { + +#line 1222 "cs.ATG" + attributes = new List(); modifiers = null; + while (la.kind == 18) { + AttributeSection( +#line 1223 "cs.ATG" +out section); + +#line 1223 "cs.ATG" + attributes.Add(section); + } + if (la.kind == 84 || la.kind == 96 || la.kind == 97) { + AccessorModifiers( +#line 1224 "cs.ATG" +out modifiers); + } + GetAccessorDecl( +#line 1225 "cs.ATG" +out getBlock, attributes); + +#line 1226 "cs.ATG" + if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } + } + } else if (StartOf(18)) { + Identifier(); + +#line 1228 "cs.ATG" + Error("get or set accessor declaration expected"); + } else SynErr(184); + } + + void InterfaceAccessors( +#line 1273 "cs.ATG" +out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { + +#line 1275 "cs.ATG" + AttributeSection section; + List attributes = new List(); + getBlock = null; setBlock = null; + PropertyGetSetRegion lastBlock = null; + + while (la.kind == 18) { + AttributeSection( +#line 1281 "cs.ATG" +out section); + +#line 1281 "cs.ATG" + attributes.Add(section); + } + +#line 1282 "cs.ATG" + Location startLocation = la.Location; + if (la.kind == 128) { + lexer.NextToken(); + +#line 1284 "cs.ATG" + getBlock = new PropertyGetRegion(null, attributes); + } else if (la.kind == 129) { + lexer.NextToken(); + +#line 1285 "cs.ATG" + setBlock = new PropertySetRegion(null, attributes); + } else SynErr(185); + Expect(11); + +#line 1288 "cs.ATG" + if (getBlock != null) { getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } + if (setBlock != null) { setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } + attributes = new List(); + if (la.kind == 18 || la.kind == 128 || la.kind == 129) { + while (la.kind == 18) { + AttributeSection( +#line 1292 "cs.ATG" +out section); + +#line 1292 "cs.ATG" + attributes.Add(section); + } + +#line 1293 "cs.ATG" + startLocation = la.Location; + if (la.kind == 128) { + lexer.NextToken(); + +#line 1295 "cs.ATG" + if (getBlock != null) Error("get already declared"); + else { getBlock = new PropertyGetRegion(null, attributes); lastBlock = getBlock; } + + } else if (la.kind == 129) { + lexer.NextToken(); + +#line 1298 "cs.ATG" + if (setBlock != null) Error("set already declared"); + else { setBlock = new PropertySetRegion(null, attributes); lastBlock = setBlock; } + + } else SynErr(186); + Expect(11); + +#line 1303 "cs.ATG" + if (lastBlock != null) { lastBlock.StartLocation = startLocation; lastBlock.EndLocation = t.EndLocation; } + } + } + + void GetAccessorDecl( +#line 1232 "cs.ATG" +out PropertyGetRegion getBlock, List attributes) { + +#line 1233 "cs.ATG" + BlockStatement stmt = null; + Expect(128); + +#line 1236 "cs.ATG" + Location startLocation = t.Location; + if (la.kind == 16) { + Block( +#line 1237 "cs.ATG" +out stmt); + } else if (la.kind == 11) { + lexer.NextToken(); + } else SynErr(187); + +#line 1238 "cs.ATG" + getBlock = new PropertyGetRegion(stmt, attributes); + +#line 1239 "cs.ATG" + getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; + } + + void SetAccessorDecl( +#line 1242 "cs.ATG" +out PropertySetRegion setBlock, List attributes) { + +#line 1243 "cs.ATG" + BlockStatement stmt = null; + Expect(129); + +#line 1246 "cs.ATG" + Location startLocation = t.Location; + if (la.kind == 16) { + Block( +#line 1247 "cs.ATG" +out stmt); + } else if (la.kind == 11) { + lexer.NextToken(); + } else SynErr(188); + +#line 1248 "cs.ATG" + setBlock = new PropertySetRegion(stmt, attributes); + +#line 1249 "cs.ATG" + setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; + } + + void AddAccessorDecl( +#line 1331 "cs.ATG" +out BlockStatement stmt) { + +#line 1332 "cs.ATG" + stmt = null; + Expect(130); + Block( +#line 1335 "cs.ATG" +out stmt); + } + + void RemoveAccessorDecl( +#line 1338 "cs.ATG" +out BlockStatement stmt) { + +#line 1339 "cs.ATG" + stmt = null; + Expect(131); + Block( +#line 1342 "cs.ATG" +out stmt); + } + + void VariableInitializer( +#line 1360 "cs.ATG" +out Expression initializerExpression) { + +#line 1361 "cs.ATG" + TypeReference type = null; Expression expr = null; initializerExpression = null; + if (StartOf(6)) { + Expr( +#line 1363 "cs.ATG" +out initializerExpression); + } else if (la.kind == 16) { + CollectionInitializer( +#line 1364 "cs.ATG" +out initializerExpression); + } else if (la.kind == 106) { + lexer.NextToken(); + Type( +#line 1365 "cs.ATG" +out type); + Expect(18); + Expr( +#line 1365 "cs.ATG" +out expr); + Expect(19); + +#line 1365 "cs.ATG" + initializerExpression = new StackAllocExpression(type, expr); + } else SynErr(189); + } + + void Statement() { + +#line 1522 "cs.ATG" + Statement stmt = null; + Location startPos = la.Location; + + while (!(StartOf(28))) {SynErr(190); lexer.NextToken(); } + if ( +#line 1529 "cs.ATG" +IsLabel()) { + Identifier(); + +#line 1529 "cs.ATG" + AddChild(new LabelStatement(t.val)); + Expect(9); + Statement(); + } else if (la.kind == 60) { + lexer.NextToken(); + LocalVariableDecl( +#line 1533 "cs.ATG" +out stmt); + +#line 1534 "cs.ATG" + if (stmt != null) { ((LocalVariableDeclaration)stmt).Modifier |= Modifiers.Const; } + Expect(11); + +#line 1535 "cs.ATG" + AddChild(stmt); + } else if ( +#line 1537 "cs.ATG" +IsLocalVarDecl()) { + LocalVariableDecl( +#line 1537 "cs.ATG" +out stmt); + Expect(11); + +#line 1537 "cs.ATG" + AddChild(stmt); + } else if (StartOf(29)) { + EmbeddedStatement( +#line 1539 "cs.ATG" +out stmt); + +#line 1539 "cs.ATG" + AddChild(stmt); + } else SynErr(191); + +#line 1545 "cs.ATG" + if (stmt != null) { + stmt.StartLocation = startPos; + stmt.EndLocation = t.EndLocation; + } + + } + + void Argument( +#line 1400 "cs.ATG" +out Expression argumentexpr) { + +#line 1401 "cs.ATG" + argumentexpr = null; + if ( +#line 1403 "cs.ATG" +IdentAndColon()) { + +#line 1404 "cs.ATG" + Token ident; Expression expr; + Identifier(); + +#line 1405 "cs.ATG" + ident = t; + Expect(9); + ArgumentValue( +#line 1407 "cs.ATG" +out expr); + +#line 1408 "cs.ATG" + argumentexpr = new NamedArgumentExpression(ident.val, expr) { StartLocation = ident.Location, EndLocation = t.EndLocation }; + } else if (StartOf(25)) { + ArgumentValue( +#line 1410 "cs.ATG" +out argumentexpr); + } else SynErr(192); + } + + void CollectionInitializer( +#line 1444 "cs.ATG" +out Expression outExpr) { + +#line 1446 "cs.ATG" + Expression expr = null; + CollectionInitializerExpression initializer = new CollectionInitializerExpression(); + + Expect(16); + +#line 1450 "cs.ATG" + initializer.StartLocation = t.Location; + if (StartOf(30)) { + VariableInitializer( +#line 1451 "cs.ATG" +out expr); + +#line 1452 "cs.ATG" + SafeAdd(initializer, initializer.CreateExpressions, expr); + while ( +#line 1453 "cs.ATG" +NotFinalComma()) { + Expect(14); + VariableInitializer( +#line 1454 "cs.ATG" +out expr); + +#line 1455 "cs.ATG" + SafeAdd(initializer, initializer.CreateExpressions, expr); + } + if (la.kind == 14) { + lexer.NextToken(); + } + } + Expect(17); + +#line 1459 "cs.ATG" + initializer.EndLocation = t.Location; outExpr = initializer; + } + + void ArgumentValue( +#line 1413 "cs.ATG" +out Expression argumentexpr) { + +#line 1415 "cs.ATG" + Expression expr; + FieldDirection fd = FieldDirection.None; + + if (la.kind == 93 || la.kind == 100) { + if (la.kind == 100) { + lexer.NextToken(); + +#line 1420 "cs.ATG" + fd = FieldDirection.Ref; + } else { + lexer.NextToken(); + +#line 1421 "cs.ATG" + fd = FieldDirection.Out; + } + } + Expr( +#line 1423 "cs.ATG" +out expr); + +#line 1424 "cs.ATG" + argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; + } + + void AssignmentOperator( +#line 1427 "cs.ATG" +out AssignmentOperatorType op) { + +#line 1428 "cs.ATG" + op = AssignmentOperatorType.None; + if (la.kind == 3) { + lexer.NextToken(); + +#line 1430 "cs.ATG" + op = AssignmentOperatorType.Assign; + } else if (la.kind == 38) { + lexer.NextToken(); + +#line 1431 "cs.ATG" + op = AssignmentOperatorType.Add; + } else if (la.kind == 39) { + lexer.NextToken(); + +#line 1432 "cs.ATG" + op = AssignmentOperatorType.Subtract; + } else if (la.kind == 40) { + lexer.NextToken(); + +#line 1433 "cs.ATG" + op = AssignmentOperatorType.Multiply; + } else if (la.kind == 41) { + lexer.NextToken(); + +#line 1434 "cs.ATG" + op = AssignmentOperatorType.Divide; + } else if (la.kind == 42) { + lexer.NextToken(); + +#line 1435 "cs.ATG" + op = AssignmentOperatorType.Modulus; + } else if (la.kind == 43) { + lexer.NextToken(); + +#line 1436 "cs.ATG" + op = AssignmentOperatorType.BitwiseAnd; + } else if (la.kind == 44) { + lexer.NextToken(); + +#line 1437 "cs.ATG" + op = AssignmentOperatorType.BitwiseOr; + } else if (la.kind == 45) { + lexer.NextToken(); + +#line 1438 "cs.ATG" + op = AssignmentOperatorType.ExclusiveOr; + } else if (la.kind == 46) { + lexer.NextToken(); + +#line 1439 "cs.ATG" + op = AssignmentOperatorType.ShiftLeft; + } else if ( +#line 1440 "cs.ATG" +la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { + Expect(22); + Expect(35); + +#line 1441 "cs.ATG" + op = AssignmentOperatorType.ShiftRight; + } else SynErr(193); + } + + void CollectionOrObjectInitializer( +#line 1462 "cs.ATG" +out Expression outExpr) { + +#line 1464 "cs.ATG" + Expression expr = null; + CollectionInitializerExpression initializer = new CollectionInitializerExpression(); + + Expect(16); + +#line 1468 "cs.ATG" + initializer.StartLocation = t.Location; + if (StartOf(30)) { + ObjectPropertyInitializerOrVariableInitializer( +#line 1469 "cs.ATG" +out expr); + +#line 1470 "cs.ATG" + SafeAdd(initializer, initializer.CreateExpressions, expr); + while ( +#line 1471 "cs.ATG" +NotFinalComma()) { + Expect(14); + ObjectPropertyInitializerOrVariableInitializer( +#line 1472 "cs.ATG" +out expr); + +#line 1473 "cs.ATG" + SafeAdd(initializer, initializer.CreateExpressions, expr); + } + if (la.kind == 14) { + lexer.NextToken(); + } + } + Expect(17); + +#line 1477 "cs.ATG" + initializer.EndLocation = t.Location; outExpr = initializer; + } + + void ObjectPropertyInitializerOrVariableInitializer( +#line 1480 "cs.ATG" +out Expression expr) { + +#line 1481 "cs.ATG" + expr = null; + if ( +#line 1483 "cs.ATG" +IdentAndAsgn()) { + Identifier(); + +#line 1485 "cs.ATG" + MemberInitializerExpression mie = new MemberInitializerExpression(t.val, null); + mie.StartLocation = t.Location; + mie.IsKey = true; + Expression r = null; + Expect(3); + if (la.kind == 16) { + CollectionOrObjectInitializer( +#line 1490 "cs.ATG" +out r); + } else if (StartOf(30)) { + VariableInitializer( +#line 1491 "cs.ATG" +out r); + } else SynErr(194); + +#line 1492 "cs.ATG" + mie.Expression = r; mie.EndLocation = t.EndLocation; expr = mie; + } else if (StartOf(30)) { + VariableInitializer( +#line 1494 "cs.ATG" +out expr); + } else SynErr(195); + } + + void LocalVariableDecl( +#line 1498 "cs.ATG" +out Statement stmt) { + +#line 1500 "cs.ATG" + TypeReference type; + VariableDeclaration var = null; + LocalVariableDeclaration localVariableDeclaration; + Location startPos = la.Location; + + Type( +#line 1506 "cs.ATG" +out type); + +#line 1506 "cs.ATG" + localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = startPos; + LocalVariableDeclarator( +#line 1507 "cs.ATG" +out var); + +#line 1507 "cs.ATG" + SafeAdd(localVariableDeclaration, localVariableDeclaration.Variables, var); + while (la.kind == 14) { + lexer.NextToken(); + LocalVariableDeclarator( +#line 1508 "cs.ATG" +out var); + +#line 1508 "cs.ATG" + SafeAdd(localVariableDeclaration, localVariableDeclaration.Variables, var); + } + +#line 1509 "cs.ATG" + stmt = localVariableDeclaration; stmt.EndLocation = t.EndLocation; + } + + void LocalVariableDeclarator( +#line 1512 "cs.ATG" +out VariableDeclaration var) { + +#line 1513 "cs.ATG" + Expression expr = null; + Identifier(); + +#line 1515 "cs.ATG" + var = new VariableDeclaration(t.val); var.StartLocation = t.Location; + if (la.kind == 3) { + lexer.NextToken(); + VariableInitializer( +#line 1516 "cs.ATG" +out expr); + +#line 1516 "cs.ATG" + var.Initializer = expr; + } + +#line 1517 "cs.ATG" + var.EndLocation = t.EndLocation; + } + + void EmbeddedStatement( +#line 1552 "cs.ATG" +out Statement statement) { + +#line 1554 "cs.ATG" + TypeReference type = null; + Expression expr = null; + Statement embeddedStatement = null; + BlockStatement block = null; + statement = null; + + +#line 1561 "cs.ATG" + Location startLocation = la.Location; + if (la.kind == 16) { + Block( +#line 1563 "cs.ATG" +out block); + +#line 1563 "cs.ATG" + statement = block; + } else if (la.kind == 11) { + lexer.NextToken(); + +#line 1566 "cs.ATG" + statement = new EmptyStatement(); + } else if ( +#line 1569 "cs.ATG" +UnCheckedAndLBrace()) { + +#line 1569 "cs.ATG" + bool isChecked = true; + if (la.kind == 58) { + lexer.NextToken(); + } else if (la.kind == 118) { + lexer.NextToken(); + +#line 1570 "cs.ATG" + isChecked = false; + } else SynErr(196); + Block( +#line 1571 "cs.ATG" +out block); + +#line 1571 "cs.ATG" + statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); + } else if (la.kind == 79) { + IfStatement( +#line 1574 "cs.ATG" +out statement); + } else if (la.kind == 110) { + lexer.NextToken(); + +#line 1576 "cs.ATG" + List switchSections = new List(); + Expect(20); + Expr( +#line 1577 "cs.ATG" +out expr); + Expect(21); + Expect(16); + SwitchSections( +#line 1578 "cs.ATG" +switchSections); + Expect(17); + +#line 1580 "cs.ATG" + statement = new SwitchStatement(expr, switchSections); + } else if (la.kind == 125) { + lexer.NextToken(); + Expect(20); + Expr( +#line 1583 "cs.ATG" +out expr); + Expect(21); + EmbeddedStatement( +#line 1584 "cs.ATG" +out embeddedStatement); + +#line 1585 "cs.ATG" + statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); + } else if (la.kind == 65) { + lexer.NextToken(); + EmbeddedStatement( +#line 1587 "cs.ATG" +out embeddedStatement); + Expect(125); + Expect(20); + Expr( +#line 1588 "cs.ATG" +out expr); + Expect(21); + Expect(11); + +#line 1589 "cs.ATG" + statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); + } else if (la.kind == 76) { + lexer.NextToken(); + +#line 1591 "cs.ATG" + List initializer = null; List iterator = null; + Expect(20); + if (StartOf(6)) { + ForInitializer( +#line 1592 "cs.ATG" +out initializer); + } + Expect(11); + if (StartOf(6)) { + Expr( +#line 1593 "cs.ATG" +out expr); + } + Expect(11); + if (StartOf(6)) { + ForIterator( +#line 1594 "cs.ATG" +out iterator); + } + Expect(21); + EmbeddedStatement( +#line 1595 "cs.ATG" +out embeddedStatement); + +#line 1596 "cs.ATG" + statement = new ForStatement(initializer, expr, iterator, embeddedStatement); + } else if (la.kind == 77) { + lexer.NextToken(); + Expect(20); + Type( +#line 1598 "cs.ATG" +out type); + Identifier(); + +#line 1598 "cs.ATG" + string varName = t.val; + Expect(81); + Expr( +#line 1599 "cs.ATG" +out expr); + Expect(21); + EmbeddedStatement( +#line 1600 "cs.ATG" +out embeddedStatement); + +#line 1601 "cs.ATG" + statement = new ForeachStatement(type, varName , expr, embeddedStatement); + } else if (la.kind == 53) { + lexer.NextToken(); + Expect(11); + +#line 1604 "cs.ATG" + statement = new BreakStatement(); + } else if (la.kind == 61) { + lexer.NextToken(); + Expect(11); + +#line 1605 "cs.ATG" + statement = new ContinueStatement(); + } else if (la.kind == 78) { + GotoStatement( +#line 1606 "cs.ATG" +out statement); + } else if ( +#line 1608 "cs.ATG" +IsYieldStatement()) { + Expect(132); + if (la.kind == 101) { + lexer.NextToken(); + Expr( +#line 1609 "cs.ATG" +out expr); + +#line 1609 "cs.ATG" + statement = new YieldStatement(new ReturnStatement(expr)); + } else if (la.kind == 53) { + lexer.NextToken(); + +#line 1610 "cs.ATG" + statement = new YieldStatement(new BreakStatement()); + } else SynErr(197); + Expect(11); + } else if (la.kind == 101) { + lexer.NextToken(); + if (StartOf(6)) { + Expr( +#line 1613 "cs.ATG" +out expr); + } + Expect(11); + +#line 1613 "cs.ATG" + statement = new ReturnStatement(expr); + } else if (la.kind == 112) { + lexer.NextToken(); + if (StartOf(6)) { + Expr( +#line 1614 "cs.ATG" +out expr); + } + Expect(11); + +#line 1614 "cs.ATG" + statement = new ThrowStatement(expr); + } else if (StartOf(6)) { + StatementExpr( +#line 1617 "cs.ATG" +out statement); + while (!(la.kind == 0 || la.kind == 11)) {SynErr(198); lexer.NextToken(); } + Expect(11); + } else if (la.kind == 114) { + TryStatement( +#line 1620 "cs.ATG" +out statement); + } else if (la.kind == 86) { + lexer.NextToken(); + Expect(20); + Expr( +#line 1623 "cs.ATG" +out expr); + Expect(21); + EmbeddedStatement( +#line 1624 "cs.ATG" +out embeddedStatement); + +#line 1624 "cs.ATG" + statement = new LockStatement(expr, embeddedStatement); + } else if (la.kind == 121) { + +#line 1627 "cs.ATG" + Statement resourceAcquisitionStmt = null; + lexer.NextToken(); + Expect(20); + ResourceAcquisition( +#line 1629 "cs.ATG" +out resourceAcquisitionStmt); + Expect(21); + EmbeddedStatement( +#line 1630 "cs.ATG" +out embeddedStatement); + +#line 1630 "cs.ATG" + statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); + } else if (la.kind == 119) { + lexer.NextToken(); + Block( +#line 1633 "cs.ATG" +out block); + +#line 1633 "cs.ATG" + statement = new UnsafeStatement(block); + } else if (la.kind == 74) { + +#line 1635 "cs.ATG" + Statement pointerDeclarationStmt = null; + lexer.NextToken(); + Expect(20); + ResourceAcquisition( +#line 1637 "cs.ATG" +out pointerDeclarationStmt); + Expect(21); + EmbeddedStatement( +#line 1638 "cs.ATG" +out embeddedStatement); + +#line 1638 "cs.ATG" + statement = new FixedStatement(pointerDeclarationStmt, embeddedStatement); + } else SynErr(199); + +#line 1640 "cs.ATG" + if (statement != null) { + statement.StartLocation = startLocation; + statement.EndLocation = t.EndLocation; + } + + } + + void IfStatement( +#line 1647 "cs.ATG" +out Statement statement) { + +#line 1649 "cs.ATG" + Expression expr = null; + Statement embeddedStatement = null; + statement = null; + + Expect(79); + Expect(20); + Expr( +#line 1655 "cs.ATG" +out expr); + Expect(21); + EmbeddedStatement( +#line 1656 "cs.ATG" +out embeddedStatement); + +#line 1657 "cs.ATG" + Statement elseStatement = null; + if (la.kind == 67) { + lexer.NextToken(); + EmbeddedStatement( +#line 1658 "cs.ATG" +out elseStatement); + } + +#line 1659 "cs.ATG" + statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); + +#line 1660 "cs.ATG" + if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) { + /* else if-section (otherwise we would have a BlockStatment) */ + (statement as IfElseStatement).ElseIfSections.Add( + new ElseIfSection((elseStatement as IfElseStatement).Condition, + (elseStatement as IfElseStatement).TrueStatement[0])); + (statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections); + (statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement; + } + + } + + void SwitchSections( +#line 1690 "cs.ATG" +List switchSections) { + +#line 1692 "cs.ATG" + SwitchSection switchSection = new SwitchSection(); + CaseLabel label; + + SwitchLabel( +#line 1696 "cs.ATG" +out label); + +#line 1696 "cs.ATG" + SafeAdd(switchSection, switchSection.SwitchLabels, label); + +#line 1697 "cs.ATG" + BlockStart(switchSection); + while (StartOf(31)) { + if (la.kind == 55 || la.kind == 63) { + SwitchLabel( +#line 1699 "cs.ATG" +out label); + +#line 1700 "cs.ATG" + if (label != null) { + if (switchSection.Children.Count > 0) { + // open new section + BlockEnd(); switchSections.Add(switchSection); + switchSection = new SwitchSection(); + BlockStart(switchSection); + } + SafeAdd(switchSection, switchSection.SwitchLabels, label); + } + + } else { + Statement(); + } + } + +#line 1712 "cs.ATG" + BlockEnd(); switchSections.Add(switchSection); + } + + void ForInitializer( +#line 1671 "cs.ATG" +out List initializer) { + +#line 1673 "cs.ATG" + Statement stmt; + initializer = new List(); + + if ( +#line 1677 "cs.ATG" +IsLocalVarDecl()) { + LocalVariableDecl( +#line 1677 "cs.ATG" +out stmt); + +#line 1677 "cs.ATG" + initializer.Add(stmt); + } else if (StartOf(6)) { + StatementExpr( +#line 1678 "cs.ATG" +out stmt); + +#line 1678 "cs.ATG" + initializer.Add(stmt); + while (la.kind == 14) { + lexer.NextToken(); + StatementExpr( +#line 1678 "cs.ATG" +out stmt); + +#line 1678 "cs.ATG" + initializer.Add(stmt); + } + } else SynErr(200); + } + + void ForIterator( +#line 1681 "cs.ATG" +out List iterator) { + +#line 1683 "cs.ATG" + Statement stmt; + iterator = new List(); + + StatementExpr( +#line 1687 "cs.ATG" +out stmt); + +#line 1687 "cs.ATG" + iterator.Add(stmt); + while (la.kind == 14) { + lexer.NextToken(); + StatementExpr( +#line 1687 "cs.ATG" +out stmt); + +#line 1687 "cs.ATG" + iterator.Add(stmt); + } + } + + void GotoStatement( +#line 1769 "cs.ATG" +out Statement stmt) { + +#line 1770 "cs.ATG" + Expression expr; stmt = null; + Expect(78); + if (StartOf(18)) { + Identifier(); + +#line 1774 "cs.ATG" + stmt = new GotoStatement(t.val); + Expect(11); + } else if (la.kind == 55) { + lexer.NextToken(); + Expr( +#line 1775 "cs.ATG" +out expr); + Expect(11); + +#line 1775 "cs.ATG" + stmt = new GotoCaseStatement(expr); + } else if (la.kind == 63) { + lexer.NextToken(); + Expect(11); + +#line 1776 "cs.ATG" + stmt = new GotoCaseStatement(null); + } else SynErr(201); + } + + void StatementExpr( +#line 1796 "cs.ATG" +out Statement stmt) { + +#line 1797 "cs.ATG" + Expression expr; + Expr( +#line 1799 "cs.ATG" +out expr); + +#line 1802 "cs.ATG" + stmt = new ExpressionStatement(expr); + } + + void TryStatement( +#line 1722 "cs.ATG" +out Statement tryStatement) { + +#line 1724 "cs.ATG" + BlockStatement blockStmt = null, finallyStmt = null; + CatchClause catchClause = null; + List catchClauses = new List(); + + Expect(114); + Block( +#line 1729 "cs.ATG" +out blockStmt); + while (la.kind == 56) { + CatchClause( +#line 1731 "cs.ATG" +out catchClause); + +#line 1732 "cs.ATG" + if (catchClause != null) catchClauses.Add(catchClause); + } + if (la.kind == 73) { + lexer.NextToken(); + Block( +#line 1734 "cs.ATG" +out finallyStmt); + } + +#line 1736 "cs.ATG" + tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); + if (catchClauses != null) { + foreach (CatchClause cc in catchClauses) cc.Parent = tryStatement; + } + + } + + void ResourceAcquisition( +#line 1780 "cs.ATG" +out Statement stmt) { + +#line 1782 "cs.ATG" + stmt = null; + Expression expr; + + if ( +#line 1787 "cs.ATG" +IsLocalVarDecl()) { + LocalVariableDecl( +#line 1787 "cs.ATG" +out stmt); + } else if (StartOf(6)) { + Expr( +#line 1788 "cs.ATG" +out expr); + +#line 1792 "cs.ATG" + stmt = new ExpressionStatement(expr); + } else SynErr(202); + } + + void SwitchLabel( +#line 1715 "cs.ATG" +out CaseLabel label) { + +#line 1716 "cs.ATG" + Expression expr = null; label = null; + if (la.kind == 55) { + lexer.NextToken(); + Expr( +#line 1718 "cs.ATG" +out expr); + Expect(9); + +#line 1718 "cs.ATG" + label = new CaseLabel(expr); + } else if (la.kind == 63) { + lexer.NextToken(); + Expect(9); + +#line 1719 "cs.ATG" + label = new CaseLabel(); + } else SynErr(203); + } + + void CatchClause( +#line 1743 "cs.ATG" +out CatchClause catchClause) { + Expect(56); + +#line 1745 "cs.ATG" + string identifier; + BlockStatement stmt; + TypeReference typeRef; + Location startPos = t.Location; + catchClause = null; + + if (la.kind == 16) { + Block( +#line 1753 "cs.ATG" +out stmt); + +#line 1753 "cs.ATG" + catchClause = new CatchClause(stmt); + } else if (la.kind == 20) { + lexer.NextToken(); + ClassType( +#line 1756 "cs.ATG" +out typeRef, false); + +#line 1756 "cs.ATG" + identifier = null; + if (StartOf(18)) { + Identifier(); + +#line 1757 "cs.ATG" + identifier = t.val; + } + Expect(21); + Block( +#line 1758 "cs.ATG" +out stmt); + +#line 1759 "cs.ATG" + catchClause = new CatchClause(typeRef, identifier, stmt); + } else SynErr(204); + +#line 1762 "cs.ATG" + if (catchClause != null) { + catchClause.StartLocation = startPos; + catchClause.EndLocation = t.Location; + } + + } + + void UnaryExpr( +#line 1831 "cs.ATG" +out Expression uExpr) { + +#line 1833 "cs.ATG" + TypeReference type = null; + Expression expr = null; + ArrayList expressions = new ArrayList(); + uExpr = null; + + while (StartOf(32) || +#line 1855 "cs.ATG" +IsTypeCast()) { + if (la.kind == 4) { + lexer.NextToken(); + +#line 1842 "cs.ATG" + expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus) { StartLocation = t.Location }); + } else if (la.kind == 5) { + lexer.NextToken(); + +#line 1843 "cs.ATG" + expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus) { StartLocation = t.Location }); + } else if (la.kind == 24) { + lexer.NextToken(); + +#line 1844 "cs.ATG" + expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not) { StartLocation = t.Location }); + } else if (la.kind == 27) { + lexer.NextToken(); + +#line 1845 "cs.ATG" + expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot) { StartLocation = t.Location }); + } else if (la.kind == 6) { + lexer.NextToken(); + +#line 1846 "cs.ATG" + expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Dereference) { StartLocation = t.Location }); + } else if (la.kind == 31) { + lexer.NextToken(); + +#line 1847 "cs.ATG" + expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment) { StartLocation = t.Location }); + } else if (la.kind == 32) { + lexer.NextToken(); + +#line 1848 "cs.ATG" + expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement) { StartLocation = t.Location }); + } else if (la.kind == 28) { + lexer.NextToken(); + +#line 1849 "cs.ATG" + expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.AddressOf) { StartLocation = t.Location }); + } else { + Expect(20); + Type( +#line 1855 "cs.ATG" +out type); + Expect(21); + +#line 1855 "cs.ATG" + expressions.Add(new CastExpression(type) { StartLocation = t.Location }); + } + } + if ( +#line 1860 "cs.ATG" +LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffix()) { + Expect(2); + +#line 1863 "cs.ATG" + expressions.RemoveAt(expressions.Count - 1); + if (t.literalValue is uint) { + expr = new PrimitiveExpression(int.MinValue, int.MinValue.ToString()); + } else if (t.literalValue is ulong) { + expr = new PrimitiveExpression(long.MinValue, long.MinValue.ToString()); + } else { + throw new Exception("t.literalValue must be uint or ulong"); + } + + } else if (StartOf(33)) { + PrimaryExpr( +#line 1872 "cs.ATG" +out expr); + } else SynErr(205); + +#line 1874 "cs.ATG" + for (int i = 0; i < expressions.Count; ++i) { + Expression nextExpression = i + 1 < expressions.Count ? (Expression)expressions[i + 1] : expr; + if (expressions[i] is CastExpression) { + ((CastExpression)expressions[i]).Expression = nextExpression; + } else { + ((UnaryOperatorExpression)expressions[i]).Expression = nextExpression; + } + } + if (expressions.Count > 0) { + uExpr = (Expression)expressions[0]; + } else { + uExpr = expr; + } + + } + + void ConditionalOrExpr( +#line 2184 "cs.ATG" +ref Expression outExpr) { + +#line 2185 "cs.ATG" + Expression expr; Location startLocation = la.Location; + ConditionalAndExpr( +#line 2187 "cs.ATG" +ref outExpr); + while (la.kind == 26) { + lexer.NextToken(); + UnaryExpr( +#line 2187 "cs.ATG" +out expr); + ConditionalAndExpr( +#line 2187 "cs.ATG" +ref expr); + +#line 2187 "cs.ATG" + outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void PrimaryExpr( +#line 1891 "cs.ATG" +out Expression pexpr) { + +#line 1893 "cs.ATG" + TypeReference type = null; + Expression expr; + pexpr = null; + + +#line 1898 "cs.ATG" + Location startLocation = la.Location; + if (la.kind == 113) { + lexer.NextToken(); + +#line 1900 "cs.ATG" + pexpr = new PrimitiveExpression(true, "true"); + } else if (la.kind == 72) { + lexer.NextToken(); + +#line 1901 "cs.ATG" + pexpr = new PrimitiveExpression(false, "false"); + } else if (la.kind == 90) { + lexer.NextToken(); + +#line 1902 "cs.ATG" + pexpr = new PrimitiveExpression(null, "null"); + } else if (la.kind == 2) { + lexer.NextToken(); + +#line 1903 "cs.ATG" + pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; + } else if ( +#line 1904 "cs.ATG" +StartOfQueryExpression()) { + QueryExpression( +#line 1905 "cs.ATG" +out pexpr); + } else if ( +#line 1906 "cs.ATG" +IdentAndDoubleColon()) { + Identifier(); + +#line 1907 "cs.ATG" + type = new TypeReference(t.val); + Expect(10); + +#line 1908 "cs.ATG" + pexpr = new TypeReferenceExpression(type); + Identifier(); + +#line 1909 "cs.ATG" + if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); + } else if (StartOf(18)) { + Identifier(); + +#line 1913 "cs.ATG" + pexpr = new IdentifierExpression(t.val); + if (la.kind == 48 || +#line 1916 "cs.ATG" +IsGenericInSimpleNameOrMemberAccess()) { + if (la.kind == 48) { + ShortedLambdaExpression( +#line 1915 "cs.ATG" +(IdentifierExpression)pexpr, out pexpr); + } else { + +#line 1917 "cs.ATG" + List typeList; + TypeArgumentList( +#line 1918 "cs.ATG" +out typeList, false); + +#line 1919 "cs.ATG" + ((IdentifierExpression)pexpr).TypeArguments = typeList; + } + } + } else if ( +#line 1921 "cs.ATG" +IsLambdaExpression()) { + LambdaExpression( +#line 1922 "cs.ATG" +out pexpr); + } else if (la.kind == 20) { + lexer.NextToken(); + Expr( +#line 1925 "cs.ATG" +out expr); + Expect(21); + +#line 1925 "cs.ATG" + pexpr = new ParenthesizedExpression(expr); + } else if (StartOf(34)) { + +#line 1928 "cs.ATG" + string val = null; + switch (la.kind) { + case 52: { + lexer.NextToken(); + +#line 1929 "cs.ATG" + val = "System.Boolean"; + break; + } + case 54: { + lexer.NextToken(); + +#line 1930 "cs.ATG" + val = "System.Byte"; + break; + } + case 57: { + lexer.NextToken(); + +#line 1931 "cs.ATG" + val = "System.Char"; + break; + } + case 62: { + lexer.NextToken(); + +#line 1932 "cs.ATG" + val = "System.Decimal"; + break; + } + case 66: { + lexer.NextToken(); + +#line 1933 "cs.ATG" + val = "System.Double"; + break; + } + case 75: { + lexer.NextToken(); + +#line 1934 "cs.ATG" + val = "System.Single"; + break; + } + case 82: { + lexer.NextToken(); + +#line 1935 "cs.ATG" + val = "System.Int32"; + break; + } + case 87: { + lexer.NextToken(); + +#line 1936 "cs.ATG" + val = "System.Int64"; + break; + } + case 91: { + lexer.NextToken(); + +#line 1937 "cs.ATG" + val = "System.Object"; + break; + } + case 102: { + lexer.NextToken(); + +#line 1938 "cs.ATG" + val = "System.SByte"; + break; + } + case 104: { + lexer.NextToken(); + +#line 1939 "cs.ATG" + val = "System.Int16"; + break; + } + case 108: { + lexer.NextToken(); + +#line 1940 "cs.ATG" + val = "System.String"; + break; + } + case 116: { + lexer.NextToken(); + +#line 1941 "cs.ATG" + val = "System.UInt32"; + break; + } + case 117: { + lexer.NextToken(); + +#line 1942 "cs.ATG" + val = "System.UInt64"; + break; + } + case 120: { + lexer.NextToken(); + +#line 1943 "cs.ATG" + val = "System.UInt16"; + break; + } + case 123: { + lexer.NextToken(); + +#line 1944 "cs.ATG" + val = "System.Void"; + break; + } + } + +#line 1946 "cs.ATG" + pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation }; + } else if (la.kind == 111) { + lexer.NextToken(); + +#line 1949 "cs.ATG" + pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; + } else if (la.kind == 51) { + lexer.NextToken(); + +#line 1951 "cs.ATG" + pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; + } else if (la.kind == 89) { + NewExpression( +#line 1954 "cs.ATG" +out pexpr); + } else if (la.kind == 115) { + lexer.NextToken(); + Expect(20); + if ( +#line 1958 "cs.ATG" +NotVoidPointer()) { + Expect(123); + +#line 1958 "cs.ATG" + type = new TypeReference("System.Void", true); + } else if (StartOf(10)) { + TypeWithRestriction( +#line 1959 "cs.ATG" +out type, true, true); + } else SynErr(206); + Expect(21); + +#line 1961 "cs.ATG" + pexpr = new TypeOfExpression(type); + } else if (la.kind == 63) { + lexer.NextToken(); + Expect(20); + Type( +#line 1963 "cs.ATG" +out type); + Expect(21); + +#line 1963 "cs.ATG" + pexpr = new DefaultValueExpression(type); + } else if (la.kind == 105) { + lexer.NextToken(); + Expect(20); + Type( +#line 1964 "cs.ATG" +out type); + Expect(21); + +#line 1964 "cs.ATG" + pexpr = new SizeOfExpression(type); + } else if (la.kind == 58) { + lexer.NextToken(); + Expect(20); + Expr( +#line 1965 "cs.ATG" +out expr); + Expect(21); + +#line 1965 "cs.ATG" + pexpr = new CheckedExpression(expr); + } else if (la.kind == 118) { + lexer.NextToken(); + Expect(20); + Expr( +#line 1966 "cs.ATG" +out expr); + Expect(21); + +#line 1966 "cs.ATG" + pexpr = new UncheckedExpression(expr); + } else if (la.kind == 64) { + lexer.NextToken(); + AnonymousMethodExpr( +#line 1967 "cs.ATG" +out expr); + +#line 1967 "cs.ATG" + pexpr = expr; + } else SynErr(207); + +#line 1969 "cs.ATG" + if (pexpr != null) { + if (pexpr.StartLocation.IsEmpty) + pexpr.StartLocation = startLocation; + if (pexpr.EndLocation.IsEmpty) + pexpr.EndLocation = t.EndLocation; + } + + while (StartOf(35)) { + +#line 1977 "cs.ATG" + startLocation = la.Location; + switch (la.kind) { + case 31: { + lexer.NextToken(); + +#line 1979 "cs.ATG" + pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); + break; + } + case 32: { + lexer.NextToken(); + +#line 1981 "cs.ATG" + pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); + break; + } + case 47: { + PointerMemberAccess( +#line 1983 "cs.ATG" +out pexpr, pexpr); + break; + } + case 15: { + MemberAccess( +#line 1984 "cs.ATG" +out pexpr, pexpr); + break; + } + case 20: { + lexer.NextToken(); + +#line 1988 "cs.ATG" + List parameters = new List(); + +#line 1989 "cs.ATG" + pexpr = new InvocationExpression(pexpr, parameters); + if (StartOf(25)) { + Argument( +#line 1990 "cs.ATG" +out expr); + +#line 1990 "cs.ATG" + SafeAdd(pexpr, parameters, expr); + while (la.kind == 14) { + lexer.NextToken(); + Argument( +#line 1991 "cs.ATG" +out expr); + +#line 1991 "cs.ATG" + SafeAdd(pexpr, parameters, expr); + } + } + Expect(21); + break; + } + case 18: { + +#line 1997 "cs.ATG" + List indices = new List(); + pexpr = new IndexerExpression(pexpr, indices); + + lexer.NextToken(); + Expr( +#line 2000 "cs.ATG" +out expr); + +#line 2000 "cs.ATG" + SafeAdd(pexpr, indices, expr); + while (la.kind == 14) { + lexer.NextToken(); + Expr( +#line 2001 "cs.ATG" +out expr); + +#line 2001 "cs.ATG" + SafeAdd(pexpr, indices, expr); + } + Expect(19); + break; + } + } + +#line 2004 "cs.ATG" + if (pexpr != null) { + if (pexpr.StartLocation.IsEmpty) + pexpr.StartLocation = startLocation; + if (pexpr.EndLocation.IsEmpty) + pexpr.EndLocation = t.EndLocation; + } + + } + } + + void QueryExpression( +#line 2442 "cs.ATG" +out Expression outExpr) { + +#line 2443 "cs.ATG" + QueryExpression q = new QueryExpression(); outExpr = q; q.StartLocation = la.Location; + QueryExpressionFromClause fromClause; + + QueryExpressionFromClause( +#line 2447 "cs.ATG" +out fromClause); + +#line 2447 "cs.ATG" + q.FromClause = fromClause; + QueryExpressionBody( +#line 2448 "cs.ATG" +ref q); + +#line 2449 "cs.ATG" + q.EndLocation = t.EndLocation; + outExpr = q; /* set outExpr to q again if QueryExpressionBody changed it (can happen with 'into' clauses) */ + + } + + void ShortedLambdaExpression( +#line 2118 "cs.ATG" +IdentifierExpression ident, out Expression pexpr) { + +#line 2119 "cs.ATG" + LambdaExpression lambda = new LambdaExpression(); pexpr = lambda; + Expect(48); + +#line 2124 "cs.ATG" + lambda.StartLocation = ident.StartLocation; + SafeAdd(lambda, lambda.Parameters, new ParameterDeclarationExpression(null, ident.Identifier)); + lambda.Parameters[0].StartLocation = ident.StartLocation; + lambda.Parameters[0].EndLocation = ident.EndLocation; + + LambdaExpressionBody( +#line 2129 "cs.ATG" +lambda); + } + + void TypeArgumentList( +#line 2361 "cs.ATG" +out List types, bool canBeUnbound) { + +#line 2363 "cs.ATG" + types = new List(); + TypeReference type = null; + + Expect(23); + if ( +#line 2368 "cs.ATG" +canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) { + +#line 2369 "cs.ATG" + types.Add(TypeReference.Null); + while (la.kind == 14) { + lexer.NextToken(); + +#line 2370 "cs.ATG" + types.Add(TypeReference.Null); + } + } else if (StartOf(10)) { + Type( +#line 2371 "cs.ATG" +out type); + +#line 2371 "cs.ATG" + if (type != null) { types.Add(type); } + while (la.kind == 14) { + lexer.NextToken(); + Type( +#line 2372 "cs.ATG" +out type); + +#line 2372 "cs.ATG" + if (type != null) { types.Add(type); } + } + } else SynErr(208); + Expect(22); + } + + void LambdaExpression( +#line 2098 "cs.ATG" +out Expression outExpr) { + +#line 2100 "cs.ATG" + LambdaExpression lambda = new LambdaExpression(); + lambda.StartLocation = la.Location; + ParameterDeclarationExpression p; + outExpr = lambda; + + Expect(20); + if (StartOf(36)) { + LambdaExpressionParameter( +#line 2108 "cs.ATG" +out p); + +#line 2108 "cs.ATG" + SafeAdd(lambda, lambda.Parameters, p); + while (la.kind == 14) { + lexer.NextToken(); + LambdaExpressionParameter( +#line 2110 "cs.ATG" +out p); + +#line 2110 "cs.ATG" + SafeAdd(lambda, lambda.Parameters, p); + } + } + Expect(21); + Expect(48); + LambdaExpressionBody( +#line 2115 "cs.ATG" +lambda); + } + + void NewExpression( +#line 2045 "cs.ATG" +out Expression pexpr) { + +#line 2046 "cs.ATG" + pexpr = null; + List parameters = new List(); + TypeReference type = null; + Expression expr; + + Expect(89); + if (StartOf(10)) { + NonArrayType( +#line 2053 "cs.ATG" +out type); + } + if (la.kind == 16 || la.kind == 20) { + if (la.kind == 20) { + +#line 2059 "cs.ATG" + ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); + lexer.NextToken(); + +#line 2060 "cs.ATG" + if (type == null) Error("Cannot use an anonymous type with arguments for the constructor"); + if (StartOf(25)) { + Argument( +#line 2061 "cs.ATG" +out expr); + +#line 2061 "cs.ATG" + SafeAdd(oce, parameters, expr); + while (la.kind == 14) { + lexer.NextToken(); + Argument( +#line 2062 "cs.ATG" +out expr); + +#line 2062 "cs.ATG" + SafeAdd(oce, parameters, expr); + } + } + Expect(21); + +#line 2064 "cs.ATG" + pexpr = oce; + if (la.kind == 16) { + CollectionOrObjectInitializer( +#line 2065 "cs.ATG" +out expr); + +#line 2065 "cs.ATG" + oce.ObjectInitializer = (CollectionInitializerExpression)expr; + } + } else { + +#line 2066 "cs.ATG" + ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); + CollectionOrObjectInitializer( +#line 2067 "cs.ATG" +out expr); + +#line 2067 "cs.ATG" + oce.ObjectInitializer = (CollectionInitializerExpression)expr; + +#line 2068 "cs.ATG" + pexpr = oce; + } + } else if (la.kind == 18) { + lexer.NextToken(); + +#line 2073 "cs.ATG" + ArrayCreateExpression ace = new ArrayCreateExpression(type); + /* we must not change RankSpecifier on the null type reference*/ + if (ace.CreateType.IsNull) { ace.CreateType = new TypeReference(""); } + pexpr = ace; + int dims = 0; List ranks = new List(); + + if (la.kind == 14 || la.kind == 19) { + while (la.kind == 14) { + lexer.NextToken(); + +#line 2080 "cs.ATG" + dims += 1; + } + Expect(19); + +#line 2081 "cs.ATG" + ranks.Add(dims); dims = 0; + while (la.kind == 18) { + lexer.NextToken(); + while (la.kind == 14) { + lexer.NextToken(); + +#line 2082 "cs.ATG" + ++dims; + } + Expect(19); + +#line 2082 "cs.ATG" + ranks.Add(dims); dims = 0; + } + +#line 2083 "cs.ATG" + ace.CreateType.RankSpecifier = ranks.ToArray(); + CollectionInitializer( +#line 2084 "cs.ATG" +out expr); + +#line 2084 "cs.ATG" + ace.ArrayInitializer = (CollectionInitializerExpression)expr; + } else if (StartOf(6)) { + Expr( +#line 2085 "cs.ATG" +out expr); + +#line 2085 "cs.ATG" + if (expr != null) parameters.Add(expr); + while (la.kind == 14) { + lexer.NextToken(); + +#line 2086 "cs.ATG" + dims += 1; + Expr( +#line 2087 "cs.ATG" +out expr); + +#line 2087 "cs.ATG" + if (expr != null) parameters.Add(expr); + } + Expect(19); + +#line 2089 "cs.ATG" + ranks.Add(dims); ace.Arguments = parameters; dims = 0; + while (la.kind == 18) { + lexer.NextToken(); + while (la.kind == 14) { + lexer.NextToken(); + +#line 2090 "cs.ATG" + ++dims; + } + Expect(19); + +#line 2090 "cs.ATG" + ranks.Add(dims); dims = 0; + } + +#line 2091 "cs.ATG" + ace.CreateType.RankSpecifier = ranks.ToArray(); + if (la.kind == 16) { + CollectionInitializer( +#line 2092 "cs.ATG" +out expr); + +#line 2092 "cs.ATG" + ace.ArrayInitializer = (CollectionInitializerExpression)expr; + } + } else SynErr(209); + } else SynErr(210); + } + + void AnonymousMethodExpr( +#line 2165 "cs.ATG" +out Expression outExpr) { + +#line 2167 "cs.ATG" + AnonymousMethodExpression expr = new AnonymousMethodExpression(); + expr.StartLocation = t.Location; + BlockStatement stmt; + List p = new List(); + outExpr = expr; + + if (la.kind == 20) { + lexer.NextToken(); + if (StartOf(11)) { + FormalParameterList( +#line 2176 "cs.ATG" +p); + +#line 2176 "cs.ATG" + expr.Parameters = p; + } + Expect(21); + +#line 2178 "cs.ATG" + expr.HasParameterList = true; + } + Block( +#line 2180 "cs.ATG" +out stmt); + +#line 2180 "cs.ATG" + expr.Body = stmt; + +#line 2181 "cs.ATG" + expr.EndLocation = t.Location; + } + + void PointerMemberAccess( +#line 2033 "cs.ATG" +out Expression expr, Expression target) { + +#line 2034 "cs.ATG" + List typeList; + Expect(47); + Identifier(); + +#line 2038 "cs.ATG" + expr = new PointerReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; + if ( +#line 2039 "cs.ATG" +IsGenericInSimpleNameOrMemberAccess()) { + TypeArgumentList( +#line 2040 "cs.ATG" +out typeList, false); + +#line 2041 "cs.ATG" + ((MemberReferenceExpression)expr).TypeArguments = typeList; + } + } + + void MemberAccess( +#line 2014 "cs.ATG" +out Expression expr, Expression target) { + +#line 2015 "cs.ATG" + List typeList; + +#line 2017 "cs.ATG" + if (ShouldConvertTargetExpressionToTypeReference(target)) { + TypeReference type = GetTypeReferenceFromExpression(target); + if (type != null) { + target = new TypeReferenceExpression(type) { StartLocation = t.Location, EndLocation = t.EndLocation }; + } + } + + Expect(15); + +#line 2024 "cs.ATG" + Location startLocation = t.Location; + Identifier(); + +#line 2026 "cs.ATG" + expr = new MemberReferenceExpression(target, t.val); expr.StartLocation = startLocation; expr.EndLocation = t.EndLocation; + if ( +#line 2027 "cs.ATG" +IsGenericInSimpleNameOrMemberAccess()) { + TypeArgumentList( +#line 2028 "cs.ATG" +out typeList, false); + +#line 2029 "cs.ATG" + ((MemberReferenceExpression)expr).TypeArguments = typeList; + } + } + + void LambdaExpressionParameter( +#line 2132 "cs.ATG" +out ParameterDeclarationExpression p) { + +#line 2133 "cs.ATG" + Location start = la.Location; p = null; + TypeReference type; + ParameterModifiers mod = ParameterModifiers.In; + + if ( +#line 2138 "cs.ATG" +Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) { + Identifier(); + +#line 2140 "cs.ATG" + p = new ParameterDeclarationExpression(null, t.val); + p.StartLocation = start; p.EndLocation = t.EndLocation; + + } else if (StartOf(36)) { + if (la.kind == 93 || la.kind == 100) { + if (la.kind == 100) { + lexer.NextToken(); + +#line 2143 "cs.ATG" + mod = ParameterModifiers.Ref; + } else { + lexer.NextToken(); + +#line 2144 "cs.ATG" + mod = ParameterModifiers.Out; + } + } + Type( +#line 2146 "cs.ATG" +out type); + Identifier(); + +#line 2148 "cs.ATG" + p = new ParameterDeclarationExpression(type, t.val, mod); + p.StartLocation = start; p.EndLocation = t.EndLocation; + + } else SynErr(211); + } + + void LambdaExpressionBody( +#line 2154 "cs.ATG" +LambdaExpression lambda) { + +#line 2155 "cs.ATG" + Expression expr; BlockStatement stmt; + if (la.kind == 16) { + Block( +#line 2158 "cs.ATG" +out stmt); + +#line 2158 "cs.ATG" + lambda.StatementBody = stmt; + } else if (StartOf(6)) { + Expr( +#line 2159 "cs.ATG" +out expr); + +#line 2159 "cs.ATG" + lambda.ExpressionBody = expr; + } else SynErr(212); + +#line 2161 "cs.ATG" + lambda.EndLocation = t.EndLocation; + +#line 2162 "cs.ATG" + lambda.ExtendedEndLocation = la.Location; + } + + void ConditionalAndExpr( +#line 2190 "cs.ATG" +ref Expression outExpr) { + +#line 2191 "cs.ATG" + Expression expr; Location startLocation = la.Location; + InclusiveOrExpr( +#line 2193 "cs.ATG" +ref outExpr); + while (la.kind == 25) { + lexer.NextToken(); + UnaryExpr( +#line 2193 "cs.ATG" +out expr); + InclusiveOrExpr( +#line 2193 "cs.ATG" +ref expr); + +#line 2193 "cs.ATG" + outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void InclusiveOrExpr( +#line 2196 "cs.ATG" +ref Expression outExpr) { + +#line 2197 "cs.ATG" + Expression expr; Location startLocation = la.Location; + ExclusiveOrExpr( +#line 2199 "cs.ATG" +ref outExpr); + while (la.kind == 29) { + lexer.NextToken(); + UnaryExpr( +#line 2199 "cs.ATG" +out expr); + ExclusiveOrExpr( +#line 2199 "cs.ATG" +ref expr); + +#line 2199 "cs.ATG" + outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void ExclusiveOrExpr( +#line 2202 "cs.ATG" +ref Expression outExpr) { + +#line 2203 "cs.ATG" + Expression expr; Location startLocation = la.Location; + AndExpr( +#line 2205 "cs.ATG" +ref outExpr); + while (la.kind == 30) { + lexer.NextToken(); + UnaryExpr( +#line 2205 "cs.ATG" +out expr); + AndExpr( +#line 2205 "cs.ATG" +ref expr); + +#line 2205 "cs.ATG" + outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void AndExpr( +#line 2208 "cs.ATG" +ref Expression outExpr) { + +#line 2209 "cs.ATG" + Expression expr; Location startLocation = la.Location; + EqualityExpr( +#line 2211 "cs.ATG" +ref outExpr); + while (la.kind == 28) { + lexer.NextToken(); + UnaryExpr( +#line 2211 "cs.ATG" +out expr); + EqualityExpr( +#line 2211 "cs.ATG" +ref expr); + +#line 2211 "cs.ATG" + outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void EqualityExpr( +#line 2214 "cs.ATG" +ref Expression outExpr) { + +#line 2216 "cs.ATG" + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; + + RelationalExpr( +#line 2221 "cs.ATG" +ref outExpr); + while (la.kind == 33 || la.kind == 34) { + if (la.kind == 34) { + lexer.NextToken(); + +#line 2224 "cs.ATG" + op = BinaryOperatorType.InEquality; + } else { + lexer.NextToken(); + +#line 2225 "cs.ATG" + op = BinaryOperatorType.Equality; + } + UnaryExpr( +#line 2227 "cs.ATG" +out expr); + RelationalExpr( +#line 2227 "cs.ATG" +ref expr); + +#line 2227 "cs.ATG" + outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void RelationalExpr( +#line 2231 "cs.ATG" +ref Expression outExpr) { + +#line 2233 "cs.ATG" + TypeReference type; + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; + + ShiftExpr( +#line 2239 "cs.ATG" +ref outExpr); + while (StartOf(37)) { + if (StartOf(38)) { + if (la.kind == 23) { + lexer.NextToken(); + +#line 2241 "cs.ATG" + op = BinaryOperatorType.LessThan; + } else if (la.kind == 22) { + lexer.NextToken(); + +#line 2242 "cs.ATG" + op = BinaryOperatorType.GreaterThan; + } else if (la.kind == 36) { + lexer.NextToken(); + +#line 2243 "cs.ATG" + op = BinaryOperatorType.LessThanOrEqual; + } else if (la.kind == 35) { + lexer.NextToken(); + +#line 2244 "cs.ATG" + op = BinaryOperatorType.GreaterThanOrEqual; + } else SynErr(213); + UnaryExpr( +#line 2246 "cs.ATG" +out expr); + ShiftExpr( +#line 2247 "cs.ATG" +ref expr); + +#line 2248 "cs.ATG" + outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } else { + if (la.kind == 85) { + lexer.NextToken(); + TypeWithRestriction( +#line 2251 "cs.ATG" +out type, false, false); + if ( +#line 2252 "cs.ATG" +la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { + NullableQuestionMark( +#line 2253 "cs.ATG" +ref type); + } + +#line 2254 "cs.ATG" + outExpr = new TypeOfIsExpression(outExpr, type) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } else if (la.kind == 50) { + lexer.NextToken(); + TypeWithRestriction( +#line 2256 "cs.ATG" +out type, false, false); + if ( +#line 2257 "cs.ATG" +la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { + NullableQuestionMark( +#line 2258 "cs.ATG" +ref type); + } + +#line 2259 "cs.ATG" + outExpr = new CastExpression(type, outExpr, CastType.TryCast) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } else SynErr(214); + } + } + } + + void ShiftExpr( +#line 2264 "cs.ATG" +ref Expression outExpr) { + +#line 2266 "cs.ATG" + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; + + AdditiveExpr( +#line 2271 "cs.ATG" +ref outExpr); + while (la.kind == 37 || +#line 2274 "cs.ATG" +IsShiftRight()) { + if (la.kind == 37) { + lexer.NextToken(); + +#line 2273 "cs.ATG" + op = BinaryOperatorType.ShiftLeft; + } else { + Expect(22); + Expect(22); + +#line 2275 "cs.ATG" + op = BinaryOperatorType.ShiftRight; + } + UnaryExpr( +#line 2278 "cs.ATG" +out expr); + AdditiveExpr( +#line 2278 "cs.ATG" +ref expr); + +#line 2278 "cs.ATG" + outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void AdditiveExpr( +#line 2282 "cs.ATG" +ref Expression outExpr) { + +#line 2284 "cs.ATG" + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; + + MultiplicativeExpr( +#line 2289 "cs.ATG" +ref outExpr); + while (la.kind == 4 || la.kind == 5) { + if (la.kind == 4) { + lexer.NextToken(); + +#line 2292 "cs.ATG" + op = BinaryOperatorType.Add; + } else { + lexer.NextToken(); + +#line 2293 "cs.ATG" + op = BinaryOperatorType.Subtract; + } + UnaryExpr( +#line 2295 "cs.ATG" +out expr); + MultiplicativeExpr( +#line 2295 "cs.ATG" +ref expr); + +#line 2295 "cs.ATG" + outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void MultiplicativeExpr( +#line 2299 "cs.ATG" +ref Expression outExpr) { + +#line 2301 "cs.ATG" + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; + + while (la.kind == 6 || la.kind == 7 || la.kind == 8) { + if (la.kind == 6) { + lexer.NextToken(); + +#line 2308 "cs.ATG" + op = BinaryOperatorType.Multiply; + } else if (la.kind == 7) { + lexer.NextToken(); + +#line 2309 "cs.ATG" + op = BinaryOperatorType.Divide; + } else { + lexer.NextToken(); + +#line 2310 "cs.ATG" + op = BinaryOperatorType.Modulus; + } + UnaryExpr( +#line 2312 "cs.ATG" +out expr); + +#line 2312 "cs.ATG" + outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void VariantTypeParameter( +#line 2390 "cs.ATG" +out TemplateDefinition typeParameter) { + +#line 2392 "cs.ATG" + typeParameter = new TemplateDefinition(); + AttributeSection section; + + while (la.kind == 18) { + AttributeSection( +#line 2396 "cs.ATG" +out section); + +#line 2396 "cs.ATG" + typeParameter.Attributes.Add(section); + } + if (la.kind == 81 || la.kind == 93) { + if (la.kind == 81) { + lexer.NextToken(); + +#line 2398 "cs.ATG" + typeParameter.VarianceModifier = VarianceModifier.Contravariant; + } else { + lexer.NextToken(); + +#line 2399 "cs.ATG" + typeParameter.VarianceModifier = VarianceModifier.Covariant; + } + } + Identifier(); + +#line 2401 "cs.ATG" + typeParameter.Name = t.val; typeParameter.StartLocation = t.Location; + +#line 2402 "cs.ATG" + typeParameter.EndLocation = t.EndLocation; + } + + void TypeParameterConstraintsClauseBase( +#line 2433 "cs.ATG" +out TypeReference type) { + +#line 2434 "cs.ATG" + TypeReference t; type = null; + if (la.kind == 109) { + lexer.NextToken(); + +#line 2436 "cs.ATG" + type = TypeReference.StructConstraint; + } else if (la.kind == 59) { + lexer.NextToken(); + +#line 2437 "cs.ATG" + type = TypeReference.ClassConstraint; + } else if (la.kind == 89) { + lexer.NextToken(); + Expect(20); + Expect(21); + +#line 2438 "cs.ATG" + type = TypeReference.NewConstraint; + } else if (StartOf(10)) { + Type( +#line 2439 "cs.ATG" +out t); + +#line 2439 "cs.ATG" + type = t; + } else SynErr(215); + } + + void QueryExpressionFromClause( +#line 2454 "cs.ATG" +out QueryExpressionFromClause fc) { + +#line 2455 "cs.ATG" + fc = new QueryExpressionFromClause(); + fc.StartLocation = la.Location; + CollectionRangeVariable variable; + + Expect(137); + QueryExpressionFromOrJoinClause( +#line 2461 "cs.ATG" +out variable); + +#line 2462 "cs.ATG" + fc.EndLocation = t.EndLocation; + fc.Sources.Add(variable); + + } + + void QueryExpressionBody( +#line 2498 "cs.ATG" +ref QueryExpression q) { + +#line 2499 "cs.ATG" + QueryExpressionFromClause fromClause; QueryExpressionWhereClause whereClause; + QueryExpressionLetClause letClause; QueryExpressionJoinClause joinClause; + QueryExpressionOrderClause orderClause; + QueryExpressionSelectClause selectClause; QueryExpressionGroupClause groupClause; + + while (StartOf(39)) { + if (la.kind == 137) { + QueryExpressionFromClause( +#line 2505 "cs.ATG" +out fromClause); + +#line 2505 "cs.ATG" + SafeAdd(q, q.MiddleClauses, fromClause); + } else if (la.kind == 127) { + QueryExpressionWhereClause( +#line 2506 "cs.ATG" +out whereClause); + +#line 2506 "cs.ATG" + SafeAdd(q, q.MiddleClauses, whereClause); + } else if (la.kind == 141) { + QueryExpressionLetClause( +#line 2507 "cs.ATG" +out letClause); + +#line 2507 "cs.ATG" + SafeAdd(q, q.MiddleClauses, letClause); + } else if (la.kind == 142) { + QueryExpressionJoinClause( +#line 2508 "cs.ATG" +out joinClause); + +#line 2508 "cs.ATG" + SafeAdd(q, q.MiddleClauses, joinClause); + } else { + QueryExpressionOrderByClause( +#line 2509 "cs.ATG" +out orderClause); + +#line 2509 "cs.ATG" + SafeAdd(q, q.MiddleClauses, orderClause); + } + } + if (la.kind == 133) { + QueryExpressionSelectClause( +#line 2511 "cs.ATG" +out selectClause); + +#line 2511 "cs.ATG" + q.SelectOrGroupClause = selectClause; + } else if (la.kind == 134) { + QueryExpressionGroupClause( +#line 2512 "cs.ATG" +out groupClause); + +#line 2512 "cs.ATG" + q.SelectOrGroupClause = groupClause; + } else SynErr(216); + if (la.kind == 136) { + QueryExpressionIntoClause( +#line 2514 "cs.ATG" +ref q); + } + } + + void QueryExpressionFromOrJoinClause( +#line 2488 "cs.ATG" +out CollectionRangeVariable variable) { + +#line 2489 "cs.ATG" + TypeReference type; Expression expr; variable = new CollectionRangeVariable(); + +#line 2491 "cs.ATG" + variable.Type = null; + if ( +#line 2492 "cs.ATG" +IsLocalVarDecl()) { + Type( +#line 2492 "cs.ATG" +out type); + +#line 2492 "cs.ATG" + variable.Type = type; + } + Identifier(); + +#line 2493 "cs.ATG" + variable.Identifier = t.val; + Expect(81); + Expr( +#line 2495 "cs.ATG" +out expr); + +#line 2495 "cs.ATG" + variable.Expression = expr; + } + + void QueryExpressionJoinClause( +#line 2467 "cs.ATG" +out QueryExpressionJoinClause jc) { + +#line 2468 "cs.ATG" + jc = new QueryExpressionJoinClause(); jc.StartLocation = la.Location; + Expression expr; + CollectionRangeVariable variable; + + Expect(142); + QueryExpressionFromOrJoinClause( +#line 2474 "cs.ATG" +out variable); + Expect(143); + Expr( +#line 2476 "cs.ATG" +out expr); + +#line 2476 "cs.ATG" + jc.OnExpression = expr; + Expect(144); + Expr( +#line 2478 "cs.ATG" +out expr); + +#line 2478 "cs.ATG" + jc.EqualsExpression = expr; + if (la.kind == 136) { + lexer.NextToken(); + Identifier(); + +#line 2480 "cs.ATG" + jc.IntoIdentifier = t.val; + } + +#line 2483 "cs.ATG" + jc.EndLocation = t.EndLocation; + jc.Source = variable; + + } + + void QueryExpressionWhereClause( +#line 2517 "cs.ATG" +out QueryExpressionWhereClause wc) { + +#line 2518 "cs.ATG" + Expression expr; wc = new QueryExpressionWhereClause(); wc.StartLocation = la.Location; + Expect(127); + Expr( +#line 2521 "cs.ATG" +out expr); + +#line 2521 "cs.ATG" + wc.Condition = expr; + +#line 2522 "cs.ATG" + wc.EndLocation = t.EndLocation; + } + + void QueryExpressionLetClause( +#line 2525 "cs.ATG" +out QueryExpressionLetClause wc) { + +#line 2526 "cs.ATG" + Expression expr; wc = new QueryExpressionLetClause(); wc.StartLocation = la.Location; + Expect(141); + Identifier(); + +#line 2529 "cs.ATG" + wc.Identifier = t.val; + Expect(3); + Expr( +#line 2531 "cs.ATG" +out expr); + +#line 2531 "cs.ATG" + wc.Expression = expr; + +#line 2532 "cs.ATG" + wc.EndLocation = t.EndLocation; + } + + void QueryExpressionOrderByClause( +#line 2535 "cs.ATG" +out QueryExpressionOrderClause oc) { + +#line 2536 "cs.ATG" + QueryExpressionOrdering ordering; oc = new QueryExpressionOrderClause(); oc.StartLocation = la.Location; + Expect(140); + QueryExpressionOrdering( +#line 2539 "cs.ATG" +out ordering); + +#line 2539 "cs.ATG" + SafeAdd(oc, oc.Orderings, ordering); + while (la.kind == 14) { + lexer.NextToken(); + QueryExpressionOrdering( +#line 2541 "cs.ATG" +out ordering); + +#line 2541 "cs.ATG" + SafeAdd(oc, oc.Orderings, ordering); + } + +#line 2543 "cs.ATG" + oc.EndLocation = t.EndLocation; + } + + void QueryExpressionSelectClause( +#line 2556 "cs.ATG" +out QueryExpressionSelectClause sc) { + +#line 2557 "cs.ATG" + Expression expr; sc = new QueryExpressionSelectClause(); sc.StartLocation = la.Location; + Expect(133); + Expr( +#line 2560 "cs.ATG" +out expr); + +#line 2560 "cs.ATG" + sc.Projection = expr; + +#line 2561 "cs.ATG" + sc.EndLocation = t.EndLocation; + } + + void QueryExpressionGroupClause( +#line 2564 "cs.ATG" +out QueryExpressionGroupClause gc) { + +#line 2565 "cs.ATG" + Expression expr; gc = new QueryExpressionGroupClause(); gc.StartLocation = la.Location; + Expect(134); + Expr( +#line 2568 "cs.ATG" +out expr); + +#line 2568 "cs.ATG" + gc.Projection = expr; + Expect(135); + Expr( +#line 2570 "cs.ATG" +out expr); + +#line 2570 "cs.ATG" + gc.GroupBy = expr; + +#line 2571 "cs.ATG" + gc.EndLocation = t.EndLocation; + } + + void QueryExpressionIntoClause( +#line 2574 "cs.ATG" +ref QueryExpression q) { + +#line 2575 "cs.ATG" + QueryExpression firstQuery = q; + QueryExpression continuedQuery = new QueryExpression(); + continuedQuery.StartLocation = q.StartLocation; + firstQuery.EndLocation = la.Location; + continuedQuery.FromClause = new QueryExpressionFromClause(); + CollectionRangeVariable fromVariable = new CollectionRangeVariable(); + continuedQuery.FromClause.Sources.Add(fromVariable); + fromVariable.StartLocation = la.Location; + // nest firstQuery inside continuedQuery. + fromVariable.Expression = firstQuery; + continuedQuery.IsQueryContinuation = true; + q = continuedQuery; + + Expect(136); + Identifier(); + +#line 2590 "cs.ATG" + fromVariable.Identifier = t.val; + +#line 2591 "cs.ATG" + continuedQuery.FromClause.EndLocation = t.EndLocation; + QueryExpressionBody( +#line 2592 "cs.ATG" +ref q); + } + + void QueryExpressionOrdering( +#line 2546 "cs.ATG" +out QueryExpressionOrdering ordering) { + +#line 2547 "cs.ATG" + Expression expr; ordering = new QueryExpressionOrdering(); ordering.StartLocation = la.Location; + Expr( +#line 2549 "cs.ATG" +out expr); + +#line 2549 "cs.ATG" + ordering.Criteria = expr; + if (la.kind == 138 || la.kind == 139) { + if (la.kind == 138) { + lexer.NextToken(); + +#line 2550 "cs.ATG" + ordering.Direction = QueryExpressionOrderingDirection.Ascending; + } else { + lexer.NextToken(); + +#line 2551 "cs.ATG" + ordering.Direction = QueryExpressionOrderingDirection.Descending; + } + } + +#line 2553 "cs.ATG" + ordering.EndLocation = t.EndLocation; + } + + + + void ParseRoot() + { + CS(); + + } + + protected override void SynErr(int line, int col, int errorNumber) + { + string s; + switch (errorNumber) { + case 0: s = "EOF expected"; break; + case 1: s = "ident expected"; break; + case 2: s = "Literal expected"; break; + case 3: s = "\"=\" expected"; break; + case 4: s = "\"+\" expected"; break; + case 5: s = "\"-\" expected"; break; + case 6: s = "\"*\" expected"; break; + case 7: s = "\"/\" expected"; break; + case 8: s = "\"%\" expected"; break; + case 9: s = "\":\" expected"; break; + case 10: s = "\"::\" expected"; break; + case 11: s = "\";\" expected"; break; + case 12: s = "\"?\" expected"; break; + case 13: s = "\"??\" expected"; break; + case 14: s = "\",\" expected"; break; + case 15: s = "\".\" expected"; break; + case 16: s = "\"{\" expected"; break; + case 17: s = "\"}\" expected"; break; + case 18: s = "\"[\" expected"; break; + case 19: s = "\"]\" expected"; break; + case 20: s = "\"(\" expected"; break; + case 21: s = "\")\" expected"; break; + case 22: s = "\">\" expected"; break; + case 23: s = "\"<\" expected"; break; + case 24: s = "\"!\" expected"; break; + case 25: s = "\"&&\" expected"; break; + case 26: s = "\"||\" expected"; break; + case 27: s = "\"~\" expected"; break; + case 28: s = "\"&\" expected"; break; + case 29: s = "\"|\" expected"; break; + case 30: s = "\"^\" expected"; break; + case 31: s = "\"++\" expected"; break; + case 32: s = "\"--\" expected"; break; + case 33: s = "\"==\" expected"; break; + case 34: s = "\"!=\" expected"; break; + case 35: s = "\">=\" expected"; break; + case 36: s = "\"<=\" expected"; break; + case 37: s = "\"<<\" expected"; break; + case 38: s = "\"+=\" expected"; break; + case 39: s = "\"-=\" expected"; break; + case 40: s = "\"*=\" expected"; break; + case 41: s = "\"/=\" expected"; break; + case 42: s = "\"%=\" expected"; break; + case 43: s = "\"&=\" expected"; break; + case 44: s = "\"|=\" expected"; break; + case 45: s = "\"^=\" expected"; break; + case 46: s = "\"<<=\" expected"; break; + case 47: s = "\"->\" expected"; break; + case 48: s = "\"=>\" expected"; break; + case 49: s = "\"abstract\" expected"; break; + case 50: s = "\"as\" expected"; break; + case 51: s = "\"base\" expected"; break; + case 52: s = "\"bool\" expected"; break; + case 53: s = "\"break\" expected"; break; + case 54: s = "\"byte\" expected"; break; + case 55: s = "\"case\" expected"; break; + case 56: s = "\"catch\" expected"; break; + case 57: s = "\"char\" expected"; break; + case 58: s = "\"checked\" expected"; break; + case 59: s = "\"class\" expected"; break; + case 60: s = "\"const\" expected"; break; + case 61: s = "\"continue\" expected"; break; + case 62: s = "\"decimal\" expected"; break; + case 63: s = "\"default\" expected"; break; + case 64: s = "\"delegate\" expected"; break; + case 65: s = "\"do\" expected"; break; + case 66: s = "\"double\" expected"; break; + case 67: s = "\"else\" expected"; break; + case 68: s = "\"enum\" expected"; break; + case 69: s = "\"event\" expected"; break; + case 70: s = "\"explicit\" expected"; break; + case 71: s = "\"extern\" expected"; break; + case 72: s = "\"false\" expected"; break; + case 73: s = "\"finally\" expected"; break; + case 74: s = "\"fixed\" expected"; break; + case 75: s = "\"float\" expected"; break; + case 76: s = "\"for\" expected"; break; + case 77: s = "\"foreach\" expected"; break; + case 78: s = "\"goto\" expected"; break; + case 79: s = "\"if\" expected"; break; + case 80: s = "\"implicit\" expected"; break; + case 81: s = "\"in\" expected"; break; + case 82: s = "\"int\" expected"; break; + case 83: s = "\"interface\" expected"; break; + case 84: s = "\"internal\" expected"; break; + case 85: s = "\"is\" expected"; break; + case 86: s = "\"lock\" expected"; break; + case 87: s = "\"long\" expected"; break; + case 88: s = "\"namespace\" expected"; break; + case 89: s = "\"new\" expected"; break; + case 90: s = "\"null\" expected"; break; + case 91: s = "\"object\" expected"; break; + case 92: s = "\"operator\" expected"; break; + case 93: s = "\"out\" expected"; break; + case 94: s = "\"override\" expected"; break; + case 95: s = "\"params\" expected"; break; + case 96: s = "\"private\" expected"; break; + case 97: s = "\"protected\" expected"; break; + case 98: s = "\"public\" expected"; break; + case 99: s = "\"readonly\" expected"; break; + case 100: s = "\"ref\" expected"; break; + case 101: s = "\"return\" expected"; break; + case 102: s = "\"sbyte\" expected"; break; + case 103: s = "\"sealed\" expected"; break; + case 104: s = "\"short\" expected"; break; + case 105: s = "\"sizeof\" expected"; break; + case 106: s = "\"stackalloc\" expected"; break; + case 107: s = "\"static\" expected"; break; + case 108: s = "\"string\" expected"; break; + case 109: s = "\"struct\" expected"; break; + case 110: s = "\"switch\" expected"; break; + case 111: s = "\"this\" expected"; break; + case 112: s = "\"throw\" expected"; break; + case 113: s = "\"true\" expected"; break; + case 114: s = "\"try\" expected"; break; + case 115: s = "\"typeof\" expected"; break; + case 116: s = "\"uint\" expected"; break; + case 117: s = "\"ulong\" expected"; break; + case 118: s = "\"unchecked\" expected"; break; + case 119: s = "\"unsafe\" expected"; break; + case 120: s = "\"ushort\" expected"; break; + case 121: s = "\"using\" expected"; break; + case 122: s = "\"virtual\" expected"; break; + case 123: s = "\"void\" expected"; break; + case 124: s = "\"volatile\" expected"; break; + case 125: s = "\"while\" expected"; break; + case 126: s = "\"partial\" expected"; break; + case 127: s = "\"where\" expected"; break; + case 128: s = "\"get\" expected"; break; + case 129: s = "\"set\" expected"; break; + case 130: s = "\"add\" expected"; break; + case 131: s = "\"remove\" expected"; break; + case 132: s = "\"yield\" expected"; break; + case 133: s = "\"select\" expected"; break; + case 134: s = "\"group\" expected"; break; + case 135: s = "\"by\" expected"; break; + case 136: s = "\"into\" expected"; break; + case 137: s = "\"from\" expected"; break; + case 138: s = "\"ascending\" expected"; break; + case 139: s = "\"descending\" expected"; break; + case 140: s = "\"orderby\" expected"; break; + case 141: s = "\"let\" expected"; break; + case 142: s = "\"join\" expected"; break; + case 143: s = "\"on\" expected"; break; + case 144: s = "\"equals\" expected"; break; + case 145: s = "??? expected"; break; + case 146: s = "invalid NamespaceMemberDecl"; break; + case 147: s = "invalid Identifier"; break; + case 148: s = "invalid NonArrayType"; break; + case 149: s = "invalid AttributeArgument"; break; + case 150: s = "invalid Expr"; break; + case 151: s = "invalid TypeModifier"; break; + case 152: s = "invalid TypeDecl"; break; + case 153: s = "invalid TypeDecl"; break; + case 154: s = "this symbol not expected in ClassBody"; break; + case 155: s = "this symbol not expected in InterfaceBody"; break; + case 156: s = "invalid IntegralType"; break; + case 157: s = "invalid ClassType"; break; + case 158: s = "invalid ClassMemberDecl"; break; + case 159: s = "invalid ClassMemberDecl"; break; + case 160: s = "invalid StructMemberDecl"; break; + case 161: s = "invalid StructMemberDecl"; break; + case 162: s = "invalid StructMemberDecl"; break; + case 163: s = "invalid StructMemberDecl"; break; + case 164: s = "invalid StructMemberDecl"; break; + case 165: s = "invalid StructMemberDecl"; break; + case 166: s = "invalid StructMemberDecl"; break; + case 167: s = "invalid StructMemberDecl"; break; + case 168: s = "invalid StructMemberDecl"; break; + case 169: s = "invalid StructMemberDecl"; break; + case 170: s = "invalid StructMemberDecl"; break; + case 171: s = "invalid StructMemberDecl"; break; + case 172: s = "invalid StructMemberDecl"; break; + case 173: s = "invalid InterfaceMemberDecl"; break; + case 174: s = "invalid InterfaceMemberDecl"; break; + case 175: s = "invalid InterfaceMemberDecl"; break; + case 176: s = "invalid TypeWithRestriction"; break; + case 177: s = "invalid TypeWithRestriction"; break; + case 178: s = "invalid SimpleType"; break; + case 179: s = "invalid AccessorModifiers"; break; + case 180: s = "this symbol not expected in Block"; break; + case 181: s = "invalid EventAccessorDecls"; break; + case 182: s = "invalid ConstructorInitializer"; break; + case 183: s = "invalid OverloadableOperator"; break; + case 184: s = "invalid AccessorDecls"; break; + case 185: s = "invalid InterfaceAccessors"; break; + case 186: s = "invalid InterfaceAccessors"; break; + case 187: s = "invalid GetAccessorDecl"; break; + case 188: s = "invalid SetAccessorDecl"; break; + case 189: s = "invalid VariableInitializer"; break; + case 190: s = "this symbol not expected in Statement"; break; + case 191: s = "invalid Statement"; break; + case 192: s = "invalid Argument"; break; + case 193: s = "invalid AssignmentOperator"; break; + case 194: s = "invalid ObjectPropertyInitializerOrVariableInitializer"; break; + case 195: s = "invalid ObjectPropertyInitializerOrVariableInitializer"; break; + case 196: s = "invalid EmbeddedStatement"; break; + case 197: s = "invalid EmbeddedStatement"; break; + case 198: s = "this symbol not expected in EmbeddedStatement"; break; + case 199: s = "invalid EmbeddedStatement"; break; + case 200: s = "invalid ForInitializer"; break; + case 201: s = "invalid GotoStatement"; break; + case 202: s = "invalid ResourceAcquisition"; break; + case 203: s = "invalid SwitchLabel"; break; + case 204: s = "invalid CatchClause"; break; + case 205: s = "invalid UnaryExpr"; break; + case 206: s = "invalid PrimaryExpr"; break; + case 207: s = "invalid PrimaryExpr"; break; + case 208: s = "invalid TypeArgumentList"; break; + case 209: s = "invalid NewExpression"; break; + case 210: s = "invalid NewExpression"; break; + case 211: s = "invalid LambdaExpressionParameter"; break; + case 212: s = "invalid LambdaExpressionBody"; break; + case 213: s = "invalid RelationalExpr"; break; + case 214: s = "invalid RelationalExpr"; break; + case 215: s = "invalid TypeParameterConstraintsClauseBase"; break; + case 216: s = "invalid QueryExpressionBody"; break; + + default: s = "error " + errorNumber; break; + } + this.Errors.Error(line, col, s); + } + + private bool StartOf(int s) + { + return set[s, lexer.LookAhead.kind]; + } + + static bool[,] set = { + {T,T,T,x, T,T,T,x, x,x,x,T, x,x,x,x, T,T,T,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,T, T,T,T,x, x,T,T,T, T,T,T,T, T,T,T,x, T,T,T,T, T,x,T,T, T,T,T,T, T,x,T,T, T,x,T,T, x,T,T,T, x,x,T,x, T,T,T,T, x,T,T,T, T,T,x,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, T,T,x,x, x,x,x,x, T,T,T,x, x,x,x,T, x,x,x,T, x,T,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,T,x,x, x,x,x,x, T,T,T,x, x,x,x,T, x,x,x,T, x,T,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,x,x, T,T,T,x, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,T,T,x, x,x,T,T, T,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,T,T,T, x,x,x,x, x,x,x,x, x,x,T,x, T,T,x,x, T,x,x,T, x,T,x,T, T,T,T,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,T,x,T, T,T,T,T, T,T,x,T, T,T,T,T, T,T,T,T, T,T,T,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, x,T,T,x, T,x,T,x, x,T,x,T, T,x,T,x, T,x,T,x, T,T,T,T, x,x,T,T, x,x,x,x, T,x,T,T, T,T,x,T, x,T,x,T, x,x,T,x, T,T,T,T, x,x,T,T, T,x,x,T, T,T,x,x, x,x,x,x, T,T,x,T, T,x,T,T, T,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, T,x,x,x, x,x,x,x, T,T,x,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,T, x,T,x,T, x,x,x,x, T,x,T,x, T,x,x,x, T,x,x,x, x,x,x,x, T,T,x,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,T,x, x,T,x,T, T,x,T,x, T,x,T,x, T,T,T,T, x,x,T,T, x,x,x,x, T,x,T,T, T,x,x,T, x,T,x,T, x,x,T,x, T,T,T,T, x,x,T,T, T,x,x,T, T,T,x,x, x,x,x,x, T,T,x,T, T,x,T,T, T,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,T,x, x,T,x,T, T,x,T,x, T,x,T,x, T,T,T,T, x,x,T,T, x,x,x,x, T,x,T,T, T,x,x,T, x,T,x,T, x,x,T,x, T,T,T,T, x,x,T,T, T,x,x,T, T,T,x,x, x,x,x,x, T,T,x,T, T,x,T,T, T,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,T,x, x,T,x,T, T,x,T,x, T,x,T,x, T,T,T,T, x,x,T,T, x,x,x,x, T,x,T,T, T,x,x,T, x,T,x,T, x,x,T,x, T,T,T,T, x,x,T,T, T,x,x,T, T,T,x,x, x,x,x,x, T,T,x,T, T,x,T,T, T,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,T,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,T,x,T, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, T,x,x,x, x,x,x,x, T,T,x,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,T,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,T,x,T, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, T,x,x,x, x,x,x,x, T,T,x,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,T,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, T,T,T,T, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,T, x,x,T,x, T,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,T, T,x,T,x, T,x,T,x, T,T,T,x, x,x,x,T, x,x,x,x, T,x,T,T, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, T,T,x,x, x,x,x,x, T,T,x,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,T,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, T,x,x,x, x,x,x,x, T,T,x,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,T,T,x, T,T,T,x, x,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,x, x,T,T,x, T,T,T,T, T,T,T,x, x,x,x,x, T,x,T,T, T,T,T,T, x,x,T,x, x,x,T,T, x,T,T,T, x,x,x,x, x,x,x,x, x,T,T,x, T,T,x,x, T,x,T,T, T,T,T,T, T,T,T,T, T,T,x,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,T,T,x, x,x,T,T, T,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,T,T,T, x,T,x,x, x,x,x,x, T,x,T,x, T,T,x,x, T,x,x,T, x,T,x,T, T,T,T,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {T,T,T,x, T,T,T,x, x,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,x, x,T,T,x, T,T,T,T, T,T,T,x, x,x,x,x, T,x,T,T, T,T,T,T, x,x,T,x, x,x,T,T, x,T,T,T, x,x,x,x, x,x,x,x, x,T,T,x, T,T,x,x, T,x,T,T, T,T,T,T, T,T,T,T, T,T,x,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,T,T,x, T,T,T,x, x,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,x, x,T,T,x, x,T,T,T, T,T,T,x, x,x,x,x, T,x,T,T, T,T,T,T, x,x,T,x, x,x,T,T, x,T,T,T, x,x,x,x, x,x,x,x, x,T,T,x, T,T,x,x, T,x,T,T, T,T,T,T, T,T,T,T, T,T,x,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,x, T,x,x,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,T,T,x, x,x,T,T, T,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,T,T,T, x,x,x,x, x,x,x,x, x,x,T,x, T,T,T,x, T,x,x,T, x,T,x,T, T,T,T,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,T,T,x, T,T,T,x, x,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, x,T,T,x, T,T,T,T, T,T,T,x, x,x,x,x, T,x,T,T, T,T,T,T, x,x,T,x, x,x,T,T, x,T,T,T, x,x,x,x, x,x,x,x, x,T,T,x, T,T,x,x, T,x,T,T, T,T,T,T, T,T,T,T, T,T,x,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,x,x,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,T,T,x, x,x,T,T, T,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,T,T,T, x,x,x,x, x,x,x,x, x,x,T,x, T,T,x,x, T,x,x,T, x,T,x,T, T,T,T,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, T,x,x,x, x,x,x,x, T,T,x,x, T,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,T, x,T,x,x, x,x,x,x, T,x,T,x, T,x,x,x, T,x,x,x, x,x,x,x, T,T,x,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, T,T,T,x, x,x,x} + + }; +} // end Parser + +} \ No newline at end of file diff --git a/Project/Src/Parser/CSharp/cs.ATG b/Project/Src/Parser/CSharp/cs.ATG new file mode 100644 index 0000000000..f95c0f01af --- /dev/null +++ b/Project/Src/Parser/CSharp/cs.ATG @@ -0,0 +1,2622 @@ +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Text; +using ICSharpCode.NRefactory.Parser; +using ICSharpCode.NRefactory.Ast; +using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute; +using Types = ICSharpCode.NRefactory.Ast.ClassType; + +COMPILER CS /* AW 2002-12-30 renamed from CompilationUnit to CS */ + + +/*------------------------------------------------------------------------* + *----- LEXER TOKEN LIST ------------------------------------------------* + *------------------------------------------------------------------------*/ + +/* START AUTOGENERATED TOKENS SECTION */ +TOKENS + /* ----- terminal classes ----- */ + /* EOF is 0 */ + ident + Literal + + /* ----- special character ----- */ + "=" + "+" + "-" + "*" + "/" + "%" + ":" + "::" + ";" + "?" + "??" + "," + "." + "{" + "}" + "[" + "]" + "(" + ")" + ">" + "<" + "!" + "&&" + "||" + "~" + "&" + "|" + "^" + "++" + "--" + "==" + "!=" + ">=" + "<=" + "<<" + "+=" + "-=" + "*=" + "/=" + "%=" + "&=" + "|=" + "^=" + "<<=" + "->" + "=>" + + /* ----- keywords ----- */ + "abstract" + "as" + "base" + "bool" + "break" + "byte" + "case" + "catch" + "char" + "checked" + "class" + "const" + "continue" + "decimal" + "default" + "delegate" + "do" + "double" + "else" + "enum" + "event" + "explicit" + "extern" + "false" + "finally" + "fixed" + "float" + "for" + "foreach" + "goto" + "if" + "implicit" + "in" + "int" + "interface" + "internal" + "is" + "lock" + "long" + "namespace" + "new" + "null" + "object" + "operator" + "out" + "override" + "params" + "private" + "protected" + "public" + "readonly" + "ref" + "return" + "sbyte" + "sealed" + "short" + "sizeof" + "stackalloc" + "static" + "string" + "struct" + "switch" + "this" + "throw" + "true" + "try" + "typeof" + "uint" + "ulong" + "unchecked" + "unsafe" + "ushort" + "using" + "virtual" + "void" + "volatile" + "while" + "partial" + "where" + "get" + "set" + "add" + "remove" + "yield" + "select" + "group" + "by" + "into" + "from" + "ascending" + "descending" + "orderby" + "let" + "join" + "on" + "equals" +/* END AUTOGENERATED TOKENS SECTION */ + +/*------------------------------------------------------------------------* + *----- PARSER -----------------------------------------------------------* + *------------------------------------------------------------------------*/ + +PRODUCTIONS + +/*--- compilation unit: */ +CS + (. + lexer.NextToken(); // get the first token + compilationUnit = new CompilationUnit(); + BlockStart(compilationUnit); + .) += + { ExternAliasDirective } + { UsingDirective } + { IF (IsGlobalAttrTarget()) GlobalAttributeSection } + { NamespaceMemberDecl } + EOF +. + +UsingDirective +(. + string qualident = null; TypeReference aliasedType = null; + string alias = null; +.) += + "using" (. Location startPos = t.Location; .) + [ IF (IdentAndDoubleColon()) Identifier (. alias = t.val; .) "::" ] + Qualident + [ "=" NonArrayType ] + ";" (. + if (qualident != null && qualident.Length > 0) { + string name = (alias != null && alias != "global") ? alias + "." + qualident : qualident; + INode node; + if (aliasedType != null) { + node = new UsingDeclaration(name, aliasedType); + } else { + node = new UsingDeclaration(name); + } + node.StartLocation = startPos; + node.EndLocation = t.EndLocation; + AddChild(node); + } + .) +. + +GlobalAttributeSection += + "[" (. Location startPos = t.Location; .) Identifier + (. if (t.val != "assembly" && t.val != "module") Error("global attribute target specifier (assembly or module) expected"); + string attributeTarget = t.val; + List attributes = new List(); + ASTAttribute attribute; + .) + ":" Attribute (. attributes.Add(attribute); .) + { IF (NotFinalComma()) "," Attribute (. attributes.Add(attribute); .)} + [ "," ] + "]" (. AttributeSection section = new AttributeSection { + AttributeTarget = attributeTarget, + Attributes = attributes, + StartLocation = startPos, + EndLocation = t.EndLocation + }; + AddChild(section); + .) +. + +Attribute +(. string qualident; + string alias = null; +.) += + (. Location startPos = la.Location; .) + [ IF (IdentAndDoubleColon()) + Identifier (. alias = t.val; .) + "::" + ] + Qualident + (. List positional = new List(); + List named = new List(); + string name = (alias != null && alias != "global") ? alias + "." + qualident : qualident; + .) + [ AttributeArguments ] + (. attribute = new ASTAttribute(name, positional, named); + attribute.StartLocation = startPos; + attribute.EndLocation = t.EndLocation; + .) +. + +AttributeArguments positional, List named> += + "(" + [ + AttributeArgument + { + "," + AttributeArgument + } + ] + ")" +. + +AttributeArgument positional, List named> +(. string name = null; bool isNamed = false; Expression expr; Location startLocation = la.Location; .) += + ( + IF (IsAssignment()) (. isNamed = true; .) + Identifier (. name = t.val; .) + "=" + | + IF (IdentAndColon()) + Identifier (. name = t.val; .) + ":" + | /* empty */ + ) + Expr + (. + if (expr != null) { + if (isNamed) { + named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }); + } else { + if (named.Count > 0) + Error("positional argument after named argument is not allowed"); + if (name != null) + expr = new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + positional.Add(expr); + } + } + .) +. + +AttributeSection +(. + string attributeTarget = ""; + List attributes = new List(); + ASTAttribute attribute; + +.) += + "[" (. Location startPos = t.Location; .) /*--- attribute target specifier: */ + [ IF (IsLocalAttrTarget()) + ( "event" (. attributeTarget = "event";.) + | "return" (. attributeTarget = "return";.) + | Identifier (. attributeTarget = t.val; .) + ) ":" + ] + /*--- attribute list: */ + Attribute (. attributes.Add(attribute); .) + { IF (NotFinalComma()) "," Attribute (. attributes.Add(attribute); .)} + [ "," ] + "]" (. section = new AttributeSection { + AttributeTarget = attributeTarget, + Attributes = attributes, + StartLocation = startPos, + EndLocation = t.EndLocation + }; + .) +. + +NamespaceMemberDecl +(. + AttributeSection section; + List attributes = new List(); + ModifierList m = new ModifierList(); + string qualident; +.) += /*--- namespace declaration: */ + "namespace" (. Location startPos = t.Location; .) + Qualident (. INode node = new NamespaceDeclaration(qualident); + node.StartLocation = startPos; + AddChild(node); + BlockStart(node); + .) + "{" + { ExternAliasDirective } + { UsingDirective } + { NamespaceMemberDecl } + "}" + [ ";" ] (. node.EndLocation = t.EndLocation; + BlockEnd(); + .) + /*--- type declaration: */ +| { AttributeSection (. attributes.Add(section); .) } + { TypeModifier } + TypeDecl +. + +ExternAliasDirective +(. ExternAliasDirective ead = new ExternAliasDirective { StartLocation = la.Location }; .) += + "extern" + Identifier (. if (t.val != "alias") Error("Expected 'extern alias'."); .) + Identifier (. ead.Name = t.val; .) + ";" (. ead.EndLocation = t.EndLocation; .) + (. AddChild(ead); .) +. + +TypeDecl attributes> +(. + TypeReference type; + List names; + List p = new List(); + string name; + List templates; +.) += /*--- class declaration: */ (. m.Check(Modifiers.Classes); .) + "class" (. TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + templates = newType.Templates; + AddChild(newType); + BlockStart(newType); + newType.StartLocation = m.GetDeclarationLocation(t.Location); + + newType.Type = Types.Class; + .) + Identifier (. newType.Name = t.val; .) + + /* .NET 2.0 */ + [ TypeParameterList ] + + [ ClassBase (. newType.BaseTypes = names; .) ] + + /* .NET 2.0 */ + { TypeParameterConstraintsClause } + + (. newType.BodyStartLocation = t.EndLocation; .) + "{" + ClassBody + "}" + [ ";" ] (. newType.EndLocation = t.EndLocation; + BlockEnd(); + .) +| /*--- struct declaration: */ (. m.Check(Modifiers.StructsInterfacesEnumsDelegates); .) + ( "struct" (. TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + templates = newType.Templates; + newType.StartLocation = m.GetDeclarationLocation(t.Location); + AddChild(newType); + BlockStart(newType); + newType.Type = Types.Struct; + .) + Identifier (. newType.Name = t.val; .) + + /* .NET 2.0 */ + [ TypeParameterList ] + + [ StructInterfaces (. newType.BaseTypes = names; .) ] + + /* .NET 2.0 */ + { TypeParameterConstraintsClause } + + + (. newType.BodyStartLocation = t.EndLocation; .) + StructBody + [ ";" ] (. newType.EndLocation = t.EndLocation; + BlockEnd(); + .) +| /*--- interface declaration: */ + "interface" (. TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + templates = newType.Templates; + AddChild(newType); + BlockStart(newType); + newType.StartLocation = m.GetDeclarationLocation(t.Location); + newType.Type = Types.Interface; + .) + Identifier (. newType.Name = t.val; .) + + /* .NET 2.0 */ + [ TypeParameterList ] + + [ InterfaceBase (. newType.BaseTypes = names; .) ] + + /* .NET 2.0 */ + { TypeParameterConstraintsClause } + + (. newType.BodyStartLocation = t.EndLocation; .) + InterfaceBody + [ ";" ] (. newType.EndLocation = t.EndLocation; + BlockEnd(); + .) +| /*--- enumeration declaration: */ + "enum" (. TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + AddChild(newType); + BlockStart(newType); + newType.StartLocation = m.GetDeclarationLocation(t.Location); + newType.Type = Types.Enum; + .) + Identifier (. newType.Name = t.val; .) + [ ":" IntegralType (. newType.BaseTypes.Add(new TypeReference(name, true)); .) + ] + (. newType.BodyStartLocation = t.EndLocation; .) + EnumBody + [ ";" ] (. newType.EndLocation = t.EndLocation; + BlockEnd(); + .) +| /*--- delegate declaration: */ + "delegate" (. DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes); + templates = delegateDeclr.Templates; + delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location); + .) + ( IF (NotVoidPointer()) "void" (. delegateDeclr.ReturnType = new TypeReference("System.Void", true); .) + | Type (. delegateDeclr.ReturnType = type; .) + ) + Identifier (. delegateDeclr.Name = t.val; .) + + /* .NET 2.0 */ + [ TypeParameterList ] + + "(" [ FormalParameterList

(. delegateDeclr.Parameters = p; .) + ] ")" + + /* .NET 2.0 */ + { TypeParameterConstraintsClause } + + ";" (. delegateDeclr.EndLocation = t.EndLocation; + AddChild(delegateDeclr); + .) + ) +. + +Qualident += + Identifier (. qualidentBuilder.Length = 0; qualidentBuilder.Append(t.val); .) + { IF (DotAndIdent()) "." Identifier (. qualidentBuilder.Append('.'); + qualidentBuilder.Append(t.val); + .) + } (. qualident = qualidentBuilder.ToString(); .) +. + +ClassBase names> +(. + TypeReference typeRef; + names = new List(); +.) += + ":" ClassType (. if (typeRef != null) { names.Add(typeRef); } .) + { "," TypeName (. if (typeRef != null) { names.Add(typeRef); } .) } +. + +ClassBody +(. AttributeSection section; .) += + { (.List attributes = new List(); + ModifierList m = new ModifierList(); + .) + SYNC + { AttributeSection (. attributes.Add(section); .) } + MemberModifiers + ClassMemberDecl + } +. + +StructInterfaces names> +(. + TypeReference typeRef; + names = new List(); +.) += + ":" TypeName (. if (typeRef != null) { names.Add(typeRef); } .) + { "," TypeName (. if (typeRef != null) { names.Add(typeRef); } .) } +. + +StructBody +(. AttributeSection section; .) += + "{" + { (.List attributes = new List(); + ModifierList m = new ModifierList(); + .) + { AttributeSection (. attributes.Add(section); .) } + MemberModifiers + StructMemberDecl + } + "}" +. + +InterfaceBase names> +(. + TypeReference typeRef; + names = new List(); +.) += + ":" TypeName (. if (typeRef != null) { names.Add(typeRef); } .) + { "," TypeName (. if (typeRef != null) { names.Add(typeRef); } .) } +. + +InterfaceBody += "{" + { SYNC InterfaceMemberDecl } + "}" +. + +EnumBody (. FieldDeclaration f; .) += + "{" + [ EnumMemberDecl (. AddChild(f); .) + { IF (NotFinalComma()) "," + EnumMemberDecl (. AddChild(f); .) + } + [","] ] + "}" +. + +Type += + TypeWithRestriction +. + +TypeWithRestriction +(. + Location startPos = la.Location; + string name; + int pointer = 0; + type = null; +.) += + ( ClassType + | SimpleType (. type = new TypeReference(name, true); type.StartLocation = startPos; type.EndLocation = t.EndLocation; .) + | "void" "*" (. pointer = 1; type = new TypeReference("System.Void", true); type.StartLocation = startPos; type.EndLocation = t.EndLocation; .) + ) (. List r = new List(); .) + + [ IF (allowNullable && la.kind == Tokens.Question) NullableQuestionMark ] + + { IF (IsPointerOrDims()) (. int i = 0; .) + ( "*" (. ++pointer; .) + | "[" { "," (. ++i; .) } "]" (. r.Add(i); .) + ) + } + (. if (type != null) { + type.RankSpecifier = r.ToArray(); + type.PointerNestingLevel = pointer; + type.EndLocation = t.EndLocation; + type.StartLocation = startPos; + } + .) +. + + +NonArrayType +(. + Location startPos = la.Location; + string name; + int pointer = 0; + type = null; +.) += + ( ClassType + | SimpleType (. type = new TypeReference(name, true); .) + | "void" "*" (. pointer = 1; type = new TypeReference("System.Void", true); .) + ) + + [ NullableQuestionMark ] + + { IF (IsPointer()) + "*" (. ++pointer; .) + } + (.if (type != null) { + type.PointerNestingLevel = pointer; + type.EndLocation = t.EndLocation; + type.StartLocation = startPos; + } + .) +. + +SimpleType +(. name = String.Empty; .) += + IntegralType + | "float" (. name = "System.Single"; .) + | "double" (. name = "System.Double"; .) + | "decimal" (. name = "System.Decimal"; .) + | "bool" (. name = "System.Boolean"; .) +. + + +FormalParameterList parameter> +(. + + ParameterDeclarationExpression p; + AttributeSection section; + List attributes = new List(); +.) += + { AttributeSection (.attributes.Add(section); .) } + FixedParameter (. p.Attributes = attributes; + parameter.Add(p); + .) + { + "," (. attributes = new List(); .) + { AttributeSection (.attributes.Add(section); .) } + FixedParameter (. p.Attributes = attributes; parameter.Add(p); .) + } +. + +FixedParameter +(. + TypeReference type; + ParameterModifiers mod = ParameterModifiers.In; + Location start = la.Location; + Expression expr; +.) += + [ + "ref" (. mod = ParameterModifiers.Ref; .) + | "out" (. mod = ParameterModifiers.Out; .) + | "params" (. mod = ParameterModifiers.Params; .) + ] + Type + Identifier (. p = new ParameterDeclarationExpression(type, t.val, mod); .) + [ "=" Expr (. p.DefaultValue = expr; p.ParamModifier |= ParameterModifiers.Optional; .) ] + (. p.StartLocation = start; p.EndLocation = t.EndLocation; .) +. + +AccessorModifiers +(. m = new ModifierList(); .) += + "private" (. m.Add(Modifiers.Private, t.Location); .) + | "protected" (. m.Add(Modifiers.Protected, t.Location); .) + ["internal" (. m.Add(Modifiers.Internal, t.Location); .)] + | "internal" (. m.Add(Modifiers.Internal, t.Location); .) + ["protected" (. m.Add(Modifiers.Protected, t.Location); .)] +. + +TypeModifier += + "new" (. m.Add(Modifiers.New, t.Location); .) + | "public" (. m.Add(Modifiers.Public, t.Location); .) + | "protected" (. m.Add(Modifiers.Protected, t.Location); .) + | "internal" (. m.Add(Modifiers.Internal, t.Location); .) + | "private" (. m.Add(Modifiers.Private, t.Location); .) + | "unsafe" (. m.Add(Modifiers.Unsafe, t.Location); .) + | "abstract" (. m.Add(Modifiers.Abstract, t.Location); .) + | "sealed" (. m.Add(Modifiers.Sealed, t.Location); .) + | "static" (. m.Add(Modifiers.Static, t.Location); .) + | "partial" (. m.Add(Modifiers.Partial, t.Location); .) +. + +ClassType +(. TypeReference r; typeRef = null; .) += + TypeName (. typeRef = r; .) + | "object" (. typeRef = new TypeReference("System.Object", true); typeRef.StartLocation = t.Location; typeRef.EndLocation = t.EndLocation; .) + | "string" (. typeRef = new TypeReference("System.String", true); typeRef.StartLocation = t.Location; typeRef.EndLocation = t.EndLocation; .) +. + +IntegralType (. name = ""; .) += + "sbyte" (. name = "System.SByte"; .) + | "byte" (. name = "System.Byte"; .) + | "short" (. name = "System.Int16"; .) + | "ushort" (. name = "System.UInt16"; .) + | "int" (. name = "System.Int32"; .) + | "uint" (. name = "System.UInt32"; .) + | "long" (. name = "System.Int64"; .) + | "ulong" (. name = "System.UInt64"; .) + | "char" (. name = "System.Char"; .) +. + +MemberModifiers += + { + "abstract" (. m.Add(Modifiers.Abstract, t.Location); .) + | "extern" (. m.Add(Modifiers.Extern, t.Location); .) + | "internal" (. m.Add(Modifiers.Internal, t.Location); .) + | "new" (. m.Add(Modifiers.New, t.Location); .) + | "override" (. m.Add(Modifiers.Override, t.Location); .) + | "private" (. m.Add(Modifiers.Private, t.Location); .) + | "protected" (. m.Add(Modifiers.Protected, t.Location); .) + | "public" (. m.Add(Modifiers.Public, t.Location); .) + | "readonly" (. m.Add(Modifiers.ReadOnly, t.Location); .) + | "sealed" (. m.Add(Modifiers.Sealed, t.Location); .) + | "static" (. m.Add(Modifiers.Static, t.Location); .) + | "fixed" (. m.Add(Modifiers.Fixed, t.Location); .) + | "unsafe" (. m.Add(Modifiers.Unsafe, t.Location); .) + | "virtual" (. m.Add(Modifiers.Virtual, t.Location); .) + | "volatile" (. m.Add(Modifiers.Volatile, t.Location); .) + | "partial" (. m.Add(Modifiers.Partial, t.Location); .) + } +. + +StructMemberDecl attributes> +(. + string qualident = null; + TypeReference type; + Expression expr; + List p = new List(); + BlockStatement stmt = null; + List templates = new List(); + TypeReference explicitInterface = null; + bool isExtensionMethod = false; +.) += + /*--- constant declaration: */ (. m.Check(Modifiers.Constants); .) + "const" (.Location startPos = t.Location; .) + Type Identifier (. FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifiers.Const); + fd.StartLocation = m.GetDeclarationLocation(startPos); + VariableDeclaration f = new VariableDeclaration(t.val); + f.StartLocation = t.Location; + f.TypeReference = type; + SafeAdd(fd, fd.Fields, f); + .) + "=" Expr (. f.Initializer = expr; .) + { "," Identifier (. f = new VariableDeclaration(t.val); + f.StartLocation = t.Location; + f.TypeReference = type; + SafeAdd(fd, fd.Fields, f); + .) + "=" Expr (. f.EndLocation = t.EndLocation; f.Initializer = expr; .) + } ";" (. fd.EndLocation = t.EndLocation; AddChild(fd); .) + + +| /*--- void method (procedure) declaration: */ + IF (NotVoidPointer()) (. m.Check(Modifiers.PropertysEventsMethods); .) + "void" (. Location startPos = t.Location; .) + ( IF (IsExplicitInterfaceImplementation()) + TypeName + (.if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { + qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); + } .) + | Identifier (. qualident = t.val; .) + ) + /* .NET 2.0 */ + [ TypeParameterList ] + + "(" + [ "this" (. isExtensionMethod = true; /* C# 3.0 */ .) ] + [ FormalParameterList

] ")" + (. MethodDeclaration methodDeclaration = new MethodDeclaration { + Name = qualident, + Modifier = m.Modifier, + TypeReference = new TypeReference("System.Void", true), + Parameters = p, + Attributes = attributes, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = t.EndLocation, + Templates = templates, + IsExtensionMethod = isExtensionMethod + }; + if (explicitInterface != null) + SafeAdd(methodDeclaration, methodDeclaration.InterfaceImplementations, new InterfaceImplementation(explicitInterface, qualident)); + AddChild(methodDeclaration); + BlockStart(methodDeclaration); + .) + + /* .NET 2.0 */ + { TypeParameterConstraintsClause } + + ( Block | ";" ) (. BlockEnd(); + methodDeclaration.Body = (BlockStatement)stmt; + .) + +| /*--- event declaration: */ (. m.Check(Modifiers.PropertysEventsMethods); .) + "event" + (. EventDeclaration eventDecl = new EventDeclaration { + Modifier = m.Modifier, + Attributes = attributes, + StartLocation = t.Location + }; + AddChild(eventDecl); + BlockStart(eventDecl); + EventAddRegion addBlock = null; + EventRemoveRegion removeBlock = null; + .) + Type (. eventDecl.TypeReference = type; .) + ( IF (IsExplicitInterfaceImplementation()) + TypeName + (. qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); .) + (. eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); .) + + | Identifier (. qualident = t.val; .) + [ "=" Expr (. eventDecl.Initializer = expr; .) ] + { "," /* multiple event declarations on single line */ + /* our AST isn't built to handle this, so let's create multiple overlapping EventDeclarations */ + /* commit the current EventDeclaration */ + (. eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; BlockEnd(); .) + /* create a new EventDeclaration for the next identifier */ + (. eventDecl = new EventDeclaration { + Modifier = eventDecl.Modifier, + Attributes = eventDecl.Attributes, + StartLocation = eventDecl.StartLocation, + TypeReference = eventDecl.TypeReference.Clone() + }; + AddChild(eventDecl); + BlockStart(eventDecl); + .) + Identifier (. qualident = t.val; .) + [ "=" Expr (. eventDecl.Initializer = expr; .) ] + } + ) + (. eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; .) + [ "{" (. eventDecl.BodyStart = t.Location; .) + EventAccessorDecls + "}" (. eventDecl.BodyEnd = t.EndLocation; .) + ] + [ ";" ] + (. BlockEnd(); + eventDecl.AddRegion = addBlock; + eventDecl.RemoveRegion = removeBlock; + .) + +| /*--- constructor or static contructor declaration: */ + IF (IdentAndLPar()) (. m.Check(Modifiers.Constructors | Modifiers.StaticConstructors); .) + Identifier (. string name = t.val; Location startPos = t.Location; .) "(" [ (. m.Check(Modifiers.Constructors); .) + FormalParameterList

+ ] + ")" (.ConstructorInitializer init = null; .) + [ (. m.Check(Modifiers.Constructors); .) + ConstructorInitializer + ] (. + ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); + cd.StartLocation = startPos; + cd.EndLocation = t.EndLocation; + .) + + ( Block | ";" ) (. cd.Body = (BlockStatement)stmt; AddChild(cd); .) + + +| /*--- conversion operator declaration: */ (. m.Check(Modifiers.Operators); + if (m.isNone) Error("at least one modifier must be set"); + bool isImplicit = true; + Location startPos = Location.Empty; + .) + ( "implicit" (. startPos = t.Location; .) | "explicit" (. isImplicit = false; startPos = t.Location; .) ) + "operator" Type (. TypeReference operatorType = type; .) + "(" Type Identifier (. string varName = t.val; .) ")" + (. Location endPos = t.Location; .) + ( Block | ";" (. stmt = null; .) ) + (. + + List parameters = new List(); + parameters.Add(new ParameterDeclarationExpression(type, varName)); + OperatorDeclaration operatorDeclaration = new OperatorDeclaration { + Name = (isImplicit ? "op_Implicit" : "op_Explicit"), + Modifier = m.Modifier, + Attributes = attributes, + Parameters = parameters, + TypeReference = operatorType, + ConversionType = isImplicit ? ConversionType.Implicit : ConversionType.Explicit, + Body = (BlockStatement)stmt, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = endPos + }; + AddChild(operatorDeclaration); + .) + + +| /*--- inner type declaration: */ + TypeDecl + +| Type (. Location startPos = t.Location; .) + ( + /*--- operator declaration: */ (. OverloadableOperatorType op; + m.Check(Modifiers.Operators); + if (m.isNone) Error("at least one modifier must be set"); + .) + "operator" OverloadableOperator (. TypeReference firstType, secondType = null; string secondName = null; .) + "(" (. Location firstStart = la.Location, secondStart = Location.Empty, secondEnd = Location.Empty; .) Type Identifier (. string firstName = t.val; Location firstEnd = t.EndLocation; .) + ( "," (. secondStart = la.Location; .) Type Identifier (. secondName = t.val; secondEnd = t.EndLocation; .) /* (. if (Tokens.OverloadableUnaryOp[op.kind] && !Tokens.OverloadableBinaryOp[op.kind]) + Error("too many operands for unary operator"); + .)*/ + | /* empty */ /*(. if (Tokens.OverloadableBinaryOp[op.kind]){ + Error("too few operands for binary operator"); + } + .)*/ + ) + (. Location endPos = t.Location; .) + ")" ( Block | ";" ) + (. + if (op == OverloadableOperatorType.Add && secondType == null) + op = OverloadableOperatorType.UnaryPlus; + if (op == OverloadableOperatorType.Subtract && secondType == null) + op = OverloadableOperatorType.UnaryMinus; + OperatorDeclaration operatorDeclaration = new OperatorDeclaration { + Modifier = m.Modifier, + Attributes = attributes, + TypeReference = type, + OverloadableOperator = op, + Name = GetReflectionNameForOperator(op), + Body = (BlockStatement)stmt, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = endPos + }; + SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(firstType, firstName) { StartLocation = firstStart, EndLocation = firstEnd }); + if (secondType != null) { + SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(secondType, secondName) { StartLocation = secondStart, EndLocation = secondEnd }); + } + AddChild(operatorDeclaration); + .) + + /*--- field declaration: */ + | IF (IsVarDecl()) + (. m.Check(Modifiers.Fields); + FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); + fd.StartLocation = m.GetDeclarationLocation(startPos); + .) + ( IF (m.Contains(Modifiers.Fixed)) + VariableDeclarator + "[" + Expr (. if (fd.Fields.Count > 0) + fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; .) + "]" + { "," + VariableDeclarator + "[" + Expr (. if (fd.Fields.Count > 0) + fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; .) + "]" + } + | /* non-fixed field */ + VariableDeclarator + { "," VariableDeclarator } + ) + ";" (. fd.EndLocation = t.EndLocation; AddChild(fd); .) + + /*--- unqualified indexer declaration (without interface name): */ + | (. m.Check(Modifiers.Indexers); .) + "this" "[" FormalParameterList

"]" (. Location endLocation = t.EndLocation; .) "{" (. + PropertyDeclaration indexer = new PropertyDeclaration(m.Modifier | Modifiers.Default, attributes, "Item", p); + indexer.StartLocation = startPos; + indexer.EndLocation = endLocation; + indexer.BodyStart = t.Location; + indexer.TypeReference = type; + PropertyGetRegion getRegion; + PropertySetRegion setRegion; + .) + AccessorDecls "}" (. + indexer.BodyEnd = t.EndLocation; + indexer.GetRegion = getRegion; + indexer.SetRegion = setRegion; + AddChild(indexer); + .) + | IF (IsIdentifierToken(la)) + ( IF (IsExplicitInterfaceImplementation()) + TypeName + (.if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { + qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); + } .) + | Identifier (. qualident = t.val; .) + ) + (. Location qualIdentEndLocation = t.EndLocation; .) + + ( + /*--- "not void" method (function) declaration: */ + ( (. m.Check(Modifiers.PropertysEventsMethods); .) + /* .NET 2.0 */ + [ TypeParameterList ] + "(" + [ "this" (. isExtensionMethod = true; .) ] + [ FormalParameterList

] ")" + (. + MethodDeclaration methodDeclaration = new MethodDeclaration { + Name = qualident, + Modifier = m.Modifier, + TypeReference = type, + Parameters = p, + Attributes = attributes + }; + if (explicitInterface != null) + methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); + methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); + methodDeclaration.EndLocation = t.EndLocation; + methodDeclaration.IsExtensionMethod = isExtensionMethod; + methodDeclaration.Templates = templates; + AddChild(methodDeclaration); + .) + { TypeParameterConstraintsClause } + ( Block | ";" ) (. methodDeclaration.Body = (BlockStatement)stmt; .) + + /*--- property declaration: */ + | "{" (. PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); + if (explicitInterface != null) + pDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); + pDecl.StartLocation = m.GetDeclarationLocation(startPos); + pDecl.EndLocation = qualIdentEndLocation; + pDecl.BodyStart = t.Location; + PropertyGetRegion getRegion; + PropertySetRegion setRegion; + .) + AccessorDecls + "}" (. + pDecl.GetRegion = getRegion; + pDecl.SetRegion = setRegion; + pDecl.BodyEnd = t.EndLocation; + AddChild(pDecl); + .) + ) + + /*--- qualified indexer declaration (with interface name): */ + | (. m.Check(Modifiers.Indexers); .) + "." "this" "[" FormalParameterList

"]" (. + PropertyDeclaration indexer = new PropertyDeclaration(m.Modifier | Modifiers.Default, attributes, "Item", p); + indexer.StartLocation = m.GetDeclarationLocation(startPos); + indexer.EndLocation = t.EndLocation; + indexer.TypeReference = type; + if (explicitInterface != null) + SafeAdd(indexer, indexer.InterfaceImplementations, new InterfaceImplementation(explicitInterface, "this")); + PropertyGetRegion getRegion; + PropertySetRegion setRegion; + .) + "{" (. Location bodyStart = t.Location; .) + AccessorDecls + "}" (. indexer.BodyStart = bodyStart; + indexer.BodyEnd = t.EndLocation; + indexer.GetRegion = getRegion; + indexer.SetRegion = setRegion; + AddChild(indexer); + .) + ) + ) +. + +ClassMemberDecl attributes> +(. BlockStatement stmt = null; .) += + StructMemberDecl + | /*--- destructor declaration: */ (. m.Check(Modifiers.Destructors); Location startPos = la.Location; .) + "~" Identifier (. DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); + d.Modifier = m.Modifier; + d.StartLocation = m.GetDeclarationLocation(startPos); + .) + "(" ")" (. d.EndLocation = t.EndLocation; .) ( Block | ";" ) (. + d.Body = stmt; + AddChild(d); + .) +. + +InterfaceMemberDecl +(. + TypeReference type; + + AttributeSection section; + Modifiers mod = Modifiers.None; + List attributes = new List(); + List parameters = new List(); + string name; + PropertyGetRegion getBlock; + PropertySetRegion setBlock; + Location startLocation = new Location(-1, -1); + List templates = new List(); +.) += + { AttributeSection (. attributes.Add(section); .)} + [ "new" (. mod = Modifiers.New; startLocation = t.Location; .) ] + ( + /*--- interface void method (procedure) declaration: */ + IF (NotVoidPointer()) "void" (. if (startLocation.IsEmpty) startLocation = t.Location; .) + Identifier (. name = t.val; .) + [ TypeParameterList ] + "(" [ FormalParameterList ] ")" + { TypeParameterConstraintsClause } + ";" + (. MethodDeclaration md = new MethodDeclaration { + Name = name, Modifier = mod, TypeReference = new TypeReference("System.Void", true), + Parameters = parameters, Attributes = attributes, Templates = templates, + StartLocation = startLocation, EndLocation = t.EndLocation + }; + AddChild(md); + .) + | ( + Type (. if (startLocation.IsEmpty) startLocation = t.Location; .) + ( + Identifier (. name = t.val; Location qualIdentEndLocation = t.EndLocation; .) + ( + /*--- interface "not void" method (function) declaration: */ + /* .NET 2.0 */ + [ TypeParameterList ] + "(" [ FormalParameterList ] ")" + /* .NET 2.0 */ + { TypeParameterConstraintsClause } + ";" (. MethodDeclaration md = new MethodDeclaration { + Name = name, Modifier = mod, TypeReference = type, + Parameters = parameters, Attributes = attributes, Templates = templates, + StartLocation = startLocation, EndLocation = t.EndLocation + }; + AddChild(md); + .) + /*--- interface property declaration: */ + | + (. PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); + AddChild(pd); .) + "{" + (. Location bodyStart = t.Location;.) + InterfaceAccessors + "}" (. pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; .) + ) + /*--- interface indexer declaration: */ + | "this" "[" FormalParameterList "]" + (. Location bracketEndLocation = t.EndLocation; .) + (. PropertyDeclaration id = new PropertyDeclaration(mod | Modifiers.Default, attributes, "Item", parameters); + id.TypeReference = type; + AddChild(id); .) + "{" (. Location bodyStart = t.Location;.) + InterfaceAccessors + "}" + (. id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;.) + ) + /*--- interface event declaration: */ + | "event" (. if (startLocation.IsEmpty) startLocation = t.Location; .) + Type Identifier + (. EventDeclaration ed = new EventDeclaration { + TypeReference = type, Name = t.val, Modifier = mod, Attributes = attributes + }; + AddChild(ed); + .) + ";" + (. ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; .) + ) + ) +. + +EnumMemberDecl +(. + Expression expr = null; + List attributes = new List(); + AttributeSection section = null; + VariableDeclaration varDecl = null; +.) += + { AttributeSection (. attributes.Add(section); .) } + Identifier (. f = new FieldDeclaration(attributes); + varDecl = new VariableDeclaration(t.val); + f.Fields.Add(varDecl); + f.StartLocation = t.Location; + f.EndLocation = t.EndLocation; + .) + [ "=" Expr (. varDecl.Initializer = expr; .) ] +. + + +AccessorDecls +(. + List attributes = new List(); + AttributeSection section; + getBlock = null; + setBlock = null; + ModifierList modifiers = null; +.) += + { AttributeSection (. attributes.Add(section); .) } + [ AccessorModifiers ] + ( + GetAccessorDecl + (. if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } .) + [ (. attributes = new List(); modifiers = null; .) + { AttributeSection (. attributes.Add(section); .) } + [ AccessorModifiers ] + SetAccessorDecl + (. if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } .) + ] + | + SetAccessorDecl + (. if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } .) + [ (. attributes = new List(); modifiers = null; .) + { AttributeSection (. attributes.Add(section); .) } + [ AccessorModifiers ] + GetAccessorDecl + (. if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } .) + ] + | Identifier (. Error("get or set accessor declaration expected"); .) + ) +. + +GetAccessorDecl attributes> +(. BlockStatement stmt = null; .) += + "get" + (. Location startLocation = t.Location; .) + ( Block | ";" ) + (. getBlock = new PropertyGetRegion(stmt, attributes); .) + (. getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; .) +. + +SetAccessorDecl attributes> +(. BlockStatement stmt = null; .) += + "set" + (. Location startLocation = t.Location; .) + ( Block | ";" ) + (. setBlock = new PropertySetRegion(stmt, attributes); .) + (. setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; .) +. + +EventAccessorDecls +(. AttributeSection section; + List attributes = new List(); + BlockStatement stmt; + addBlock = null; + removeBlock = null; +.) += + { AttributeSection (. attributes.Add(section); .) } + ( + (. addBlock = new EventAddRegion(attributes); .) + AddAccessorDecl (. attributes = new List(); addBlock.Block = stmt; .) + { AttributeSection (. attributes.Add(section); .)} + RemoveAccessorDecl (. removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = stmt; .) + | + RemoveAccessorDecl (. removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = stmt; attributes = new List(); .) + { AttributeSection (. attributes.Add(section); .) } + AddAccessorDecl (. addBlock = new EventAddRegion(attributes); addBlock.Block = stmt; .) + ) +. + +InterfaceAccessors +(. + AttributeSection section; + List attributes = new List(); + getBlock = null; setBlock = null; + PropertyGetSetRegion lastBlock = null; +.) += + { AttributeSection (. attributes.Add(section); .) } + (. Location startLocation = la.Location; .) + ( + "get" (. getBlock = new PropertyGetRegion(null, attributes); .) + | "set" (. setBlock = new PropertySetRegion(null, attributes); .) + ) + ";" + (. if (getBlock != null) { getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } + if (setBlock != null) { setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } + attributes = new List(); .) + [ + { AttributeSection (. attributes.Add(section); .) } + (. startLocation = la.Location; .) + ( + "get" (. if (getBlock != null) Error("get already declared"); + else { getBlock = new PropertyGetRegion(null, attributes); lastBlock = getBlock; } + .) + | "set" (. if (setBlock != null) Error("set already declared"); + else { setBlock = new PropertySetRegion(null, attributes); lastBlock = setBlock; } + .) + ) + ";" + (. if (lastBlock != null) { lastBlock.StartLocation = startLocation; lastBlock.EndLocation = t.EndLocation; } .) + ] +. + +VariableDeclarator +(. Expression expr = null; .) += + Identifier (. VariableDeclaration f = new VariableDeclaration(t.val); f.StartLocation = t.Location; .) + [ "=" VariableInitializer (. f.Initializer = expr; .) ] + (. f.EndLocation = t.EndLocation; SafeAdd(parentFieldDeclaration, parentFieldDeclaration.Fields, f); .) +. + +Block += + "{" (. BlockStatement blockStmt = new BlockStatement(); + blockStmt.StartLocation = t.Location; + BlockStart(blockStmt); + if (!ParseMethodBodies) lexer.SkipCurrentBlock(0); + .) + { Statement } + SYNC "}" + (. + stmt = blockStmt; + blockStmt.EndLocation = t.EndLocation; + BlockEnd(); + .) +. + +AddAccessorDecl +(.stmt = null;.) += + "add" + Block +. + +RemoveAccessorDecl +(.stmt = null;.) += + "remove" + Block +. + +ConstructorInitializer +(. Expression expr; ci = new ConstructorInitializer(); .) += + ":" + ( + "base" (. ci.ConstructorInitializerType = ConstructorInitializerType.Base; .) + | "this" (. ci.ConstructorInitializerType = ConstructorInitializerType.This; .) + ) + "(" + [ Argument (. SafeAdd(ci, ci.Arguments, expr); .) + { "," Argument (. SafeAdd(ci, ci.Arguments, expr); .) } + ] + ")" +. + +VariableInitializer +(. TypeReference type = null; Expression expr = null; initializerExpression = null; .) += + Expr + | CollectionInitializer + | "stackalloc" Type "[" Expr "]" (. initializerExpression = new StackAllocExpression(type, expr); .) +. + +OverloadableOperator +(. op = OverloadableOperatorType.None; .) += + "+" (. op = OverloadableOperatorType.Add; .) + | "-" (. op = OverloadableOperatorType.Subtract; .) + + | "!" (. op = OverloadableOperatorType.Not; .) + | "~" (. op = OverloadableOperatorType.BitNot; .) + + | "++" (. op = OverloadableOperatorType.Increment; .) + | "--" (. op = OverloadableOperatorType.Decrement; .) + + | "true" (. op = OverloadableOperatorType.IsTrue; .) + | "false" (. op = OverloadableOperatorType.IsFalse; .) + + | "*" (. op = OverloadableOperatorType.Multiply; .) + | "/" (. op = OverloadableOperatorType.Divide; .) + | "%" (. op = OverloadableOperatorType.Modulus; .) + + | "&" (. op = OverloadableOperatorType.BitwiseAnd; .) + | "|" (. op = OverloadableOperatorType.BitwiseOr; .) + | "^" (. op = OverloadableOperatorType.ExclusiveOr; .) + + | "<<" (. op = OverloadableOperatorType.ShiftLeft; .) + | "==" (. op = OverloadableOperatorType.Equality; .) + | "!=" (. op = OverloadableOperatorType.InEquality; .) + | "<" (. op = OverloadableOperatorType.LessThan; .) + | ">=" (. op = OverloadableOperatorType.GreaterThanOrEqual; .) + | "<=" (. op = OverloadableOperatorType.LessThanOrEqual; .) + | ">" (. op = OverloadableOperatorType.GreaterThan; .) [ ">" (. op = OverloadableOperatorType.ShiftRight; .) ] +. + +Argument +(. argumentexpr = null; .) += + IF (IdentAndColon()) + (. Token ident; Expression expr; .) + Identifier (. ident = t; .) + ":" + ArgumentValue + (. argumentexpr = new NamedArgumentExpression(ident.val, expr) { StartLocation = ident.Location, EndLocation = t.EndLocation }; .) + +| ArgumentValue +. + +ArgumentValue +(. + Expression expr; + FieldDirection fd = FieldDirection.None; +.) += + [ + "ref" (. fd = FieldDirection.Ref; .) + | "out" (. fd = FieldDirection.Out; .) + ] + Expr + (. argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; .) +. + +AssignmentOperator +(. op = AssignmentOperatorType.None; .) += + "=" (. op = AssignmentOperatorType.Assign; .) + | "+=" (. op = AssignmentOperatorType.Add; .) + | "-=" (. op = AssignmentOperatorType.Subtract; .) + | "*=" (. op = AssignmentOperatorType.Multiply; .) + | "/=" (. op = AssignmentOperatorType.Divide; .) + | "%=" (. op = AssignmentOperatorType.Modulus; .) + | "&=" (. op = AssignmentOperatorType.BitwiseAnd; .) + | "|=" (. op = AssignmentOperatorType.BitwiseOr; .) + | "^=" (. op = AssignmentOperatorType.ExclusiveOr; .) + | "<<=" (. op = AssignmentOperatorType.ShiftLeft; .) + | IF (la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) + ">" ">=" (. op = AssignmentOperatorType.ShiftRight; .) +. + +CollectionInitializer +(. + Expression expr = null; + CollectionInitializerExpression initializer = new CollectionInitializerExpression(); +.) += + "{" (. initializer.StartLocation = t.Location; .) + [ VariableInitializer + (. SafeAdd(initializer, initializer.CreateExpressions, expr); .) + { IF (NotFinalComma()) + "," VariableInitializer + (. SafeAdd(initializer, initializer.CreateExpressions, expr); .) + } + [ "," ] + ] + "}" (. initializer.EndLocation = t.Location; outExpr = initializer; .) +. + +CollectionOrObjectInitializer +(. + Expression expr = null; + CollectionInitializerExpression initializer = new CollectionInitializerExpression(); +.) += + "{" (. initializer.StartLocation = t.Location; .) + [ ObjectPropertyInitializerOrVariableInitializer + (. SafeAdd(initializer, initializer.CreateExpressions, expr); .) + { IF (NotFinalComma()) + "," ObjectPropertyInitializerOrVariableInitializer + (. SafeAdd(initializer, initializer.CreateExpressions, expr); .) + } + [ "," ] + ] + "}" (. initializer.EndLocation = t.Location; outExpr = initializer; .) +. + +ObjectPropertyInitializerOrVariableInitializer +(. expr = null; .) += +( IF (IdentAndAsgn()) + Identifier + (. MemberInitializerExpression mie = new MemberInitializerExpression(t.val, null); + mie.StartLocation = t.Location; + mie.IsKey = true; + Expression r = null; .) + "=" + ( CollectionOrObjectInitializer + | VariableInitializer ) + (. mie.Expression = r; mie.EndLocation = t.EndLocation; expr = mie; .) + +| VariableInitializer +) +. + +LocalVariableDecl +(. + TypeReference type; + VariableDeclaration var = null; + LocalVariableDeclaration localVariableDeclaration; + Location startPos = la.Location; +.) += + Type (. localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = startPos; .) + LocalVariableDeclarator (. SafeAdd(localVariableDeclaration, localVariableDeclaration.Variables, var); .) + { "," LocalVariableDeclarator (. SafeAdd(localVariableDeclaration, localVariableDeclaration.Variables, var); .) } + (. stmt = localVariableDeclaration; stmt.EndLocation = t.EndLocation; .) +. + +LocalVariableDeclarator +(. Expression expr = null; .) += + Identifier (. var = new VariableDeclaration(t.val); var.StartLocation = t.Location; .) + [ "=" VariableInitializer (. var.Initializer = expr; .) ] + (. var.EndLocation = t.EndLocation; .) +. + +Statement +(. + Statement stmt = null; + Location startPos = la.Location; +.) += + SYNC + ( + /*--- labeled statement: */ + IF (IsLabel()) Identifier (. AddChild(new LabelStatement(t.val)); .) + ":" Statement + /*--- local constant declaration: */ + | "const" + LocalVariableDecl + (. if (stmt != null) { ((LocalVariableDeclaration)stmt).Modifier |= Modifiers.Const; } .) + ";" (. AddChild(stmt); .) + /*--- local variable declaration: */ + | IF (IsLocalVarDecl()) LocalVariableDecl ";" (. AddChild(stmt); .) + + | EmbeddedStatement (. AddChild(stmt); .) + /* LL(1) confict: LocalVariableDecl * + * <-> StatementExpr * + * ident {"." ident} { "[" Expr ... */ + ) + (. + if (stmt != null) { + stmt.StartLocation = startPos; + stmt.EndLocation = t.EndLocation; + } + .) +. + +EmbeddedStatement +(. + TypeReference type = null; + Expression expr = null; + Statement embeddedStatement = null; + BlockStatement block = null; + statement = null; +.) += + (. Location startLocation = la.Location; .) + ( + Block (. statement = block; .) + + /*--- empty statement: */ + | ";" (. statement = new EmptyStatement(); .) + + /*--- checked / unchecked statement: */ + | IF (UnCheckedAndLBrace()) (. bool isChecked = true; .) + ("checked" | "unchecked" (. isChecked = false;.) ) + Block (. statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); .) + + /*--- selection statements (if, switch): */ + | IfStatement + + | "switch" (. List switchSections = new List(); .) + "(" Expr ")" + "{" SwitchSections + "}" + (. statement = new SwitchStatement(expr, switchSections); .) + + /*--- iteration statements (while, do, for, foreach): */ + | "while" "(" Expr ")" + EmbeddedStatement + (. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);.) + + | "do" EmbeddedStatement "while" + "(" Expr ")" ";" + (. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); .) + + | "for" (. List initializer = null; List iterator = null; .) + "(" [ ForInitializer ] ";" + [ Expr ] ";" + [ ForIterator ] ")" + EmbeddedStatement + (. statement = new ForStatement(initializer, expr, iterator, embeddedStatement); .) + + | "foreach" "(" Type Identifier (. string varName = t.val; .) + "in" Expr ")" + EmbeddedStatement + (. statement = new ForeachStatement(type, varName , expr, embeddedStatement); .) + + /*--- jump statements (break, contine, goto, return, throw): */ + | "break" ";" (. statement = new BreakStatement(); .) + | "continue" ";" (. statement = new ContinueStatement(); .) + | GotoStatement + + | IF (IsYieldStatement()) "yield" + ( "return" Expr (. statement = new YieldStatement(new ReturnStatement(expr)); .) + | "break" (. statement = new YieldStatement(new BreakStatement()); .) ) + ";" + + | "return" [ Expr ] ";" (. statement = new ReturnStatement(expr); .) + | "throw" [ Expr ] ";" (. statement = new ThrowStatement(expr); .) + + /*--- expression statement: */ + | StatementExpr SYNC ";" + + /*--- try statement: */ + | TryStatement + + /*--- lock satement: */ + | "lock" "(" Expr ")" + EmbeddedStatement (. statement = new LockStatement(expr, embeddedStatement); .) + + /*--- using statement: */ + | (.Statement resourceAcquisitionStmt = null; .) + "using" "(" + ResourceAcquisition ")" + EmbeddedStatement (. statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); .) + + /*--- unsafe statement: */ + | "unsafe" Block (. statement = new UnsafeStatement(block); .) + /*--- fixed statement: */ + | (. Statement pointerDeclarationStmt = null; .) + "fixed" "(" + ResourceAcquisition ")" + EmbeddedStatement (. statement = new FixedStatement(pointerDeclarationStmt, embeddedStatement); .) + ) + (. if (statement != null) { + statement.StartLocation = startLocation; + statement.EndLocation = t.EndLocation; + } + .) +. + +IfStatement +(. + Expression expr = null; + Statement embeddedStatement = null; + statement = null; +.) += + "if" + "(" Expr ")" + EmbeddedStatement + (. Statement elseStatement = null; .) + [ "else" EmbeddedStatement ] + (. statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); .) + (. if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) { + /* else if-section (otherwise we would have a BlockStatment) */ + (statement as IfElseStatement).ElseIfSections.Add( + new ElseIfSection((elseStatement as IfElseStatement).Condition, + (elseStatement as IfElseStatement).TrueStatement[0])); + (statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections); + (statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement; + } + .) +. + +ForInitializer initializer> +(. + Statement stmt; + initializer = new List(); +.) += + IF (IsLocalVarDecl()) LocalVariableDecl (. initializer.Add(stmt);.) + | StatementExpr (.initializer.Add(stmt);.) { "," StatementExpr (. initializer.Add(stmt);.) } +. + +ForIterator iterator> +(. + Statement stmt; + iterator = new List(); +.) += + StatementExpr (. iterator.Add(stmt);.) { "," StatementExpr (. iterator.Add(stmt); .) } +. + +SwitchSections switchSections> +(. + SwitchSection switchSection = new SwitchSection(); + CaseLabel label; +.) += + SwitchLabel (. SafeAdd(switchSection, switchSection.SwitchLabels, label); .) + (. BlockStart(switchSection); .) + { + ( SwitchLabel + (. if (label != null) { + if (switchSection.Children.Count > 0) { + // open new section + BlockEnd(); switchSections.Add(switchSection); + switchSection = new SwitchSection(); + BlockStart(switchSection); + } + SafeAdd(switchSection, switchSection.SwitchLabels, label); + } + .) + | Statement) + } + (. BlockEnd(); switchSections.Add(switchSection); .) +. + +SwitchLabel + (. Expression expr = null; label = null; .) += + "case" Expr ":" (. label = new CaseLabel(expr); .) + | "default" ":" (. label = new CaseLabel(); .) +. + +TryStatement +(. + BlockStatement blockStmt = null, finallyStmt = null; + CatchClause catchClause = null; + List catchClauses = new List(); +.) += + "try" Block + { + CatchClause + (. if (catchClause != null) catchClauses.Add(catchClause); .) + } + [ "finally" Block ] + (. + tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); + if (catchClauses != null) { + foreach (CatchClause cc in catchClauses) cc.Parent = tryStatement; + } + .) +. + +CatchClause += + "catch" (. string identifier; + BlockStatement stmt; + TypeReference typeRef; + Location startPos = t.Location; + catchClause = null; + .) + ( + /*--- general catch clause */ + Block (. catchClause = new CatchClause(stmt); .) + + /*--- specific catch clause */ + | "(" ClassType (. identifier = null; .) + [ Identifier (. identifier = t.val; .) ] + ")" Block + (. catchClause = new CatchClause(typeRef, identifier, stmt); .) + ) + (. + if (catchClause != null) { + catchClause.StartLocation = startPos; + catchClause.EndLocation = t.Location; + } + .) +. + +GotoStatement +(. Expression expr; stmt = null; .) += + "goto" + ( + Identifier (. stmt = new GotoStatement(t.val); .) ";" + | "case" Expr ";" (. stmt = new GotoCaseStatement(expr); .) + | "default" ";" (. stmt = new GotoCaseStatement(null); .) + ) +. + +ResourceAcquisition +(. + stmt = null; + Expression expr; +.) += + ( + IF (IsLocalVarDecl()) LocalVariableDecl + | Expr /* LL(1) conflict resoltion: * + * check if next is Qualident followed by ident * + * ==> LocalVariableDecl * + * new problem: first set of ResourceAcquisition changes */ + (. stmt = new ExpressionStatement(expr); .) + ) +. + +StatementExpr +(. Expression expr; .) += + Expr + /* The grammar allows only assignments or method invocations here, */ + /* but we don't enforce that here */ + (. stmt = new ExpressionStatement(expr); .) +. + +Expr +(. expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; .) += + (. Location startLocation = la.Location; .) + UnaryExpr + /*--- conditional expression: */ + ( + ( AssignmentOperator Expr (. expr = new AssignmentExpression(expr, op, expr1); .) ) + | IF (la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) + ( AssignmentOperator Expr (. expr = new AssignmentExpression(expr, op, expr1); .) ) + | ( + ConditionalOrExpr + [ "??" Expr (. expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); .) ] + [ "?" Expr ":" Expr (. expr = new ConditionalExpression(expr, expr1, expr2); .) ] + ) + ) + (. if (expr != null) { + if (expr.StartLocation.IsEmpty) + expr.StartLocation = startLocation; + if (expr.EndLocation.IsEmpty) + expr.EndLocation = t.EndLocation; + } + .) +. + + +UnaryExpr +(. + TypeReference type = null; + Expression expr = null; + ArrayList expressions = new ArrayList(); + uExpr = null; +.) += + { + /* IF (Tokens.UnaryOp[la.kind] || IsTypeCast()) */ + ( + "+" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus) { StartLocation = t.Location }); .) + | "-" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus) { StartLocation = t.Location }); .) + | "!" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not) { StartLocation = t.Location }); .) + | "~" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot) { StartLocation = t.Location }); .) + | "*" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Dereference) { StartLocation = t.Location }); .) + | "++" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment) { StartLocation = t.Location }); .) + | "--" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement) { StartLocation = t.Location }); .) + | "&" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.AddressOf) { StartLocation = t.Location }); .) + + /*--- cast expression: */ + /* Problem: "(" Type ")" from here and * + * "(" Expr ")" from PrimaryExpr * + * Solution: (in IsTypeCast()) */ + | IF (IsTypeCast()) "(" Type ")" (. expressions.Add(new CastExpression(type) { StartLocation = t.Location }); .) + ) + } + + /* special rule (2.4.4.2) to allow writing int.MinValue and long.MinValue */ + ( IF (LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffix()) + Literal + (. + expressions.RemoveAt(expressions.Count - 1); + if (t.literalValue is uint) { + expr = new PrimitiveExpression(int.MinValue, int.MinValue.ToString()); + } else if (t.literalValue is ulong) { + expr = new PrimitiveExpression(long.MinValue, long.MinValue.ToString()); + } else { + throw new Exception("t.literalValue must be uint or ulong"); + } + .) + | PrimaryExpr + ) + (. for (int i = 0; i < expressions.Count; ++i) { + Expression nextExpression = i + 1 < expressions.Count ? (Expression)expressions[i + 1] : expr; + if (expressions[i] is CastExpression) { + ((CastExpression)expressions[i]).Expression = nextExpression; + } else { + ((UnaryOperatorExpression)expressions[i]).Expression = nextExpression; + } + } + if (expressions.Count > 0) { + uExpr = (Expression)expressions[0]; + } else { + uExpr = expr; + } + .) +. + + +PrimaryExpr +(. + TypeReference type = null; + Expression expr; + pexpr = null; +.) += + (. Location startLocation = la.Location; .) + ( + "true" (.pexpr = new PrimitiveExpression(true, "true"); .) + | "false" (.pexpr = new PrimitiveExpression(false, "false"); .) + | "null" (.pexpr = new PrimitiveExpression(null, "null"); .) /* from literal token */ + | Literal (.pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; .) + | IF (StartOfQueryExpression()) + QueryExpression + | IF (IdentAndDoubleColon()) + Identifier (. type = new TypeReference(t.val); .) + "::" (. pexpr = new TypeReferenceExpression(type); .) + Identifier (. if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); .) + + /*--- simple name (IdentifierExpression): */ + | Identifier + (. pexpr = new IdentifierExpression(t.val); .) + + [ ShortedLambdaExpression<(IdentifierExpression)pexpr, out pexpr> + | IF (IsGenericInSimpleNameOrMemberAccess()) + (. List typeList; .) + TypeArgumentList + (. ((IdentifierExpression)pexpr).TypeArguments = typeList; .) + ] + | IF (IsLambdaExpression()) /* Lambda expression */ + LambdaExpression + + /*--- parenthesized expression: */ + | "(" Expr ")" (. pexpr = new ParenthesizedExpression(expr); .) + + | /*--- predefined type member access: */ + (. string val = null; .) + ( "bool" (. val = "System.Boolean"; .) + | "byte" (. val = "System.Byte"; .) + | "char" (. val = "System.Char"; .) + | "decimal" (. val = "System.Decimal"; .) + | "double" (. val = "System.Double"; .) + | "float" (. val = "System.Single"; .) + | "int" (. val = "System.Int32"; .) + | "long" (. val = "System.Int64"; .) + | "object" (. val = "System.Object"; .) + | "sbyte" (. val = "System.SByte"; .) + | "short" (. val = "System.Int16"; .) + | "string" (. val = "System.String"; .) + | "uint" (. val = "System.UInt32"; .) + | "ulong" (. val = "System.UInt64"; .) + | "ushort" (. val = "System.UInt16"; .) + | "void" (. val = "System.Void"; .) + ) + (. pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation }; .) + + /*--- this access: */ + | "this" (. pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; .) + /*--- base access: */ + | "base" (. pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; .) + + /* new ... - ObjectCreationExpression or ArrayCreateExpression */ + | NewExpression + + | "typeof" "(" + ( + IF (NotVoidPointer()) "void" (. type = new TypeReference("System.Void", true); .) + | TypeWithRestriction + ) + ")" (. pexpr = new TypeOfExpression(type); .) + + | "default" "(" Type ")" (. pexpr = new DefaultValueExpression(type); .) + | "sizeof" "(" Type ")" (. pexpr = new SizeOfExpression(type); .) + | "checked" "(" Expr ")" (. pexpr = new CheckedExpression(expr); .) + | "unchecked" "(" Expr ")" (. pexpr = new UncheckedExpression(expr); .) + | "delegate" AnonymousMethodExpr (. pexpr = expr; .) + ) + (. if (pexpr != null) { + if (pexpr.StartLocation.IsEmpty) + pexpr.StartLocation = startLocation; + if (pexpr.EndLocation.IsEmpty) + pexpr.EndLocation = t.EndLocation; + } + .) + { + (. startLocation = la.Location; .) + ( + "++" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); .) + | + "--" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); .) + /*--- member access */ + | PointerMemberAccess + | MemberAccess + + /*--- invocation expression: */ + | "(" + (. List parameters = new List(); .) + (. pexpr = new InvocationExpression(pexpr, parameters); .) + [ Argument (. SafeAdd(pexpr, parameters, expr); .) + { "," Argument (. SafeAdd(pexpr, parameters, expr); .) + } + ] + ")" + /*--- element access */ + | (. /*if (isArrayCreation) Error("element access not allow on array creation");*/ + List indices = new List(); + pexpr = new IndexerExpression(pexpr, indices); + .) + "[" Expr (. SafeAdd(pexpr, indices, expr); .) + { "," Expr (. SafeAdd(pexpr, indices, expr); .) + } "]" + ) + (. if (pexpr != null) { + if (pexpr.StartLocation.IsEmpty) + pexpr.StartLocation = startLocation; + if (pexpr.EndLocation.IsEmpty) + pexpr.EndLocation = t.EndLocation; + } + .) + } +. + +MemberAccess +(. List typeList; .) += + (. if (ShouldConvertTargetExpressionToTypeReference(target)) { + TypeReference type = GetTypeReferenceFromExpression(target); + if (type != null) { + target = new TypeReferenceExpression(type) { StartLocation = t.Location, EndLocation = t.EndLocation }; + } + } + .) + "." (. Location startLocation = t.Location; .) + Identifier + (. expr = new MemberReferenceExpression(target, t.val); expr.StartLocation = startLocation; expr.EndLocation = t.EndLocation; .) + [ IF (IsGenericInSimpleNameOrMemberAccess()) + TypeArgumentList + (. ((MemberReferenceExpression)expr).TypeArguments = typeList; .) + ] +. + +PointerMemberAccess +(. List typeList; .) += + "->" + Identifier + (. expr = new PointerReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; .) + [ IF (IsGenericInSimpleNameOrMemberAccess()) + TypeArgumentList + (. ((MemberReferenceExpression)expr).TypeArguments = typeList; .) + ] +. + +NewExpression +(. pexpr = null; + List parameters = new List(); + TypeReference type = null; + Expression expr; +.) += + "new" + [ NonArrayType ] /* optional since .NET 3.0 */ + + /*--- delegate / object creation expression: */ + /* Note: a delegate creation expression allow only a single Expr */ + /* not an argument list, but this is not distinguished here */ + ( + ( (. ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); .) + "(" (. if (type == null) Error("Cannot use an anonymous type with arguments for the constructor"); .) + [ Argument (. SafeAdd(oce, parameters, expr); .) + { "," Argument (. SafeAdd(oce, parameters, expr); .) } + ] + ")" (. pexpr = oce; .) + [ CollectionOrObjectInitializer (. oce.ObjectInitializer = (CollectionInitializerExpression)expr; .) ] + | (. ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); .) + CollectionOrObjectInitializer (. oce.ObjectInitializer = (CollectionInitializerExpression)expr; .) + (. pexpr = oce; .) + ) + + /*--- array creation expression: */ + | "[" + (. ArrayCreateExpression ace = new ArrayCreateExpression(type); + /* we must not change RankSpecifier on the null type reference*/ + if (ace.CreateType.IsNull) { ace.CreateType = new TypeReference(""); } + pexpr = ace; + int dims = 0; List ranks = new List(); + .) + ( + { "," (. dims += 1; .) } + "]" (. ranks.Add(dims); dims = 0; .) + { "[" { "," (. ++dims; .) } "]" (. ranks.Add(dims); dims = 0; .) } + (. ace.CreateType.RankSpecifier = ranks.ToArray(); .) + CollectionInitializer (. ace.ArrayInitializer = (CollectionInitializerExpression)expr; .) + | Expr (. if (expr != null) parameters.Add(expr); .) + { "," (. dims += 1; .) + Expr (. if (expr != null) parameters.Add(expr); .) + } + "]" (. ranks.Add(dims); ace.Arguments = parameters; dims = 0; .) + { "[" { "," (. ++dims; .) } "]" (. ranks.Add(dims); dims = 0; .) } + (. ace.CreateType.RankSpecifier = ranks.ToArray(); .) + [ CollectionInitializer (. ace.ArrayInitializer = (CollectionInitializerExpression)expr; .) ] + ) + ) +. + +/* Lambda expression with parameter list */ +LambdaExpression +(. + LambdaExpression lambda = new LambdaExpression(); + lambda.StartLocation = la.Location; + ParameterDeclarationExpression p; + outExpr = lambda; +.) += + "(" + [ + LambdaExpressionParameter (. SafeAdd(lambda, lambda.Parameters, p); .) + { "," + LambdaExpressionParameter (. SafeAdd(lambda, lambda.Parameters, p); .) + } + ] + ")" + "=>" + LambdaExpressionBody +. + +ShortedLambdaExpression +(. LambdaExpression lambda = new LambdaExpression(); pexpr = lambda; .) += + "=>" + /* not an IdentifierExpression, but a short lambda expression*/ + (. + lambda.StartLocation = ident.StartLocation; + SafeAdd(lambda, lambda.Parameters, new ParameterDeclarationExpression(null, ident.Identifier)); + lambda.Parameters[0].StartLocation = ident.StartLocation; + lambda.Parameters[0].EndLocation = ident.EndLocation; + .) + LambdaExpressionBody +. + +LambdaExpressionParameter +(. Location start = la.Location; p = null; + TypeReference type; + ParameterModifiers mod = ParameterModifiers.In; +.) += + ( IF (Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) + Identifier + (. p = new ParameterDeclarationExpression(null, t.val); + p.StartLocation = start; p.EndLocation = t.EndLocation; + .) + | [ "ref" (. mod = ParameterModifiers.Ref; .) + | "out" (. mod = ParameterModifiers.Out; .) + ] + Type + Identifier + (. p = new ParameterDeclarationExpression(type, t.val, mod); + p.StartLocation = start; p.EndLocation = t.EndLocation; + .) + ) +. + +LambdaExpressionBody +(. Expression expr; BlockStatement stmt; .) += + ( + Block (. lambda.StatementBody = stmt; .) + | Expr (. lambda.ExpressionBody = expr; .) + ) + (. lambda.EndLocation = t.EndLocation; .) + (. lambda.ExtendedEndLocation = la.Location; .) +. + +AnonymousMethodExpr +(. + AnonymousMethodExpression expr = new AnonymousMethodExpression(); + expr.StartLocation = t.Location; + BlockStatement stmt; + List p = new List(); + outExpr = expr; +.) += + [ + "(" + [ FormalParameterList

(. expr.Parameters = p; .) ] + ")" + (. expr.HasParameterList = true; .) + ] + Block (. expr.Body = stmt; .) + (. expr.EndLocation = t.Location; .) +. + +ConditionalOrExpr +(. Expression expr; Location startLocation = la.Location; .) += + ConditionalAndExpr { "||" UnaryExpr ConditionalAndExpr (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) } +. + +ConditionalAndExpr +(. Expression expr; Location startLocation = la.Location; .) += + InclusiveOrExpr { "&&" UnaryExpr InclusiveOrExpr (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) } +. + +InclusiveOrExpr +(. Expression expr; Location startLocation = la.Location; .) += + ExclusiveOrExpr { "|" UnaryExpr ExclusiveOrExpr (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) } +. + +ExclusiveOrExpr +(. Expression expr; Location startLocation = la.Location; .) += + AndExpr { "^" UnaryExpr AndExpr (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) } +. + +AndExpr +(. Expression expr; Location startLocation = la.Location; .) += + EqualityExpr { "&" UnaryExpr EqualityExpr (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) } +. + +EqualityExpr +(. + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; +.) += + RelationalExpr + { + ( + "!=" (. op = BinaryOperatorType.InEquality; .) + | "==" (. op = BinaryOperatorType.Equality; .) + ) + UnaryExpr RelationalExpr (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) + } +. + +RelationalExpr +(. + TypeReference type; + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; +.) += + ShiftExpr + { + ( "<" (. op = BinaryOperatorType.LessThan; .) + | ">" (. op = BinaryOperatorType.GreaterThan; .) + | "<=" (. op = BinaryOperatorType.LessThanOrEqual; .) + | ">=" (. op = BinaryOperatorType.GreaterThanOrEqual; .) + ) + UnaryExpr + ShiftExpr + (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) + | + ( "is" + TypeWithRestriction + [ IF (la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) + NullableQuestionMark ] + (. outExpr = new TypeOfIsExpression(outExpr, type) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) + | "as" + TypeWithRestriction + [ IF (la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) + NullableQuestionMark ] + (. outExpr = new CastExpression(type, outExpr, CastType.TryCast) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) + ) + } +. + +ShiftExpr +(. + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; +.) += + AdditiveExpr + { + ( "<<" (. op = BinaryOperatorType.ShiftLeft; .) + | IF (IsShiftRight()) ( + ">" ">" (. op = BinaryOperatorType.ShiftRight; .) + ) + ) + UnaryExpr AdditiveExpr (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) + } +. + +AdditiveExpr +(. + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; +.) += + MultiplicativeExpr + { + ( + "+" (. op = BinaryOperatorType.Add; .) + | "-" (. op = BinaryOperatorType.Subtract; .) + ) + UnaryExpr MultiplicativeExpr (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) + } +. + +MultiplicativeExpr +(. + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; +.) += + { + ( + "*" (. op = BinaryOperatorType.Multiply; .) + | "/" (. op = BinaryOperatorType.Divide; .) + | "%" (. op = BinaryOperatorType.Modulus; .) + ) + UnaryExpr (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) + } +. + +/* .NET 2.0 rules */ + +TypeName +(. List typeArguments = null; + string alias = null; + string qualident; + Location startLocation = la.Location; +.) += + [ IF (IdentAndDoubleColon()) + Identifier (. alias = t.val; .) + "::" + ] + Qualident + [TypeArgumentList] + (. + if (alias == null) { + typeRef = new TypeReference(qualident, typeArguments); + } else if (alias == "global") { + typeRef = new TypeReference(qualident, typeArguments); + typeRef.IsGlobal = true; + } else { + typeRef = new TypeReference(alias + "." + qualident, typeArguments); + } + .) + { IF (DotAndIdent()) + "." (. typeArguments = null; .) + Qualident + [TypeArgumentList] + (. typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); .) + } + (. typeRef.StartLocation = startLocation; typeRef.EndLocation = t.EndLocation; .) +. + + +NullableQuestionMark +(. List typeArguments = new List(1); .) += + "?" + (. + if (typeRef != null) typeArguments.Add(typeRef); + typeRef = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; + .) +. + +TypeArgumentList types, bool canBeUnbound> +(. + types = new List(); + TypeReference type = null; +.) += + "<" + ( IF (canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) + (. types.Add(TypeReference.Null); .) + { "," (. types.Add(TypeReference.Null); .) } + | Type (. if (type != null) { types.Add(type); } .) + { "," Type (. if (type != null) { types.Add(type); } .) } + ) + ">" +. + +TypeParameterList templates> +(. + TemplateDefinition template; +.) += + "<" + VariantTypeParameter (. templates.Add(template); .) + { "," + VariantTypeParameter (. templates.Add(template); .) + } + ">" +. + +VariantTypeParameter +(. + typeParameter = new TemplateDefinition(); + AttributeSection section; +.) += + { AttributeSection (. typeParameter.Attributes.Add(section); .) } + [ + "in" (. typeParameter.VarianceModifier = VarianceModifier.Contravariant; .) + | "out" (. typeParameter.VarianceModifier = VarianceModifier.Covariant; .) + ] + Identifier (. typeParameter.Name = t.val; typeParameter.StartLocation = t.Location; .) +(. typeParameter.EndLocation = t.EndLocation; .) +. + +TypeParameterConstraintsClause templates> +(. string name = ""; TypeReference type; .) += + "where" + Identifier (. name = t.val; .) + ":" + TypeParameterConstraintsClauseBase (. + TemplateDefinition td = null; + foreach (TemplateDefinition d in templates) { + if (d.Name == name) { + td = d; + break; + } + } + if ( td != null && type != null) { td.Bases.Add(type); } + .) + { "," TypeParameterConstraintsClauseBase (. + td = null; + foreach (TemplateDefinition d in templates) { + if (d.Name == name) { + td = d; + break; + } + } + if ( td != null && type != null) { td.Bases.Add(type); } + .) } +. + +TypeParameterConstraintsClauseBase +(. TypeReference t; type = null; .) += + "struct" (. type = TypeReference.StructConstraint; .) + | "class" (. type = TypeReference.ClassConstraint; .) + | "new" "(" ")" (. type = TypeReference.NewConstraint; .) + | Type (. type = t; .) +. + +QueryExpression +(. QueryExpression q = new QueryExpression(); outExpr = q; q.StartLocation = la.Location; + QueryExpressionFromClause fromClause; +.) += + QueryExpressionFromClause (. q.FromClause = fromClause; .) + QueryExpressionBody + (. q.EndLocation = t.EndLocation; + outExpr = q; /* set outExpr to q again if QueryExpressionBody changed it (can happen with 'into' clauses) */ + .) +. + +QueryExpressionFromClause +(. fc = new QueryExpressionFromClause(); +fc.StartLocation = la.Location; +CollectionRangeVariable variable; +.) += + "from" + QueryExpressionFromOrJoinClause + (. fc.EndLocation = t.EndLocation; + fc.Sources.Add(variable); + .) +. + +QueryExpressionJoinClause +(. jc = new QueryExpressionJoinClause(); jc.StartLocation = la.Location; + Expression expr; + CollectionRangeVariable variable; +.) += + "join" + QueryExpressionFromOrJoinClause + "on" + Expr (. jc.OnExpression = expr; .) + "equals" + Expr (. jc.EqualsExpression = expr; .) + [ "into" + Identifier (. jc.IntoIdentifier = t.val; .) + ] + (. + jc.EndLocation = t.EndLocation; + jc.Source = variable; + .) +. + +QueryExpressionFromOrJoinClause +(. TypeReference type; Expression expr; variable = new CollectionRangeVariable(); .) += + (. variable.Type = null; .) + [ IF (IsLocalVarDecl()) Type (. variable.Type = type; .) ] + Identifier (. variable.Identifier = t.val; .) + "in" + Expr (. variable.Expression = expr; .) +. + +QueryExpressionBody +(. QueryExpressionFromClause fromClause; QueryExpressionWhereClause whereClause; + QueryExpressionLetClause letClause; QueryExpressionJoinClause joinClause; + QueryExpressionOrderClause orderClause; + QueryExpressionSelectClause selectClause; QueryExpressionGroupClause groupClause; +.) += + { ( QueryExpressionFromClause (. SafeAdd(q, q.MiddleClauses, fromClause); .) + | QueryExpressionWhereClause (. SafeAdd(q, q.MiddleClauses, whereClause); .) + | QueryExpressionLetClause (. SafeAdd(q, q.MiddleClauses, letClause); .) + | QueryExpressionJoinClause (. SafeAdd(q, q.MiddleClauses, joinClause); .) + | QueryExpressionOrderByClause (. SafeAdd(q, q.MiddleClauses, orderClause); .) + ) } + ( QueryExpressionSelectClause (. q.SelectOrGroupClause = selectClause; .) + | QueryExpressionGroupClause (. q.SelectOrGroupClause = groupClause; .) + ) + [ QueryExpressionIntoClause ] +. + +QueryExpressionWhereClause +(. Expression expr; wc = new QueryExpressionWhereClause(); wc.StartLocation = la.Location; .) += + "where" + Expr (. wc.Condition = expr; .) + (. wc.EndLocation = t.EndLocation; .) +. + +QueryExpressionLetClause +(. Expression expr; wc = new QueryExpressionLetClause(); wc.StartLocation = la.Location; .) += + "let" + Identifier (. wc.Identifier = t.val; .) + "=" + Expr (. wc.Expression = expr; .) + (. wc.EndLocation = t.EndLocation; .) +. + +QueryExpressionOrderByClause +(. QueryExpressionOrdering ordering; oc = new QueryExpressionOrderClause(); oc.StartLocation = la.Location; .) += + "orderby" + QueryExpressionOrdering (. SafeAdd(oc, oc.Orderings, ordering); .) + { "," + QueryExpressionOrdering (. SafeAdd(oc, oc.Orderings, ordering); .) + } + (. oc.EndLocation = t.EndLocation; .) +. + +QueryExpressionOrdering +(. Expression expr; ordering = new QueryExpressionOrdering(); ordering.StartLocation = la.Location; .) += + Expr (. ordering.Criteria = expr; .) + [ "ascending" (. ordering.Direction = QueryExpressionOrderingDirection.Ascending; .) + | "descending" (. ordering.Direction = QueryExpressionOrderingDirection.Descending; .) + ] + (. ordering.EndLocation = t.EndLocation; .) +. + +QueryExpressionSelectClause +(. Expression expr; sc = new QueryExpressionSelectClause(); sc.StartLocation = la.Location; .) += + "select" + Expr (. sc.Projection = expr; .) + (. sc.EndLocation = t.EndLocation; .) +. + +QueryExpressionGroupClause +(. Expression expr; gc = new QueryExpressionGroupClause(); gc.StartLocation = la.Location; .) += + "group" + Expr (. gc.Projection = expr; .) + "by" + Expr (. gc.GroupBy = expr; .) + (. gc.EndLocation = t.EndLocation; .) +. + +QueryExpressionIntoClause +(. QueryExpression firstQuery = q; + QueryExpression continuedQuery = new QueryExpression(); + continuedQuery.StartLocation = q.StartLocation; + firstQuery.EndLocation = la.Location; + continuedQuery.FromClause = new QueryExpressionFromClause(); + CollectionRangeVariable fromVariable = new CollectionRangeVariable(); + continuedQuery.FromClause.Sources.Add(fromVariable); + fromVariable.StartLocation = la.Location; + // nest firstQuery inside continuedQuery. + fromVariable.Expression = firstQuery; + continuedQuery.IsQueryContinuation = true; + q = continuedQuery; +.) += + "into" + Identifier (. fromVariable.Identifier = t.val; .) + (. continuedQuery.FromClause.EndLocation = t.EndLocation; .) + QueryExpressionBody +. + +/* allow usage of context sensitive keywords as identifiers */ +Identifier += +/* when updating this list, ensure you also change KeywordList.IdentifierTokens*/ + ident +| "partial" +| "where" +| "get" +| "set" +| "add" +| "remove" +| "yield" +| "select" +| "group" +| "by" +| "into" +| "from" +| "ascending" +| "descending" +| "orderby" +| "let" +| "join" +| "on" +| "equals" +. + + +END CS. diff --git a/Project/Src/Parser/Errors.cs b/Project/Src/Parser/Errors.cs new file mode 100644 index 0000000000..a948fdcd4b --- /dev/null +++ b/Project/Src/Parser/Errors.cs @@ -0,0 +1,50 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Text; + +namespace ICSharpCode.NRefactory.Parser +{ + public delegate void ErrorCodeProc(int line, int col, int n); + public delegate void ErrorMsgProc(int line, int col, string msg); + + public class Errors + { + int count = 0; // number of errors detected + public ErrorCodeProc SynErr; + public ErrorCodeProc SemErr; + public ErrorMsgProc Error; + StringBuilder errorText = new StringBuilder(); + + public string ErrorOutput { + get { + return errorText.ToString(); + } + } + + public Errors() + { + SynErr = new ErrorCodeProc(DefaultCodeError); // syntactic errors + SemErr = new ErrorCodeProc(DefaultCodeError); // semantic errors + Error = new ErrorMsgProc(DefaultMsgError); // user defined string based errors + } + + public int Count { + get { + return count; + } + } + + void DefaultCodeError(int line, int col, int n) + { + errorText.AppendLine(String.Format("-- line {0} col {1}: error {2}", line, col, n)); + count++; + } + + void DefaultMsgError(int line, int col, string s) { + errorText.AppendLine(String.Format("-- line {0} col {1}: {2}", line, col, s)); + count++; + } + } // Errors +} diff --git a/Project/Src/Parser/Frames/Parser.frame b/Project/Src/Parser/Frames/Parser.frame new file mode 100644 index 0000000000..5602370fd6 --- /dev/null +++ b/Project/Src/Parser/Frames/Parser.frame @@ -0,0 +1,50 @@ +/* + Parser.frame file for NRefactory. + */ +using System; +using System.Reflection; + +-->namespace + +-->tokens + +partial class Parser : AbstractParser +{ +-->constants + const bool T = true; + const bool x = false; + +-->declarations + +/* +-->pragmas +*/ + +-->productions + + void ParseRoot() + { +-->parseRoot + } + + protected override void SynErr(int line, int col, int errorNumber) + { + string s; + switch (errorNumber) { +-->errors + default: s = "error " + errorNumber; break; + } + this.Errors.Error(line, col, s); + } + + private bool StartOf(int s) + { + return set[s, lexer.LookAhead.kind]; + } + + static bool[,] set = { +-->initialization + }; +} // end Parser + +$$$ diff --git a/Project/Src/Parser/Frames/Scanner.frame b/Project/Src/Parser/Frames/Scanner.frame new file mode 100644 index 0000000000..be14a4e655 --- /dev/null +++ b/Project/Src/Parser/Frames/Scanner.frame @@ -0,0 +1,202 @@ +/*---------------------------------------------------------------------- +Compiler Generator Coco/R, +Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz +extended by M. Loeberbauer & A. Woess, Univ. of Linz +with improvements by Pat Terry, Rhodes University + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As an exception, it is allowed to write an extension of Coco/R that is +used as a plugin in non-free software. + +If not otherwise stated, any source code generated by Coco/R (other than +Coco/R itself) does not fall under the GNU General Public License. +-----------------------------------------------------------------------*/ +-->begin +using System; +using System.IO; +using System.Collections; +using System.Text; + +-->namespace + +public class Token { + public int kind; // token kind + public int pos; // token position in the source text (starting at 0) + public int col; // token column (starting at 0) + public int line; // token line (starting at 1) + public string val; // token value + public Token next; // AW 2003-03-07 Tokens are kept in linked list +} + +public class Buffer { + public const char EOF = (char)256; + static byte[] buf; + static int bufLen; + static int pos; + // CHANGES by M.KRUEGER + public static int CountLines(int offset) + { + int line = 0; + for (int i = 0; i <= offset; ++i) { + if (buf[i] == '\n') { + ++line; + } + } + return line; + } + //EOC + public static void Fill (Stream s) { + bufLen = (int) s.Length; + buf = new byte[bufLen]; + s.Read(buf, 0, bufLen); + pos = 0; + } + + public static int Read () { + if (pos < bufLen) return buf[pos++]; + else return EOF; /* pdt */ + } + + public static int Peek () { + if (pos < bufLen) return buf[pos]; + else return EOF; /* pdt */ + } + + /* AW 2003-03-10 moved this from ParserGen.cs */ + public static string GetString (int beg, int end) { + StringBuilder s = new StringBuilder(64); + int oldPos = Buffer.Pos; + Buffer.Pos = beg; + while (beg < end) { s.Append((char)Buffer.Read()); beg++; } + Buffer.Pos = oldPos; + return s.ToString(); + } + + public static int Pos { + get { return pos; } + set { + if (value < 0) pos = 0; + else if (value >= bufLen) pos = bufLen; + else pos = value; + } + } +} + +public class Scanner { + const char EOL = '\n'; + const int eofSym = 0; /* pdt */ +-->declarations + + static Token t; // current token + static char ch; // current input character + static int pos; // column number of current character + static int line; // line number of current character + static int lineStart; // start position of current line + static int oldEols; // EOLs that appeared in a comment; + static BitArray ignore; // set of characters to be ignored by the scanner + + static Token tokens; // the complete input token stream + static Token pt; // current peek token + + public static void Init (string fileName) { + FileStream s = null; + try { + s = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); + Init(s); + } catch (IOException) { + Console.WriteLine("--- Cannot open file {0}", fileName); + System.Environment.Exit(1); + } finally { + if (s != null) s.Close(); + } + } + + public static void Init (Stream s) { + Buffer.Fill(s); + pos = -1; line = 1; lineStart = 0; + oldEols = 0; + NextCh(); +-->initialization + //--- AW: fill token list + tokens = new Token(); // first token is a dummy + Token node = tokens; + do { + node.next = NextToken(); + node = node.next; + } while (node.kind != eofSym); + node.next = node; + node.val = "EOF"; + t = pt = tokens; + } + + static void NextCh() { + if (oldEols > 0) { ch = EOL; oldEols--; } + else { + ch = (char)Buffer.Read(); pos++; + // replace isolated '\r' by '\n' in order to make + // eol handling uniform across Windows, Unix and Mac + if (ch == '\r' && Buffer.Peek() != '\n') ch = EOL; + if (ch == EOL) { line++; lineStart = pos + 1; } + } +-->casing + } + +-->comments + + static void CheckLiteral() { +-->literals + } + + /* AW Scan() renamed to NextToken() */ + static Token NextToken() { + while (ignore[ch]) NextCh(); +-->scan1 + t = new Token(); + t.pos = pos; t.col = pos - lineStart + 1; t.line = line; + int state = start[ch]; + StringBuilder buf = new StringBuilder(16); +-->scan2 + + switch (state) { + case -1: { t.kind = eofSym; goto done; } // NextCh already done /* pdt */ + case 0: { t.kind = noSym; goto done; } // NextCh already done +-->scan3 + } + done: + t.val = buf.ToString(); + return t; + } + + /* AW 2003-03-07 get the next token, move on and synch peek token with current */ + public static Token Scan () { + t = pt = t.next; + return t; + } + + /* AW 2003-03-07 get the next token, ignore pragmas */ + public static Token Peek () { + do { // skip pragmas while peeking + pt = pt.next; + } while (pt.kind > maxT); + return pt; + } + + /* AW 2003-03-11 to make sure peek start at current scan position */ + public static void ResetPeek () { pt = t; } + +} // end Scanner + +$$$ \ No newline at end of file diff --git a/Project/Src/Parser/Frames/SharpCoco.exe b/Project/Src/Parser/Frames/SharpCoco.exe new file mode 100755 index 0000000000000000000000000000000000000000..da33326feb975d4ea07aadc5f8a3fae3d4e599fb GIT binary patch literal 81920 zcmeFadtg-6wLiYknKNhJNhS$1Aqh-C#BnAGA)^=`Ro;Ri@)Ge)fFRM3p(g>sm>3_m zz6)N8N~yJIeQT}tstyhrgHfAgMK8Jq#i3#4~3o|^{6rb z`B6*Pws+O7ck<^rt?TMmwRU#qyX#iA)j1nF>)Jc(W}dX9Ze4zLTVpI19-~<=oTb!! z!>68~J_C^ay{1Zxh!Iq(%uuRM;@&?@!&7l5=_tNT<&@>Tvh`O@;K0PFqJFge0qi%uLsG2;Fo~w$H%NH1L@QKGVQw z8u&~DpK0JT4Sc47&ouCv20qikXBzl_NCSIlU5!6lo0`h6w%n)G&J9XYEH0bU{*}Lq zCQE&Y49FXI5Ufv^Diy8_CnDKX&A<*POHo+ohUE8 zUyhUtE0k^pi@2430k`x|1U?$K5aNDAaf>N6I*YH|@@pa&ZpR?ZA$B(6G_l&JLAp{=m(%O|0PdQO)*H9T1k1LqW1Q-ID5fiqBCYi4WW>dX=>Ui)$hmHHvHvmZHD$N?vkuSX+5v-_;FMSJO2orVs zEw$d)bu*!6wNTnUS3?A$WS&0)Pe>K_^`Rh(%U)zvF7hW9i(bMlV5g+gthh*^4;{p6 ziue`=M7nGVKilvg%K=7S@+q3q4V}Qp6554?akh4D0s z3UjYa?(3gdB!D)pdY?bJ*j4?c)Bg6izhx#BOo!|sv!j5*N0B8#M$7C&(^>lEfv3n>Rbo;t<077?-gmf2(os1cnKWR#q^o>wU zy=fP-zFEmW;wzws?ZmrM;1SNQGJ7_Ibxp1e4Sx}!hx2u$%j|SXsLqX(cs80yKrEm! z>{R>Vp;}Og9bhAH^M##mH^uCMj8>U48+O?FQQ%r1l6%$oVb0Som6NeiqtPUdoj(k> z%t2RuX}DCo7hV!N6d2x-x+FX!^odlf7k&}?Brx-!nW}3pHB%Rj3!AAU8vSPK40MPz zGz5>@h*HdJz~4w8P7$-6Nfbl=)s`62r(cn4MR$y+>aHb!9M<;;cai9@Sfawp9%sfa z@kQf8$$c?$?Kj8akC6n=PxrVLgb_$VpmOIeIfw;8| zvTV!M2mw`=@Q1m=`6Iv~yOtsvG{G_uP$npqo;v^O6H8^rKG1_1~V0{667l+H^n485jRo92v5Wn6fv?Gk-fl9MLp`J?bDjBvXb?FL%bs!;0z;*&3V(K5Anq?}q)5|{(((2o={tI9 zc7tfr8;wp4-vvKv7aH&ywsE0sh6!Gn6g5;~XJ-fEcCnQD5pny_MNC|bI2&iX20ig+ z>(+3E9k(0EKbs1knEQpAE1KViFCyetM(MHhU|sk5Lbg_(kys;`Xc(T-u@r194KdBRkgLc-=7NFktq~F*~^rE8gbk zg7uT_KrSdAreU1REZL6&t!#=dslp$M`)f4w1RHeR?{fHsWUa6@i$KW7eJ##wL`$6v zdC_;Uu0I_dlXBzntm=S_(ZeBa7_)&!G-;wa?A-1u#x`jJZbt$QK{L^NCbDM&ReZ;4 zmQnELc^2*%>Ek{gOd=NFqJf|+c1nGgtn4iwM>2@VKxSieqPW(@7@PhIA}t@2`a(Pe zWr6`s8uXF|m{fDMH0eNQ`EfLO2SQ94l$$TWOflrq@Rmp<^uB`>X^W5;>?jq=hQo5l zU7GJ=asVAtW7g!x%Z^P=u2dG~K3=|mg1%o|$77F*5q2f$wpdGAvR~q6j=@_|tWbEf zVlJ|SN~f{(b0`}vgt@l6GlLxza`e$`H8hE7h+Q8x0l{C`$#7we{&iuD-b2;kc6to= zYOaS546q{k1|nRu#6;Pecr{0qo8`W8Baaw6n8t*|=0Rn#7$aPLNLyH-*N;q^K}8^& zjN5V9QprP61QXMWKs?a!UvWE)X*TUc{4p4}yWk0kt8|G<-eA!P#xcy1EE&@*8Pib4 zq@^;!pfP4Dq^yDD+*`ugqufc*D4F9Vb11pc)sie^K^w2SGnR&DdAy>zcrEclAVYFL zhA^v&H#PS6LtR!n3t@Fxx*F&ce=0C~Pp8G~G&GI*i%f|cK1ip4(w2qpi{~4P#>cqx zSL$Lf7Pz*|M?x}U^E3ndG%Z0S{|Az@X=gd$AB z>V^+Ad#)kvu%Kg{JBtFqL=r+PtJYo68c87Y(O7nz^Kg+E){zLYQ}l`);0z%)pjfEk z1(~-db5ZAMl8tnim72H~Kj~-~h^zZa_hYT#>~~4iw}C#xCVr<-;U-EMTi`kcsM&+L^*^pK5$OuYMTRrn zQnF_ZS*2?V%)M2DpVCz-Xj5|E?XnZJPzOO@9hh1l9Z=!LE}EgSKQy3?&p?{5xI-Z9 z29>?d%`eK(^{f_JGp5Tj(-=8Wt1Yvtlp3<&LG#oNO_h&bAUWM1nvqL%p*PiLx)I_=YjRbhBX*+?i*upAm@N};$@2r=J`~|s6!V8z9~Bb6 z){Td=#*B^z;d))lM&JUW?}#04(fL`STlTr=@ynAao(%u?dxcI3TR^?=P5{< z{v2Q$-P6YcXqe#qiXxArNDSrm71)`X3S=nSu=5eoQqPK8!;{IbX&~&U&UY|2)@dx) zX$MuvIhPPF3Bxm&R9}htn(bWTCM46-kvnczb2u!yYI`CHi>WSNE725q$S@1NpbKIg5p^8iJR(J6)r0(+8GH{Ttx%K zNgj~yPkqvvKajG6DE|$4JmyjyLU$sStptlTFTN!r=GjHn>(RR{KMD~=kx z6`d+;{yEo#jh&Zpi28S_+^<~j&If=*6D)pZrCQG|UzA&NEJT8+<4X|P?P|;1*zDa}w;SP^fpV=_HDBPeDSXO2vMtYBPCs>G(FnJV6? zV(2*-d3x0J$5jkwZM<*x*Fn5W-a)S9-MV4CTgR&|9gF=SP>^a9yg`uYrz&UM*AO1- z!~DdmYEJdd$Gs11tsacV8bU9%%zOvxoaiUIOp$y65kVqN&XAC=FOt)~im8@U74XO0 z`-w8W1~mOtn3M>mTd7P_jD^8tS}x0zl+Be2hJoKoWBjIcLz zfXR~?OEQ>=4BSGq9pG|(0WPkgmN83XC5$Bm%Nog@;wUoXpB16C2zIfUE%m<@foKoW zQXgQJfkuoM2~z1?_@djWdKd!i+B61M(Ga)g*knJtsFjRW_LE;odXh<>QQ-s2#`<0t zp5*E@{2{Izh!W%0fkYQJTd5(G< zW_mW(rXRVmM=8ClKxg-?Mo2~2c4aTYMQKx2IonQSaK!F;1GXs&w0L5^I-!|+$j9a) z_JwU=K|`WFaySjwcDa$Bfg9dUxg06IBwHZ86)~w$H4_vWBq#q57NDsxYe?ECSgdk- z4(zr*?7Zfd988mb`oYWUqX2sVqmyoxt2hc%9;y;@o$IC~oyPzsSZ)2#yp{eoxTOCb zLEjdjRa?+3UnFcE@jTyol5&=!?DWHk4b=zIkKmp)5;3M9LG;gX$~@;~qMb{$|3w_Q zkw-YcD#XICNGS=*g)V73AG_?C+enIk)1|559x|cl1eu|XW9Y#Kysg0{vya=DcTPh3mLGHTktDnqx7f&lWuxX zht?`;DXuGVZ3De~y+vujTfT(Am1ibZxxgyf_?92#1CoAQq#NG&S`n#fe96sJ z^{;12m9nzRReCn*yG$^Hv0@picrL_(C8ODjT5)(*BAN}P>bdLNY~*6lHD zB51O^$c`K-y3ul$vd)|dZskUZg+7%U&a6%Cl!&=~Aiy4$T@l;+C9WJ}|DGJ5gWKQ% zOBdNtl&d-yA5?x;3*@*0p?^{4hR0Gze5yo?Fc+bTtz(9S- zT$sKFP$FV3wA0rDN>!&KsVJ==?1ugF{u%X&H1ZE_CA^OGHIQL39xl3WX;2hErepK_ zN)2J>NmuTG%`c`!i~hkxKOw8~I7_jTZT4k8qVvQyq4Ocn_4HPhcEt zERJKTn5gyLqCQ9Fj$(b5`=qakZwf$cbGWwN5PSF#_l6+7vt(zFFEU7latY>Orb-&e zIV;^R@raF_XEh^MuPQgAUF1P=-Qs z*rS|UoOn07eYfP%^{|QSTG4Sg68I;F(1YJ+t5)*9yzTb9nJ)@j!ApEr8=T zXKX&;DWE1d3s#Jw(S|0p^DFrKR3f)rv|=y`9&%*Mz}K(&`tcSTMwh_&cRd_a$y_aG z5``qY=EJuwG8ZP~rGiXqyxY!}ItA^Nh3;y^g%oC3VLK_ZdMg=b1xF+So9B4ShyH|D zs1JAn#C4c@E7xicvThDBKPPdf}igGuU-CutjKNlw-q(kq5*q+0Is)_M&X5 zPHztC3Nqe?7HB5w!vic=gAaxWA>N-^KC?;curRcRc zlpRmRpyOgG6_I!(m2Aq!Bgs=|!H+1+JyZy^-aC;@ejZ)E<$n+Wt2uR65OgKDa)@~m z*KB=Xq3@624$85UKM$bghX{&=rfPKEld(ZV1ns7|i;Wq9hUjoxrpZ_n9VK(w+N5Xw zz@rB5z_EjlJ9oN$qwji{1f}qrgx+&WHV%v1!yC)uHe7z#dDEo~(RNxg=dZ;}HDPCV zjds#-FWw~%Sw%&_#MT-cnWrvQxypDTy#VPn{#;nd@2@Y#%UOXQvQ3#vXax0xShOer zH2DGOu(*_wIhV=n72V_mqEa$9SeV8-!5)w@%1yz1&d!vZyZ}mtwLw<|(hd6pbzg+{_|MC26=$Y7)uA=lz?7-ifiIEO7Kgp&% zYOl?Cdw^^hq!QAl_q(cteDvHID?Zf-b2QV7pd9uD1Qa|$nf3%8_J`*hL=Do<;XBYF zu>8CnlB8i<#mv$%c}?;+lrxUX>ADgWo?e!0tS<5%7h;=^oEsa3!Wpm$b-5ky0ab)#A>DV4#_K=;{X24K%vc z1hI~Nm7my4AVSx92>Riot*&JRk?Uh#&PQncUfy4zeIDA>F1+io$S30@uYIu#H4mBa z`Nu5mB=MTA4EGvb=nJ4I;^bwaL1%p-Hi(?Z1sIyKgC7Q zfnLY;9m*#K;cCOR9#;>p%W-YRwG-DJxabw-$8kM_ zYY#43pT36cEnFYq`WTmjUk&0a!&QZ=4p$l%OjNbx5IBE=V!|yG2`sB6u#vz<1`i`} z0fUs;>0~fQ;5G(L0v}-T&nV5=&)|Cm+9QbB>jc&@xR1a|4E~hB=9n;E42S7#Z6T?Agh;93H2XYfn{zt7-e0uL~FJb`~= za0-EyDdIbxz(xkg5;%v!8Uj}`SVrI_4EhP&$>3k0Y3E@Ee@EaR2Hzm?9R^<^(5j;% zULbHJgFhtjSOy;@@H7VRBXA>wy9nIL;0**m%HTBwzRcjo1pbM@>}IEI6x~1XWcc3h zbnv}Z-%oY6F}}!ojqh{yeVSv9rhF5f(R?58Oyc{I&QiXQaxUciaAybKu=pK z2!+GW9z@8S_44%Grbz;AWAmS3DE>!x{2`75o$B5w9)Cn3gc@_BB*7Chxehqb(0ql0 zSkgaXU626)M{yEhCN9!)X^2D2A%8lGN&bmI^Co7@kXa7JR~PhYEVY6>$+`-j7#I8$ zS~vOc+*vCe{2d}mlHy5$QnLYyLS2gtr0SmZA+%cHQ&5A%P@CWnu|w%hGZGnu=>Hd5 zR|s7)txGisWnM06frcd1 zf(lp&-KNublIqj{1}3UYs`z0}Dw(S9!q!6g@ICiqRHYAR!~IQw3J;>(2U5lF?=Zy5 zx3DS5NOL{@cBrDS1@VEcsc_DsXN~f~&-k}7iqms*8iT<%ZuVpU!@}3I?h|f&k%oyu z_>q1L`&J(X*J3$m^bzIeZrO}sG;Y9jmga_5Zuw8H4 zdCV)quV&==Tu>c%ysE?`!!Yp$;K^swXJ<-X)kjR2>$plTf+G&c)PfSWW)himJtWa0 z2_?z=5rWcOBc7VtbqWd$r!mpMN2BSpaKnc$>Cb?^oAo*?D^ZPpP&7{-xsVHq&{|uxh`>|<_M~bsJ z#01q!uS8-USt9Sw^kdJ?>Z2eP(mNiEguO`2i|AcpnXq9;$?BsZY^U46xOW0zyN5zN z)*#bpc$3o)@5i=^)jtgZ$xF{0`*EkgJ`yW2zA_c=pALx8jK?NE2vNy7g&Zq!!G}P4y$lfj!fBGR$O= zK1zwQu7qJGmmh$Q^I+q0Z`;WOc+I7PGY3R=CP-%ZmVHLJjLQx8XRz(S`LFf+&KyzC_$D3csAgqhR*_ArQtPzhimvkz||VQ3UG~vcL1){@V$UX zX!v2kBQ?AmFm{8bu%8eT*2sQBA{u$0kf=ufL`X~{c&@r0+pxj_2N15uMyeoXgp_Hd zj*vJbpH%cyopsgefgieLcp`n=7r>?;Tmr5buHm@G;(|4(sklzW1yXemu5Mfxtj_+83oA)n^|(HVYXPpa zajnO73$AbBdJ@-5xL(KgJ6yw2;1Rfv#x(=iB3vz}AmFN|GOWCo*%Uz%r<$5W0!$n~ zMu2H<%xUAxC8o8xR)7ndDh{b=_7UbR&B|baKkAm%^J;39X(%Wo9GYBK6Nh5;b0)14 z8F!&Jj1L$5dKa%2{1U>c4oO$w(D>t|l!zM>#S3Cw%@Q|e?D!gqNxLzpkJlPFvw4Wx z>HKHphDe*n;<-BgJz7jyACXHOqNbL6(C7o`pDfVVxk~99N-6OHxvnYX^0eIGc3LwO zpJ!d+hN#KFGSXBAHJWtKma3u3{J*l6R94#X30ORf^)I#ID7Os{`{&y5t5S0e(*neX zYM-zFFFs0VTNyo6vQtPN(i8?N@Hgnx!mAFiOfl2GrXg&?!0WIBTK9g+NSYrh`nkEl zsBtI*Tr9kg97^CRE~`{Xc+qBt6jmt_(+Uy8B%-Mhk&p;_1wpdtK3P(T(4F#s3s$Xr zCGA#;REB~oGQQcG3G5!oJ*ag<=|r1;MbrLYpA z6fc;aA=ntnceG$*1v^5pBLo{R*pY%o7!w^a=<#@rXFB=D^H9&sQ_}A4qp2vT@uZZ| z`VxtyVH>Zwy~A}%|NrZ^%j>Z6R@Y*6V;sKc0a%JGkf#Dl^q+vR zuuPs{^4nOl7R}u5)MF;<-Eq^~aVNnVyxZ8B>krwRvv_ZA0MR=M-t)#DIwqu^J@f$) zn788Tk-dQ^@(B8|^;eXyc=8fNp!0ID=%-^|77>x-oJ->JXBlSkeQR24(Iz3Sm%a^C zsN}UK=2l_(dZ;Q_tKR~~X$)~^CwTCief+4o%(PN5{PwvHJ-(u9vp8)~JX8M*1M}`J`r@{is`DT_KJ-99;AEX>OSQ+9EQs~iPJsqhq5dyp_C4wd1?9bwZ{vxYL zKoqH21)>K>BN_V{;fDPOhsFKE438hd%ob*qnIQB`dlvLfOXg@&HNhvV`itokWu?xN z*75O2HOxPc9fxpcdlz;b!u_Nufk-U^kq#>PHLc9A+~aTb5_t4yRpZ6ni#NX<};-;KG5Vmi(Ggqa2_yFM!4wDWh_*eXe4d!xQirzOmu zUXVAqG?yR)D2NL6qx}Jt&VTYr{qP(pNzNYB(86c8Bzh{6J6t{=PgDK|FzrD!6-;-I zWR^lcvhhfrFWQ*WP^@v7hQf{b1c^mQb&Gp)`E2KXcB|X+> zoGr*U;0sjNFByLNa){=Bftp<)`Kxo2`D0O=4`Ik-|4u#@jd&T+C#r!SJo0dP$S10J zaDEF_>OZK;yNl(*?ji66EF;-N`Z5rR?E2GEDVtu|fm5IrI+jlAV|`zZdxM7G$KAc2 z1x(Wv_iFhA5a%bwa`Chq<-%yJ^cT3QK~_x*J@|7z0G+6lJ{|xa8MYQGl(c*LJ*Z^c zM%fZa6x11xhmp-g7iPL_-pd;=R)B~MHQ}vx1SL@48W<`0$9d}zjYkL8Au2>+X9^?{ zRg;10CXU5pAg4aAs}f7^Mb(4sizeNR`Srodpm?K_cnQ2wiFhOasu=b=jr|c;!l>)% zu)rH}v10;G`;Rx^ehh3|+|5RmlPbLyc?=vu;H-p1yX>UX!S^a>Bj1NR{d})>uHt)* zvyJby&dq!u;oQmhk0``$cc8PhzbhV|@~f`VBaLA_adzyt-f>w&Z7AVz~`j-Qrhu5|!FZ_HGK9u%`Vw zNU2(&KVK^18^l*|35Vnx&f?%YvLx)f(yie`96>;`^%7?GP^nBqC4+`;Oj8g?&OMn2 z88DvVn@LJwGJGCMux3XY>Bu~~N8B<9v6H>je*@SCeI2K(FkcGfTL^3s3*Qu6^I)A3 zS=g(NVgXu5gA2$!ZKh&}GUA4nqA7=$CG3~xEhAhxmyAGd3ivPC zKL*UQ>tt}KX$%QaoeSZxjDAX*rpJv~Bb3D>NHhoWs1x&>AlW({9m!!VDMaf*>Uvm@ z42C$GrFeqhmdwgxPjX*7>xZ+V4Ro@Xose!4wN+BS_8stg;E<<&@cVXnHMcM|J$*c!NmBjMWlP&A%PS`|{8{@5>ixAz<7L3bjQKl|+{2cLSjJ z@zFX1c_%b)oDo7rG-62SXHjflQ2#tIUCaD#~~Pt_N8yB?}J>Ei7qS?UmE*k*$&SvHEITV zdM;%x4$4Fj*~1Y#urIZ+xrTjrGMx1s1Hm5*`kLQ&K8ADjjQ*0_9rJA{X<#OFb};JH%@eCso+m@{1b4W0{uxwo;hVl z>S@z3nl{-yO)=d$e&pZ?84DW@9E{6A7z@?o*cdp(@T--X02J$fXO1~}oa*sUm4k1M zNk%y{$Fl#wlyjP{U}4V195as%asFnoRHauyVtoLoRw6outlj(y?v}=IJg1dj70I5@ zHW3&{#~g7#{2fj%GBS2F%g=7@VoJmB@a5=%acO5Xn!PaN45oL%Q(&@*G!4p3WaJ@6 zCdv9}6C9ItB|Q(eR2yVEc0gN2vd8Fi1Guf62`Esk72g0z%k7dmo7V2F5P@w_pB(T5 z_v8RiBM!3Bh?=oL+VKQ&wU{niscCF{@*TvHm{T7|a-EEn;?Y>)mQNrsPQ9ay)$Hlv9x+LS;`t+{MMrlYw41C?BF|jxc~##SnCQ-Bw!|q3Y=rKvDqP z%*6NU3`cYk9-AN>RX6TgP0E>KByX6%A{)M?eloX*SwGr2q0qXKfL?CNBsIWuRIDC4 z$nJ_B})N_98#L zS9~}Y`B=2c2^Nt+fWKW#-vJ?*TOi5YK!n*_xM43A^_EPd2Y5?<2Z7e}M;#|NM{k`r zUnlE%8oQoFU1(g89oX#<@KF02o|~iB)KolX8*Cn}R41_l&x*Sqn*^M^63KlxAmG75 zTgKm;v)l#VL(EwyTF+Soq)8UuWvCz4SCm$a;d64N6Z*DK-GX|hsEve(tdof*!N)64 zq<+bu(2|ktBJar|W)Iavj*Ad4)oiElW|6r5JrrssaBXwt-YoLLh4u}1xW2)2sz^qB z`*?Ncb*^vssS$=!(+AjBEIYw70v~E$EK70!iLJhuB-dlxY_C*i=-~X# zsLF_(WrnkDg?aJ_Jx{(Db;G25zP39?@jC-D%l6KtJ4{RViDbAo`&Cb8C2YH@|8O<&V%Iu$5YEW3#j}(4E z_QmX50&L5|wH!yClHcY8v2me{1{>}@bnP&yk-A?E9w$wOq}=yBy(;Nxe9VF1s;x8$ zq?`HmPwyKMby%bH4VwRs1aIr>y+d|SQ(z~foG<1D_; zJ4STRT|NCx$dA5=rIgpn^9!v@#C zS?XNKIFtMv7fs`51n1OxwiadgZA7l#Gmy$xY^+YP+G0fpc-cpW6r(VQK5@A#hp8Th z9J3%tB3yJ-v23%)(_$O_EGVvFq&PjC&MTISMz!lh7=tM_>8@Cw9@@*=4L2A0W263X zuTzZ%xrF*MXB*}kvK-^{{c-tB%7WD|7C>Qs#Gz*>=#q!5M>1NE33b>+SC4+xZt%Ab@$^GbOB(Md+39;I zxSxUt5%AP2xn<%O2*k55=OK4u<-FlSoKRF$G<$+aKDdn2p=#N@E>x1d4g26t-$ArbB%vs*$vjVYqi6_dSY@2QfQ%oSXPlNy0lcOF@?Ohw zkQT>O8L!59hehnQoQjIe0%4fXiv=t@{TS>>50cLgH9EQbJCkQiU#4~0&r#+Hs9y`7 zUAgnbNN&CvEjn|a<%hF5nWYt{B-n;aroW3aQD`mdK2}fTb|b1Vf%{2zt?qW-`7HYC zg{Vl87bYXr?TZm$Ud7Dy+=Q5BF>l@ssuB3bAogQ&8be@sC0BijsbZF9EZCweg?O@8 zf4iw@yo$H%0N^@=A^pijDOsFKy+){bI?X_%?5dt1(cC!{A;Pu-kICpX77L2SOp<@> zdIdbmhqziID1ESo*>^-ZjG8ficPYeb5?@y`^%8K=F;s9viP$5$8y%W7%9AAH2z9vP z#zcih&-2gVh7wXiFbwdq&GpASFT)-+m%@`YCz^%5V)_zJKTZ`Lg%i8E?FP>0JbN`E zcCN9|q+_YC??L?ydO=3)#R*$|Rf;7rUzbQ;1+OU!bp93eQh zkVrYzxuBjNm2;s5&Cy5ET4^a~KNA$vobm>*R);X%6?kNc0hrb~=<|oHbDF$#nRLL-zMNX}>g)x{d)yY08>aB59)FeT+3}6|acgeIT!{3VlyDJGLVy zpNHkyr4qa#o>#|HygKIE1w8c~tnCYi)b{QnwJo}yrRH2K?M(BrHc~qN@S8~7WrpX5 z>4}%8P&_0mXl1OZ%9s8jbk%^RCe5bmu}ML99n17Qvw{w(YtavPeT| zMWo&ZeMP;iB&=duysMZPesQ4K?ju5MeL)tZzEr14<70NA-$VKyCIv$+Z0v?F7gdfE zRi=3NjqnRIIHaIhR4Ne}FeSMgDhI*osF$pwbocr$3L9!0i5{=$xpbYH)#lDSu2ggP z3f#=^yo@`1NZk1dr48pdVDPqq=cP5gb0Duu$r~+p6~7N-@|h1icFE!8 zCLgtcli8{o;c+m^(=iV?5L#fN9iE%TFZ;+N2;QV-v-}aL-JR+^+%3+chK?5VXA=YX zwzzyf?C?ax>{*3;!YRmm-n@VF7V0;h>bID(@k*%Eg=G15g^S8qNmHU&w%oID#+O-7 zLomJl_~y_HfF2=;{y zvl5v<*nwdF97G4PlR&!HhtHx_!()-17ZHy_SpBvirYe{%hh?_xS%gNi=fopY7>(Dl z5c`K@W4QpejUfTxnlUXPcUu&OULkB4CJQ1Oilez+`9wshEf6XqQ+T`q z1filLl-R?Yu01&AusmK46_tBb#KbhF z@_MIS%|FYvuZvXoA6)oyW9|FydM9W6I$;ij%HVT+>IK{vLVafbTvQi6JCcaV-K*|AXSgr+f})U?K?P-?cErvrWQdkdJP@_7}L zanGI|N-b|Sca+r)iN{^P&q@j zfPxH-NbU?Kmq&vEej((znKVS7kaQNp0`!@a*TYUT6H;M5Nwt3qVeVsm_dP0KFRgp= z{QV|Mh0HW&VT@8uq#I{BS>NZN4moo=Y|Dw$UjZ>4VBJBs7oKQPzhoGHev_ z$@csZ+#LTN)rIz~;Yyj#9n&2&*d-14?35hBprM%KgGG{@)tAmx%{`g3g&ZX{*1chNREjg0FpOW<&)9V z&<3c^LU5v=3m}ei;5$LiC*Y!~vGhjGxpVfxL@j!A+5{0~HgaeV z#eCJ0wtR>*Nx2>=+z|3y3v))-zDJsU_o9NfY;*B46P;Fmr509fb1LsTHUB5WCcl#; z<4rL!dBE)xZB%*Kk^CAPOh4x1muM5|SHKs?IsXDTofye|&KJ&3ke6BYLKDZEv0dG3 z>yy8AD%S0I-<5c{uQ4|K*!3x>0q>ogyqAH8fzoT8+o{^@Anf5yUB&57G&|3`Ho)&= zp9=1>BQ#!$e-K$Enp<3cUz9%KPK+-dB%ofH-FGm1$QHa%?g1||4de2hbFQByAE{31 zch`zOe)nnc-W7hWu`o};OJE*JtA+bJ;4aZcN%c(XseiCeojT9m!}6 z#G%n)h5C)^6QE)Ix-jp-(4DTYAnvz1zRJK?(zve1)#=0Azp$j1VIY!D&XVeP4Nj;2 zM8Az&G1!Da3Yx_*M{0Ts`7E^rD((^t6_X3JmqW z#O)A>9}nU+$8BT>wICZSY-SI^Cg5qxV~Arzf#YC#Dv%o&;$Qx!cGyO9Z z%b%wV^E8mNmza~kHp4B|Xi4dMENC+Q0Pu)VAG?y` zz2gf>#jh6WOLaNf+4^PV%20h=vYE|pT1Fx&DT3AT>3jmZ(X_AFjN))WAAX>c3ic)U z1=7Dn;aMCiP7%D4F2tfT_?>hbpQOBcR{(EhL7lGine-Z7W)cb<{wFyLL@hN~cqEGr zj3RPEG6l>%?L`JTWHBwTK>dQjsz{1REYJKQ80+Ce%IS)u_20k9odMV)#NIK8^N2QP-6gJ$mOXE zvH}Nel&$#-zq4VfUqc0$XvFzE?1}qF)P8g>WI*8v;3nT&rGj2h!Dt{eXtFH(;l{pNCeDbOs#D7eH&tk@FlMNx>CrQ#8 z7V|`_7C%eQMQ=nFy_Y1umpmm3#?&A@sYljdL%jnhxeJPOpJ5-Zu6#n)T_^P2hjPp` zOg@|V#KQ0J((^?hzo)=s=Q1SoBeCLp3UOGB?h_9{F7IebJ<#rHL!N5(&{97CQW_~v z52XL}dkU8N7PQZDoKldZ1#=hW9mef`^8HfOn=B9wiZaLGohF&+2m${P6v-lDR_Qs= z8OTvJ=;;R=m*gt^{uiS>UzfV@PZ9rvdBL`?73U=HL-r-GwM3YI_G<8KQIA!BMJ?D# z<0$=;-HOB3mS|h!jiMNSF8NeSOrkage}9zDiC>pu%L%#>Jln@F+vs@ul|n8;TT#Pp zSi%owLY_Hm@&JCHi@BB%SJI+eOr;yai@M@W_PA=^j@J9>N2?WIcK4I~m{IWSxpAhJ zxdNI2a|OIXVL7$n$a5NOh@oqR8^#xZ%n5H1;!*Nc#5xlOlZBnd6ormw2i!xh`f063 ztKh5Lq=QOIdCJWm3&{^TB|{-+KO&vi5ac(Y2>C6i(7+rX$k!Z(lovgyeWM8Q!F{R2_lLd745BGmH( zQJh-*fvCo#p)6vRehq>AUKDd?x_|V0QA~Lq3J?*U=>=}TB5unID15B#Y;;jEqAft> zfdltf@*U2u0VKTK;=@(gRORQOSlBm+AOCs~i|}Pq)}UVx;tH_qqv?)x+}VJ5&r{(E zR$063eJHh2&3sH?Q~d(JY2!X?_bXZpp$Eo!56gKN(#e(`RxU+v!7dql+j~ivbx_T?_4|Y6mnvJy7;(MxXT{3^GSgQAD$Mwnb3q}AA612e>e2u z>!*G+jF;V&{bWv9;L(2CkI?The(3K8X}y{{@md2~g%7 z6d>-rAwaqFdjTq(zY0+4*vF8psbNmJ010P|07+h}BB{!0mYCtrbOEZJ1p?GKrwLH& ztQ25`;|MU)xln+VbBO?T&Ncx?IXeUx?d%fZFy~N^UCd6#Dk;7dvD)(*SYe!C?RPpN-2JRDaChl*vsJ+9Nxg;eH^~PloQHG zhDBwR>pF(N%J8imKF{G_%U&bUI{-qV< zESEBz?lJ<_p##jm3pRhTM;iPfK7BZH^J|d+p zW$bWxX~IrtY`j{=SSw@4;Me0QZ7pL{)C!z0igVI{h43!Xd5raGEYFlzGvz#-#7+6G zXY3@L`9RoL7+b71Gq#JdH8`)E((YjF3;431u=^OhLTzX4L5PyEK)N2Nr0zj{Yipbn>_+x-CZe!<4YT`ZvzMkQKi z1c!A-5^%jygRt31A)H{0M%c!w?HsP-aJ|vOsYL%1rkQ}41kRybftY>9YES$Mj_*ax zyT-)`KjiRFnt!ia)^C`V2>s@b2!jX{DuS4V8fK10SjS<8W9FM*N6cB~H!%5MXQ8znr~A$*P3A_)Itsy+sC7S zUy68JeUU?wd0GF}fS2`e=kRL?6Y3FrF>?KY!)G~s&0dDQ?{Y3_@!#51$KTs`A^e!* z%>Y?Nl*2vT%EmxS7K~4zEI(P&Wjq7GDiKFi7$V2FbiDK;a!6-orAtvu(FPC$_pD99&z? z`blPypX@oVe#yDs=I~vF%ldB$QiEM+A)&$n6VVIl-~*lp3N8+{#wA+!b^@hoG7=e1IBuc600?K(AbF6$+j`J zRsFAV8ODssSm8)*ufp=Wi?OZhTJt`PRkvtt3$WqpA&uQ&K8Ww)r=}_2R&|T{D1O0V zx5n-QWvzOPvF$iP=W%%JXRvl4S-uNwq?(DPF6DdDd=k4en>6-Q^T)s*)z~ZMUNuIo zpa~Bse`D?g_JGFzgtW2hj7CX|`VIoado@fs%=ce-IzMNeVAa0g;dynmNwBfLKVt^< z24mY5mNLdTH3i!cRKiqW&={}YV{E&c=PSd6Y$0ZJl(yWLFpg49IlFp@6Vu|rf!@j zm}N~frm2@16T6FS=PM7dqnf$|LX24mC?uNY^j zGqH>1`ku4Z6vnnzy;HguZ|=7ZNLyFH-Zsuw7c#b8E%pD|SfTFJ*xCMRMyqN$Q_5TI z|EsZ5ovyKV#x`lJ)33~x>T$t>n~=6zJ*BaJ|4qQ&VN9&2P5oY{Jq^k>^;g00(=OA1 z-Fp_5w^hB2`mIqdXAAaof81Q7qALV@gVWZp6zoI)FiLADY`gj&#?l&VXKabalubM@ zJC7(umNjZ6W1^)slmK5$Y1QB<*waR(Jq7b!7n@+$nVbofPaD(ithrvNNxsh)C@byp zW>*25V7HhX3mE0=QP(h|?O3BsGcHs+L>9Hue#PijPid^no@e%}F&&guq`p+WEot1g zm#X?g+7$dY@?6HAR^tO_nU|}zg|wBx((8!Jc6_DVZeFS0W9&`ixIo^#N?DzhCYrcf zWf-IK9x|_1s|wg|^E$PmfK5?b)E61suD%`kq4{s>R*mfjwoN^!u^$5avRatu64Xxv z&zjp+yT-2Y@4>izC1cywe*_*^H>q1R_Htk^PVl?XDN43OrC6n+i5=?b0=CcGq2?8^ zgXT`Pnz8Nbw}Cgzud3Y|`%B;*^JX=*n|N-=TY>MGx2PL6mJGgO?o#h*>~LVWsybRe zgR%+OZEC*8jtRbGd_%pcvEze#vHEyVV@ra+H*Z(lxUof_cc|MK+pf+Eer(>M_GoN1 zusfAHUrJaP`~-9KqcqkH>>kyjv0h;JsoOO6#h~r`rg~0eTY@FNZ>bwM5f{Q#-=X#a@%17kFXH~Jn`WALPpdgCL(2l2J;ql|4= zPocJtsVP02#y0qvS}2$*3mxNoOkHsyrBQ9C`gW@i7~86np}p#HwY!(|sl!7r8IP-N z*b|`=nnGp96Kdf_f=vYF_tb6ug3SpX@B1E|h={+fY6&JADeds%&;u}+-8^Pg(ZzX_M~QQkiF z-ZsImU~Kgbf?W$a_o-uV6wJby`ZIMlV`76pQ;Qgr9`G}DP9g1!zMrZ7LcVFnE9yCo z-4C7z)GGySm+$B5HyV2gX}?e(6|h~Hy_q*j=?_7&*Hnqdo?xt+F_GmpHHNXRYFOkZ z<25y3W3`bVny;%Z8l(BruT<3z;<;6gjXdD{wW|G!U`I#VF+a3+3N|hBvH2UdLSyqI zkNDnFFBh-}v4^npt3tUn@}PQGRoyJu%E7wk^Prrbf;cJ(dBUb{=M#~HivZow?;dEW=>3-=Kwn)tnXh|{E1 zevf!V-5jIvLr=KfPcffxOq)SFh4j6#Ppv~}U^jq5Y%Vd4i7;M5=NZ@I*H(Pk6)EQ3 z2iU~!2gT3{8!pc|oOdHaQ}rP9sXuY5la&o0lZCSVF&+kV-VwE-uAe7QsGs zMgcuAe+H&prn-_#B-u>u8AMLuDYotHr&PMBws0$Rkp3w3 zlDgNH57eQlBu1=AN|Am|E$Hg%XykI`^l}sWVvJjB(y&iW;j%=xJD9_FO5->gzEzbO zFZtRL?)QD3;msUg%;A+BZsqVM4!_RfT^xRk!|x#c1!f^-#@m=F&<@oribmDf)wg25 z_PwqikG+lX+1UF&ir>qrANf91{}ua-FU0ht)E{FpYm_oe>JSp2Q7Tw6#`(N7WGO<9=haEv7$0aviIveTw z$wde$*Qv~(_}pO4RSzTPb@ly{w|%43Pf+4qNOh!tl<^RAcnBPhG=2^m;x^SkSA9@2 z-#^~?gk%Oyhc(^^moD~CG*YEyieeBl&kt2o>0cnvtWpPS-$kX*pzg~{A6KudeCb){ zk&s~%;;%2g+)wbe{_zOE>?iu2DE$fWiDK7dH)8gc{u(-@*~}uAe35#i^c6p8Yz!oy zRa$OSILjto&9kG3Ut(`&U0rEBTy~~?By@ES!qxus><`u6vYU(}nLlaoZ9H9&@Qu>1 zV8?kx{8n(gyyQ`PE=tLpudCw%F9Rmck5XTV&&9JqS_{rq--z!CkW?S}zGJ))j|S(e z*W$y1&vLoX8h?zP2RK;rivL;TZ}IiPR}9kI>#DN+Ec11yA${H#B#lvcfB2!`C^fr$ zzi$z1ZxQtTOz=aatGv$o(C9(9)%ZgB!Qkua`ttt?2C-Z5Z?Ntac;@3%t8r9bP;FE5 zF-l>d7U52{#0aWe)X7E(&U!ly@SS)IIf(Zlwjg{}y>Iw19}1g3^%3X&7oA26;!_>gfe!bgqk5$-l_K=^%Q zC&H(UuOocMxENcrfo3OIkjK)>)Y0o){m`MtY28~S|3_}wS4}Fzt(@4ztKO-zs%q2Z};Eof71Vq|7HI#{qOic z@PF(#?3g{=9&I0EPqDk~P4-3hW%j-H_v}~f|FKoTABYBq1;zx%2POyR1QrBN4y+Aa z8n`BKL*SmkBZ21v{~7QF#|DoJ&I_&#ZVcWY+#P%&_+HS!x!V!Q9EGP;>Iy$5CU`~8 zMitJ4CJl8KLK9ZwR}cCB%^n#X9h|cqzuTl%U{B`(W%ZL^R%&kr1g6l? z&-#+s^{>Isb1km7@x*~Crkt2xy`iJ+ShZwrtFwMaepSA)ZBv^fK(%%^o_pSg#;&gO z8yR2H-P+xzrmgC3&v&Y&t@)LUER9I zZJn!6TBBBVZ&ICYo4VDs)vI;F%(m{?$&2d^cBaM^+nzij~gz52Z-NJ%frAu{jOU+Y=c@>BN+{H(rh(jv6??yt!v$+SuqoaSrZ26!E7Hn9zvdtm$ zlI+YIcHX(M&FNm6*LhBC?OwIEZ8g<|!TD70)(*8~eFvIOx8h02($Tse6z8>_+}Zy5 z4KOy?hGs#sK?Mbd=e5C}+MIRmo$XyPSG5o?$+)yIZd7b~e)VQ0Aa}YM`SqJ;L-}p! zdEJztrRY-J4pJ#JR0kl)j&39Ix=+sSZ11MlU#ga>O$z0rlg>ohs?BlGIcMjcb*-BUmb6j7qt146 z7hVFI*|w?!&9bV4BFVi>>+W_q5*(LOcSC-st*eXDV9lJw9;OHpg<1j=Md55S=rn36 zG^rN1b>%xYwlTr%R_@}&zkMZa4(7&cV`favkS0SCKDj;*O@ud6yVNQ;qz;&s+K4u8 z!}q}}H}EwdhQ0CM9wO*(FQsuxu0vx4E4gQHGj3t!s1VDyR-#Q!zZFwWDKY>#FnA^tN-_J2ly? z&ea-PMfDb+j@DY$ww@buX4{%pa3G%#%RqbU2w0ZjE8EUd9nc@zzN>(3?SkSui;;6$yViEIQ|~5iQLBJLbyDk`!$S$j&!c8tO}>C> z+3itdZB}dGgY)OBPK-CLFcfL2b#$Yi&n-yZmUIj=Zd;m%9H8bpp!FPeez$7v+^pKx zqluwKwDUUE3O%x0%%ky~u8xfm8eOYHJj*Jo0NRFJ7!t_sbS}lfu{wV~oaly?YQuV% z9|k)(FY%!Orhz4HJP0mC?_~R9harw@^@erpHgjr+a@haO<^c`a$QdDfo70I7w~>aw z^V*iQ!8dhcC?#Yr(xfjEc9OIvYTe$&BQZKoQC`RZpCx5NKTGo>As41*b+nP2f`Na2 z12x&)&Q%>7sD5*)$-3A{Y*^WiF}zzlJ9OYxaQf)TOWH4J6UzX-)P@?7{TKCd>g$4# z^?(M7CXYZ(B^?GWytMp+U=xmCq1oB zD>!!9UBq^oDm#fM-I66V3nV0j1V}A33l>PQ7+?iRz!HgBjKqc=Adq0e0>Ne$Y-qmk zoOgX+RlQ25dw~#CDz19({+xUM@44sRdZlIBWFBe*yPkr~sTfmB+5op&YrfCIq#X{e zwTC#M&E5{$(i?5F!$M`cTwUFR zJ4I}@wiiuA^YasCbLtY@w4^ssg__i_35Z>#&dV#%H^7 zdv1PaVd{e!p>{-KH+j>)%JgOh-kDPuM_Zn{CA&bMhQ<#X9zXXu!B8Pe^goE}%z{;I zsw`xTqFPYf*U4jUdyTOy0*0k$Wz6po%g+8%Wv{w=IKu*Ng_ENo>fjUtN!W~R!OQeY ztu(*#xCCw2d72??X#S6b zW^sfp8YmnFkYHsLK*DXq9v*M*V-yBzHtFp#h>t3uY%BXqu$1Pi2e3`dw#^mOaOZo~ z1Yq!8YbB`SlY~Ctpo+A)Dk8JFf|>>=npCm9Uf$R<@6=pfM1WW=tG{ZlTrTg%`49!N z#qtVfSB6^*4j=DrY)~tGZ!3cuVYLM7ih3<#zAJB)5V3FVfV*%;)u-iE)LVf%&qXl! zxn9*gxTvENxLbZ)#(Wne^Kd05SS$e6Hi8!hr8@0Yb{?r4MGu)@sqIo%pCi0l+Iw8H z7VxSUCuL^)X}Mb2*7%UY2J}=-hEA6E@a|h!fv?bpU`aJsga{GUO(d$TuIwCAcz18t zlXJI<)2|UvG*&ZQZ|#*g*RTqh+S$RJTw1EZDdbNVpP=&NHnwBWUWZ%dti6Z@b z4b}_4iRB7_tijZ)Pw=6&8f`f8AIlVmSOwTJImP7&XYyP7T;$Ebe{wEE@NuWK8@p3D zd(|qfol6h~M>2=dcBfKPw`7-Kj|-e*J+P|5)K#hOlZ;hF$h0s7J}^dFGsZcTz=M@) zS>Y{L%UjxxdZZUqt56sX6tPx8C;?zQoI?;xR(5ZL#x);G&E56aSU_Q!y8$P68!>6M zw8M{E6==%Jwm?bdwlSBlP_ejB#V>k~uWH=;4qWe3EOO>Jk5M~RH@Si>Z`R&@F*R|m zICXn+V(jYl%%!nQS1;ZgyLRdF<*{2=u3fn@efi477@LsDE@n%cJ8(W? zOW&yQcDb~rh}(X+r>5xj-2ZqGO>Isby?YJ+4?|VO1>a zw762;|HUSBu3Q8<%hi3zQ7K}qGI8Z4G+my!)I`!GU{oyiV6@7ri=eTTVOYH}AsdsJ ztPvR6oI?ed%HHl4oRM(e;$*&9+JbUIyFpcLLTZzu42~GX>xeJFmUp*dUQx+%#W=K7 zsX|N|J0s`e5)5icm>V!BMOMMNc)4;P#)fIMitlD%s#)1m7+%JhGBJ#lYZ@289x*dv zs;A{Rj>e2EUbqWup$TD3{WRX*DsMvwOQn@6=Gw*5&L-#jby}0i*=ecZheImzmMls^ z&d3zL%dvs0OE`^KkV(0K*G2xW(eW{a_!a!E$QGVqhou3oR&f;!v8JiCZw!lBP-$)6 zd;vIL0AdMcRlq@1fV(x^L!Hou?`tBz@^AOmZEoQ9Z8UJ`732k8cQGhrsc3wm;O^)U zTR>?ASK~l`S?-`;QfosY4x@%K9AX7La44C;`WB6Z7VyJB#)>Dvfp{-O%y_pBwr55G z__3ESS<>q=#^1nKY;3#-fU*f%*U)wqhr>u8nMp<&^Vq(C`_E9qPsi*6ILJGL7pHIv z?dn^uK-|0FC;7+E?HJCtwKZ`dyaEokm38D@D9bw9Vy%w%XQ)B!hZeP1U&^2Wz8Dtl zUBg!}w$W+@Nst2QB(^)i-E((N`^4#>Vs4=oaU^~w`2tGU(bnUWguy+9R*!*$LVC*J zWgKH1w8YC(OMJKFvC>JNt>79-i5R}$Z|JcKnks-v#YW%@{3xjssHT}T!&pN33Tn5t z-8kBlCp4~tmQ(Wga7AeoQhf_jPkcBUA<%sIS3o)S!db!^?ui98hi11QQNU~0b_G|> z?UJY<{KtSnYE17)-%}lf+C%Iq>ZG!{sWY4 z0xG#T4!o$#!N<)u=d{eAnl6*q#Cl74Yf`4IQUVh?exv2ehlZ2q6y-*}V{qlIn-)nv z(Nd_RRJsM3N= zQz>!BO(!9aL7gXupQ$X#A=3pXS?|T`JbVc>D1dQn`6KK7D1Qyc#A`i_^nr~@tF($$5^p&k&GB|@!f_yv= zE0_cyA+bKYzlb}0U!VhWJlh&VeU0l|Kqvy4^qa;pK+*f0x5yIYhO@OFwxX?>5A3@M zDba7ggyQ2Fd=(}GUeaRDV2kxSXd)hR!fG;*I5}-}lVWOWygq|*klM!IrtMxlBCvf zCTWuWTdr-K5$EJw3&F%$mjG?TLwiMdcU=z)yBjg3B{&6}L1cYfm8@Pl)?pXc?>c_h z)WP#qC-5s{t-znFM_@0`moVC*XRD~{T3pYl-J%7XKd7LvnJq$~O4AqC8w2N5TD?G-rY2+~4M>fU|ckyQWK+RH(OL=IeM_Bzdo??K$u^*<}QwQ6_3D zFVT=L(k~y=5pi6~(8XVrBV!vs_tKBj^>B{koa5p<;>XzD$HFes4W^Awwlu3Vz2Q1> z7qj0J9g#5sb;9CCQuG+GO6c zxW|Gns)iDOk10y;IEpghlwmNhqi+DR`3UkbsfJQEN-&pw=;1i+qa56|Z)+2kX`9n^ z;{>JXN&s=jL;UvI>wR_xKB-wx7`-ha%Gy%x_xxN#`8N1K3zL!Nex`fWFF|f>T-Q6B zxFgMuTU^=DTHRXQO~IUwxgvW4AK)Xy&6ZQN;&7}LZVxd=+a7XiP`YN; zISt8i?P;qE+L*1kTEhyiC-ubMtZGZ)C0JmkcdQvpuD=C`%`B*qsU+ykr%(#?2IfDS zJw+Kh!{|3aifRn`lZ0f{P;(jN)}`@V)Qg^qYdOvuoO|#viLng$>PpR@(N}S0_8fU8 z=VzGMg0;PFqtmlkL}@r%&H~U74($&S`HyQ0^M0!F5_4S0luXp40H66qxI|r9G!mL;Ch( z@h;$F1^@*If_3g}}n%hBANHJ2fHk-JpAvk8Gq`=nA7Oez1 zD|ebQA%RA5hhF)lTV+mz!lWofLR)LfIr{JV8P9oP+P19)&8jVab8$*sHP>rTflt?G2pR)f2`B4r**kPZI~9Al(VpX2iL zr}GMpD^1#h#boQilKq*Vv{{|;FSBhGlvsYk^hxj&o;Xp0nzH&uvts5tYHCS1i=eX% zSG~lNnJkWyY)3vb#?`kUIhiKxT0uvtFN9aYC#iPSSv6eET4`R&k^TJ6IWcGLyJcPgMK<4d6 z66_@HOY}gGlD$JAwqh`uIM2|?FOvv0B@zB*FH4(;sNVkiP##gxxQW^P4%OO z>ylcDd8-5*PB?u?sC)Aib`kDk|KOg?!7^wUr@+~!k;YD;#Uff3krACntTu=11=vtx z>*J>onY5}IPp%m`h0zxPKe69A;yEi*z+p}`Gk zh%H(ja)&astx2P(?qfE7$L)@Iv=!0B5#5D%jEnF3GrED@Tf&|eVR-*8(J0=N zONM*r^x4wIp3)ch!_pV`xH9Bnd*3Rdc|FNEk0cpq-_k`(mi~IXlpe;zpb!tL^5LTej6UcB=o7sTYd+WSp&D)ZWYza4d13diggxB z9q_yMjK{d|w~bf~>!}{U<0w7Un)CS4E@b|W`SSRc9JiB4Ji%fZG4kbkA}Nzk{}ZpE zY#7-#-o8e1#Ko<6B^l}|*ASB7>WTU-8Di@_lMy{AK^gfh+^cIJZAg1@8YOMO1dc~Zwe9sBgxj~$#a4fB?8UQeEI9MgX% zE5dpgr6z}9jCjoB#dAE*VD;S4H(%{y59_Ir)Us$Pw$haw#MAANy6g+}h&d-_Q#f0i zHu0Wbg%JvC;VqZyds7PZAhx>aNeat`Sx$#~P%lI4&E3CPrsR(Ck|);~n|rTH@6S~* zb<*eTh=;WyG%s_x`hn88gE1LTSRSG=&tX|L@8Q7fgWs`ZI}|hlJ65=bJMYPmJw=6J z$IoZZ*C(}XDq2ThrpU-xOD-led|c%6UASk1?KVSkJ5E*hhe5YQXHg%QU;ZsuPxv zazM{pw8jNsn4BZ>8REznYI|qd9L4X&S)PbgQ-3KnWM<|F|7GoIWz5CWLb(UdXo&AD zjpw7}G@+c=lT&UEq$hX&N2B6?;!AncBY>Z{cl$Q#{f_fJ=_MzYVzyYo+RpiHL`J&P zmgEtGPib(J$IGG@o`u`dQRxlv{RP!8f0CH^n6EL+oK)r9G+@8%WG-9U%q3@&@JlKS z204oHlKfM?A>!vr8W|+F%=?T3OFfeo?Yq+SInz-_E;9A24d0Ivu$|4|qi=Jf!f7kz zPgumqc0vx}o<1GZe6L-nq8a8C`bj@$58Cw&{2>zysvB3jlA}e$SGIDEKEr03xKHsE zH^Oi;mJD)jPM2%?uV*%Tye`TJy?Xur7%?-;kmJlPawgn`9M)rdlQQJ@*{rS3id{Te zA)}m~o~xydtGA@Q{CYFm-$T~a`xAf45B<-@Yd!)T=678Su4`<@*0BbkDQ7q$&kCNz zpJdKPCxK*&*0YVQ2-ma@f}Q?&6&xY2(OTqz={Yz;J-?#!D2NWZ+k&xkj0x(_gB+_b zIc(X_^C2;*T%)Z~GX4xrYwYWKc5wtb?MH3ZPx|Y*C08AHnVm2Vr|)O9;kb1^;x<3+ z>>X1voDS@u%(K}YW;d6|Ivg7waALn#>kh(J^Cmtf~X;F8TzOpf! zLXTsoOIq~{BJbEL3)89}PJIm4*XgN}a2zuy;?(|e&`n<(-A6f$`cWEpLOFwb>SBI) zkhHz4`ew4ksgCGm0z*80`-kx}^d|0i!HH-cXC9cAi?W<=%b=1aoUN&cHhUre*F}0H!<`#y0KdQqT$&mjcd?~I?OeL;M&;%_q8osL(S2Bz9J6sYjMfh%w(Q|QL`Y!$oYU0 z*v6=)%fx`Yw}QE;taArqG+c9yNU9|?55V?zipF9&$+%M-(nTBQ+{u-9Y&?`>oRIH; zGiaY2owVu+4xMiuM#>BHp_Di}Icry%wHtIk$$w!_LPp7WvNN&|(VDxj0=fT^@|QfY zc!WA&z7@YoiI!Gl>qADGN z4Os%t^zqXjRF|F_FpPApkD5rjO@sWoC_xQRGugKuWQdwfp7EP`wth#p1Z`N#MVGsC zXBe!`txI`ls~PGn^EVdLNDr@QjpU(=izVb0G@{Sq)Ch+Rzm=qtL@t%`F{yAryTKCr zSjMl6^NgQ3RKx2q5Y`2oD6RIhtcdbGRH z5v0>;EjZd)kbF)rb3G^@$ma&~#R2wy4S%_?kP7lSKoWeUyYc>7K8K3oRCg9-+5Bu8 zz4Ej9*;FTfMf0mvcSouZKfNkwGlak6_?zuS!w%w^&*8Eo%X_>@zW0c91^M25FVN}0 z1K2{rXubIy$LY<_W(1(|2{c$Si*_uTO&t~#QIRiZ^F@VTj5-YD2T-2M;}hj6#U6mP z&2TqC4X1%aKnjA9G=Fmt7Xf}_78e(6-lHAc8r1n#`Y|RHECyuMX>kb%!INYIyn)s; zgiGM5G=Av-Z0?qh6sQA5;O$NOn75A{haX6jwt?&b+Jix}Xiwp!yN{;$++FD`5Z+f` z5&B3M04t{mJd3Neq|pX7-C$peEIrdzNCm^M9Vv9>M*t>&a<~f+@*^hnY*d~_Ik3Hi zzwg@)Z@vWP0cnYd?rul~Rg7~RtzV+~} zmv4B&o^)pM1{AX)G$oxcrn`Y*IzJ1@Dbkz5bqY7x{7uz1=#rw$20?zF?8(pP=W&;x zr^M1Keds`>1^85%=E!#Z-W#B2q0(r+jGuACyJ}q)wlR`QLtS!IC|2Nt9~jRSQ-QR; zs8T`IC_xixDjr5+Ij~mvz*`Y6=8JhZ(en7JEfd)>J2IRC$nN}@VtCV_VqDW>Py&=w zAPP;%<3Qh1BtN%;(v+5_VY`&JHXDWzvSHYT`)sy5R3%5xRGQbh`~W|W=8r;x5Ij&% zb%r!Mye)SZlmyBMCri~Ngl>l2-#t30y^NwyGPR0DWY8n zI?`QuN@Kc%5XQo=1Kq%4g_KQ)odlRw@V$o8KsJO&qD|rjPO{%XE(}L#@c83vAm7^& z2I;;qOs8SCyoYIrDH!+>fYg4Fol=Uf9ZLN`n1)Dl5W)bQQ!o4*>d}`3_NIX8a5@*J zaf$k)Bg6J0vpc%OPEe5Uf(tzO64a-TfQ%xp^9Mg7MMZQWDFdLG+|OpSeTB{-n>+Zu z+`%8@4t}hx%%-RXEClsn>3^jkEFpbbjs$3^27PwFfwV#1ug;TK_7d<5F^fK zQ=p+UWHDe34<7-qpz|1!?QlVKa@qVc(8)p_^YcAmQ5qWFktUa+9vl__(r7rJznPys z8up^)O}IxIn7vdU^9Ey?7MKE}A)FWSRds;~bDJ6HWB%YLxr3jADM!LWM|z|yt$l~c zTL_xMJEQW4ry9y1{4Ed&-6tp*#LwiVLFS+g3Lni6$ z$*>=|E~CVWD(x=#3CUpWkt`9IB{H;L@FYJEBB5d631Mo(UWjg4L7`VB1PKbtila8< zF6K49qYt>=fYZ-~87-Ia-fanQ34Jlw@bVrRHo=|zJX)ruS z4S_C?0tEij`G@)Q+N-!Ayh@nJ`FCXm+O=MMfUP3!v!t~*9BNsr`bUkiKCU=%MP ziZT>Il|e9YBAyENJ7FfWpE@D|{?JsY9I%mpeJdQyAN-4A2iM3?@H-~Kh$3S@P^5v; z@zOpf4#4LYStvst~ zC;92E=^3_7;SUdwmD$sQ%nk;4;#YC$$M3xVv*|xS{|mqN<%`$;`mciDXOGplAL?U> zilwKe&C1S0JR$4hGM+9|vtm9DR?F~slZX0nBws$hv-TLjyJq78l>7s)3%qLn_cw>_ z9!*!OGtW!<6jptHYpFE8hKGvq-&dnjxT#m|w>Agb9B6Z(&4D%t+8k(epv{3c2ihF? z|IUE`zt}AJom@Gn=L8o<$b2T0v)wHIzJD{oZQ+ouJ z;aJo$?ndS023tG&+_uuo$0{nF_W;9xEx3`|ucLKVVN8KP-1gzu&+KcH-xLn{*8bP# zK$` + /// Parser interface. + /// + public interface IParser : IDisposable + { + Parser.Errors Errors { + get; + } + + Parser.ILexer Lexer { + get; + } + + CompilationUnit CompilationUnit { + get; + } + + bool ParseMethodBodies { + get; set; + } + + void Parse(); + + Expression ParseExpression(); + TypeReference ParseTypeReference (); + BlockStatement ParseBlock(); + List ParseTypeMembers(); + } +} diff --git a/Project/Src/Parser/ModifierList.cs b/Project/Src/Parser/ModifierList.cs new file mode 100644 index 0000000000..f85ee2b332 --- /dev/null +++ b/Project/Src/Parser/ModifierList.cs @@ -0,0 +1,69 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using ICSharpCode.NRefactory.Ast; + +namespace ICSharpCode.NRefactory.Parser +{ + internal class ModifierList + { + Modifiers cur; + Location location = new Location(-1, -1); + + public Modifiers Modifier { + get { + return cur; + } + } + + public Location GetDeclarationLocation(Location keywordLocation) + { + if(location.IsEmpty) { + return keywordLocation; + } + return location; + } + +// public Location Location { +// get { +// return location; +// } +// set { +// location = value; +// } +// } + + public bool isNone { get { return cur == Modifiers.None; } } + + public bool Contains(Modifiers m) + { + return ((cur & m) != 0); + } + + public void Add(Modifiers m, Location tokenLocation) + { + if(location.IsEmpty) { + location = tokenLocation; + } + + if ((cur & m) == 0) { + cur |= m; + } else { +// parser.Error("modifier " + m + " already defined"); + } + } + +// public void Add(Modifiers m) +// { +// Add(m.cur, m.Location); +// } + + public void Check(Modifiers allowed) + { + Modifiers wrong = cur & ~allowed; + if (wrong != Modifiers.None) { +// parser.Error("modifier(s) " + wrong + " not allowed here"); + } + } + } +} diff --git a/Project/Src/Parser/VBNet/ParamModifierList.cs b/Project/Src/Parser/VBNet/ParamModifierList.cs new file mode 100644 index 0000000000..8a55cdf946 --- /dev/null +++ b/Project/Src/Parser/VBNet/ParamModifierList.cs @@ -0,0 +1,49 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using ICSharpCode.NRefactory.Ast; + +namespace ICSharpCode.NRefactory.Parser.VB +{ + internal class ParamModifierList + { + ParameterModifiers cur; + Parser parser; + + public ParameterModifiers Modifier { + get { + return cur; + } + } + + public ParamModifierList(Parser parser) + { + this.parser = parser; + cur = ParameterModifiers.None; + } + + public bool isNone { get { return cur == ParameterModifiers.None; } } + + public void Add(ParameterModifiers m) + { + if ((cur & m) == 0) { + cur |= m; + } else { + parser.Error("param modifier " + m + " already defined"); + } + } + + public void Add(ParamModifierList m) + { + Add(m.cur); + } + + public void Check() + { + if((cur & ParameterModifiers.In) != 0 && + (cur & ParameterModifiers.Ref) != 0) { + parser.Error("ByRef and ByVal are not allowed at the same time."); + } + } + } +} diff --git a/Project/Src/Parser/VBNet/Parser.cs b/Project/Src/Parser/VBNet/Parser.cs new file mode 100644 index 0000000000..d5f5a8c3b1 --- /dev/null +++ b/Project/Src/Parser/VBNet/Parser.cs @@ -0,0 +1,8141 @@ + +#line 1 "VBNET.ATG" +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.Text; +using ICSharpCode.NRefactory.Ast; +using ICSharpCode.NRefactory.Parser.VB; +using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute; +/* + Parser.frame file for NRefactory. + */ +using System; +using System.Reflection; + +namespace ICSharpCode.NRefactory.Parser.VB { + + + +partial class Parser : AbstractParser +{ + const int maxT = 238; + + const bool T = true; + const bool x = false; + + +#line 13 "VBNET.ATG" + + +/* + +*/ + + void VBNET() { + +#line 263 "VBNET.ATG" + lexer.NextToken(); // get the first token + compilationUnit = new CompilationUnit(); + BlockStart(compilationUnit); + + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + while (la.kind == 173) { + OptionStmt(); + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + } + while (la.kind == 137) { + ImportsStmt(); + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + } + while ( +#line 271 "VBNET.ATG" +IsGlobalAttrTarget()) { + GlobalAttributeSection(); + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + } + while (StartOf(1)) { + NamespaceMemberDecl(); + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + } + Expect(0); + } + + void EndOfStmt() { + while (!(la.kind == 0 || la.kind == 1 || la.kind == 21)) {SynErr(239); lexer.NextToken(); } + if (la.kind == 1) { + lexer.NextToken(); + } else if (la.kind == 21) { + lexer.NextToken(); + } else SynErr(240); + } + + void OptionStmt() { + +#line 276 "VBNET.ATG" + INode node = null; bool val = true; + Expect(173); + +#line 277 "VBNET.ATG" + Location startPos = t.Location; + if (la.kind == 121) { + lexer.NextToken(); + if (la.kind == 170 || la.kind == 171) { + OptionValue( +#line 279 "VBNET.ATG" +ref val); + } + +#line 280 "VBNET.ATG" + node = new OptionDeclaration(OptionType.Explicit, val); + } else if (la.kind == 207) { + lexer.NextToken(); + if (la.kind == 170 || la.kind == 171) { + OptionValue( +#line 282 "VBNET.ATG" +ref val); + } + +#line 283 "VBNET.ATG" + node = new OptionDeclaration(OptionType.Strict, val); + } else if (la.kind == 87) { + lexer.NextToken(); + if (la.kind == 67) { + lexer.NextToken(); + +#line 285 "VBNET.ATG" + node = new OptionDeclaration(OptionType.CompareBinary, val); + } else if (la.kind == 213) { + lexer.NextToken(); + +#line 286 "VBNET.ATG" + node = new OptionDeclaration(OptionType.CompareText, val); + } else SynErr(241); + } else if (la.kind == 139) { + lexer.NextToken(); + if (la.kind == 170 || la.kind == 171) { + OptionValue( +#line 289 "VBNET.ATG" +ref val); + } + +#line 290 "VBNET.ATG" + node = new OptionDeclaration(OptionType.Infer, val); + } else SynErr(242); + EndOfStmt(); + +#line 294 "VBNET.ATG" + if (node != null) { + node.StartLocation = startPos; + node.EndLocation = t.Location; + AddChild(node); + } + + } + + void ImportsStmt() { + +#line 315 "VBNET.ATG" + List usings = new List(); + + Expect(137); + +#line 319 "VBNET.ATG" + Location startPos = t.Location; + Using u; + + ImportClause( +#line 322 "VBNET.ATG" +out u); + +#line 322 "VBNET.ATG" + if (u != null) { usings.Add(u); } + while (la.kind == 22) { + lexer.NextToken(); + ImportClause( +#line 324 "VBNET.ATG" +out u); + +#line 324 "VBNET.ATG" + if (u != null) { usings.Add(u); } + } + EndOfStmt(); + +#line 328 "VBNET.ATG" + UsingDeclaration usingDeclaration = new UsingDeclaration(usings); + usingDeclaration.StartLocation = startPos; + usingDeclaration.EndLocation = t.Location; + AddChild(usingDeclaration); + + } + + void GlobalAttributeSection() { + Expect(40); + +#line 2823 "VBNET.ATG" + Location startPos = t.Location; + if (la.kind == 65) { + lexer.NextToken(); + } else if (la.kind == 155) { + lexer.NextToken(); + } else SynErr(243); + +#line 2825 "VBNET.ATG" + string attributeTarget = t.val != null ? t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture) : null; + List attributes = new List(); + ASTAttribute attribute; + + Expect(21); + Attribute( +#line 2829 "VBNET.ATG" +out attribute); + +#line 2829 "VBNET.ATG" + attributes.Add(attribute); + while ( +#line 2830 "VBNET.ATG" +NotFinalComma()) { + if (la.kind == 22) { + lexer.NextToken(); + if (la.kind == 65) { + lexer.NextToken(); + } else if (la.kind == 155) { + lexer.NextToken(); + } else SynErr(244); + Expect(21); + } + Attribute( +#line 2830 "VBNET.ATG" +out attribute); + +#line 2830 "VBNET.ATG" + attributes.Add(attribute); + } + if (la.kind == 22) { + lexer.NextToken(); + } + Expect(39); + EndOfStmt(); + +#line 2835 "VBNET.ATG" + AttributeSection section = new AttributeSection { + AttributeTarget = attributeTarget, + Attributes = attributes, + StartLocation = startPos, + EndLocation = t.EndLocation + }; + AddChild(section); + + } + + void NamespaceMemberDecl() { + +#line 361 "VBNET.ATG" + ModifierList m = new ModifierList(); + AttributeSection section; + List attributes = new List(); + string qualident; + + if (la.kind == 160) { + lexer.NextToken(); + +#line 368 "VBNET.ATG" + Location startPos = t.Location; + + Qualident( +#line 370 "VBNET.ATG" +out qualident); + +#line 372 "VBNET.ATG" + INode node = new NamespaceDeclaration(qualident); + node.StartLocation = startPos; + AddChild(node); + BlockStart(node); + + EndOfStmt(); + NamespaceBody(); + +#line 380 "VBNET.ATG" + node.EndLocation = t.Location; + BlockEnd(); + + } else if (StartOf(2)) { + while (la.kind == 40) { + AttributeSection( +#line 384 "VBNET.ATG" +out section); + +#line 384 "VBNET.ATG" + attributes.Add(section); + } + while (StartOf(3)) { + TypeModifier( +#line 385 "VBNET.ATG" +m); + } + NonModuleDeclaration( +#line 385 "VBNET.ATG" +m, attributes); + } else SynErr(245); + } + + void OptionValue( +#line 302 "VBNET.ATG" +ref bool val) { + if (la.kind == 171) { + lexer.NextToken(); + +#line 304 "VBNET.ATG" + val = true; + } else if (la.kind == 170) { + lexer.NextToken(); + +#line 306 "VBNET.ATG" + val = false; + } else SynErr(246); + } + + void ImportClause( +#line 335 "VBNET.ATG" +out Using u) { + +#line 337 "VBNET.ATG" + string qualident = null; + TypeReference aliasedType = null; + u = null; + + if (StartOf(4)) { + Qualident( +#line 342 "VBNET.ATG" +out qualident); + if (la.kind == 20) { + lexer.NextToken(); + TypeName( +#line 343 "VBNET.ATG" +out aliasedType); + } + +#line 345 "VBNET.ATG" + if (qualident != null && qualident.Length > 0) { + if (aliasedType != null) { + u = new Using(qualident, aliasedType); + } else { + u = new Using(qualident); + } + } + + } else if (la.kind == 10) { + +#line 353 "VBNET.ATG" + string prefix = null; + lexer.NextToken(); + Identifier(); + +#line 354 "VBNET.ATG" + prefix = t.val; + Expect(20); + Expect(3); + +#line 354 "VBNET.ATG" + u = new Using(t.literalValue as string, prefix); + Expect(11); + } else SynErr(247); + } + + void Qualident( +#line 3623 "VBNET.ATG" +out string qualident) { + +#line 3625 "VBNET.ATG" + string name; + qualidentBuilder.Length = 0; + + Identifier(); + +#line 3629 "VBNET.ATG" + qualidentBuilder.Append(t.val); + while ( +#line 3630 "VBNET.ATG" +DotAndIdentOrKw()) { + Expect(26); + IdentifierOrKeyword( +#line 3630 "VBNET.ATG" +out name); + +#line 3630 "VBNET.ATG" + qualidentBuilder.Append('.'); qualidentBuilder.Append(name); + } + +#line 3632 "VBNET.ATG" + qualident = qualidentBuilder.ToString(); + } + + void TypeName( +#line 2694 "VBNET.ATG" +out TypeReference typeref) { + +#line 2695 "VBNET.ATG" + ArrayList rank = null; Location startLocation = la.Location; + NonArrayTypeName( +#line 2697 "VBNET.ATG" +out typeref, false); + ArrayTypeModifiers( +#line 2698 "VBNET.ATG" +out rank); + +#line 2700 "VBNET.ATG" + if (typeref != null) { + if (rank != null) { + typeref.RankSpecifier = (int[])rank.ToArray(typeof(int)); + } + typeref.StartLocation = startLocation; + typeref.EndLocation = t.EndLocation; + } + + } + + void Identifier() { + if (StartOf(5)) { + IdentifierForFieldDeclaration(); + } else if (la.kind == 98) { + lexer.NextToken(); + } else SynErr(248); + } + + void NamespaceBody() { + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + while (StartOf(1)) { + NamespaceMemberDecl(); + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + } + Expect(113); + Expect(160); + EndOfStmt(); + } + + void AttributeSection( +#line 2901 "VBNET.ATG" +out AttributeSection section) { + +#line 2903 "VBNET.ATG" + string attributeTarget = ""; + List attributes = new List(); + ASTAttribute attribute; + Location startLocation = la.Location; + + Expect(40); + if ( +#line 2909 "VBNET.ATG" +IsLocalAttrTarget()) { + if (la.kind == 119) { + lexer.NextToken(); + +#line 2910 "VBNET.ATG" + attributeTarget = "event"; + } else if (la.kind == 195) { + lexer.NextToken(); + +#line 2911 "VBNET.ATG" + attributeTarget = "return"; + } else { + Identifier(); + +#line 2914 "VBNET.ATG" + string val = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture); + if (val != "field" || val != "method" || + val != "module" || val != "param" || + val != "property" || val != "type") + Error("attribute target specifier (event, return, field," + + "method, module, param, property, or type) expected"); + attributeTarget = t.val; + + } + Expect(21); + } + Attribute( +#line 2924 "VBNET.ATG" +out attribute); + +#line 2924 "VBNET.ATG" + attributes.Add(attribute); + while ( +#line 2925 "VBNET.ATG" +NotFinalComma()) { + Expect(22); + Attribute( +#line 2925 "VBNET.ATG" +out attribute); + +#line 2925 "VBNET.ATG" + attributes.Add(attribute); + } + if (la.kind == 22) { + lexer.NextToken(); + } + Expect(39); + +#line 2929 "VBNET.ATG" + section = new AttributeSection { + AttributeTarget = attributeTarget, + Attributes = attributes, + StartLocation = startLocation, + EndLocation = t.EndLocation + }; + + } + + void TypeModifier( +#line 3708 "VBNET.ATG" +ModifierList m) { + switch (la.kind) { + case 188: { + lexer.NextToken(); + +#line 3709 "VBNET.ATG" + m.Add(Modifiers.Public, t.Location); + break; + } + case 187: { + lexer.NextToken(); + +#line 3710 "VBNET.ATG" + m.Add(Modifiers.Protected, t.Location); + break; + } + case 125: { + lexer.NextToken(); + +#line 3711 "VBNET.ATG" + m.Add(Modifiers.Internal, t.Location); + break; + } + case 185: { + lexer.NextToken(); + +#line 3712 "VBNET.ATG" + m.Add(Modifiers.Private, t.Location); + break; + } + case 200: { + lexer.NextToken(); + +#line 3713 "VBNET.ATG" + m.Add(Modifiers.Static, t.Location); + break; + } + case 199: { + lexer.NextToken(); + +#line 3714 "VBNET.ATG" + m.Add(Modifiers.New, t.Location); + break; + } + case 156: { + lexer.NextToken(); + +#line 3715 "VBNET.ATG" + m.Add(Modifiers.Abstract, t.Location); + break; + } + case 166: { + lexer.NextToken(); + +#line 3716 "VBNET.ATG" + m.Add(Modifiers.Sealed, t.Location); + break; + } + case 183: { + lexer.NextToken(); + +#line 3717 "VBNET.ATG" + m.Add(Modifiers.Partial, t.Location); + break; + } + default: SynErr(249); break; + } + } + + void NonModuleDeclaration( +#line 455 "VBNET.ATG" +ModifierList m, List attributes) { + +#line 457 "VBNET.ATG" + TypeReference typeRef = null; + List baseInterfaces = null; + + switch (la.kind) { + case 84: { + +#line 460 "VBNET.ATG" + m.Check(Modifiers.Classes); + lexer.NextToken(); + +#line 463 "VBNET.ATG" + TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + newType.StartLocation = t.Location; + AddChild(newType); + BlockStart(newType); + + newType.Type = ClassType.Class; + + Identifier(); + +#line 470 "VBNET.ATG" + newType.Name = t.val; + TypeParameterList( +#line 471 "VBNET.ATG" +newType.Templates); + EndOfStmt(); + +#line 473 "VBNET.ATG" + newType.BodyStartLocation = t.Location; + if (la.kind == 140) { + ClassBaseType( +#line 474 "VBNET.ATG" +out typeRef); + +#line 474 "VBNET.ATG" + SafeAdd(newType, newType.BaseTypes, typeRef); + } + while (la.kind == 136) { + TypeImplementsClause( +#line 475 "VBNET.ATG" +out baseInterfaces); + +#line 475 "VBNET.ATG" + newType.BaseTypes.AddRange(baseInterfaces); + } + ClassBody( +#line 476 "VBNET.ATG" +newType); + Expect(113); + Expect(84); + +#line 477 "VBNET.ATG" + newType.EndLocation = t.EndLocation; + EndOfStmt(); + +#line 480 "VBNET.ATG" + BlockEnd(); + + break; + } + case 155: { + lexer.NextToken(); + +#line 484 "VBNET.ATG" + m.Check(Modifiers.VBModules); + TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + AddChild(newType); + BlockStart(newType); + newType.StartLocation = m.GetDeclarationLocation(t.Location); + newType.Type = ClassType.Module; + + Identifier(); + +#line 491 "VBNET.ATG" + newType.Name = t.val; + EndOfStmt(); + +#line 493 "VBNET.ATG" + newType.BodyStartLocation = t.Location; + ModuleBody( +#line 494 "VBNET.ATG" +newType); + +#line 496 "VBNET.ATG" + BlockEnd(); + + break; + } + case 209: { + lexer.NextToken(); + +#line 500 "VBNET.ATG" + m.Check(Modifiers.VBStructures); + TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + AddChild(newType); + BlockStart(newType); + newType.StartLocation = m.GetDeclarationLocation(t.Location); + newType.Type = ClassType.Struct; + + Identifier(); + +#line 507 "VBNET.ATG" + newType.Name = t.val; + TypeParameterList( +#line 508 "VBNET.ATG" +newType.Templates); + EndOfStmt(); + +#line 510 "VBNET.ATG" + newType.BodyStartLocation = t.Location; + while (la.kind == 136) { + TypeImplementsClause( +#line 511 "VBNET.ATG" +out baseInterfaces); + +#line 511 "VBNET.ATG" + newType.BaseTypes.AddRange(baseInterfaces); + } + StructureBody( +#line 512 "VBNET.ATG" +newType); + +#line 514 "VBNET.ATG" + BlockEnd(); + + break; + } + case 115: { + lexer.NextToken(); + +#line 519 "VBNET.ATG" + m.Check(Modifiers.VBEnums); + TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + newType.StartLocation = m.GetDeclarationLocation(t.Location); + AddChild(newType); + BlockStart(newType); + + newType.Type = ClassType.Enum; + + Identifier(); + +#line 527 "VBNET.ATG" + newType.Name = t.val; + if (la.kind == 63) { + lexer.NextToken(); + NonArrayTypeName( +#line 528 "VBNET.ATG" +out typeRef, false); + +#line 528 "VBNET.ATG" + SafeAdd(newType, newType.BaseTypes, typeRef); + } + EndOfStmt(); + +#line 530 "VBNET.ATG" + newType.BodyStartLocation = t.Location; + EnumBody( +#line 531 "VBNET.ATG" +newType); + +#line 533 "VBNET.ATG" + BlockEnd(); + + break; + } + case 142: { + lexer.NextToken(); + +#line 538 "VBNET.ATG" + m.Check(Modifiers.VBInterfacs); + TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + newType.StartLocation = m.GetDeclarationLocation(t.Location); + AddChild(newType); + BlockStart(newType); + newType.Type = ClassType.Interface; + + Identifier(); + +#line 545 "VBNET.ATG" + newType.Name = t.val; + TypeParameterList( +#line 546 "VBNET.ATG" +newType.Templates); + EndOfStmt(); + +#line 548 "VBNET.ATG" + newType.BodyStartLocation = t.Location; + while (la.kind == 140) { + InterfaceBase( +#line 549 "VBNET.ATG" +out baseInterfaces); + +#line 549 "VBNET.ATG" + newType.BaseTypes.AddRange(baseInterfaces); + } + InterfaceBody( +#line 550 "VBNET.ATG" +newType); + +#line 552 "VBNET.ATG" + BlockEnd(); + + break; + } + case 103: { + lexer.NextToken(); + +#line 557 "VBNET.ATG" + m.Check(Modifiers.VBDelegates); + DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes); + delegateDeclr.ReturnType = new TypeReference("System.Void", true); + delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location); + List p = new List(); + + if (la.kind == 210) { + lexer.NextToken(); + Identifier(); + +#line 564 "VBNET.ATG" + delegateDeclr.Name = t.val; + TypeParameterList( +#line 565 "VBNET.ATG" +delegateDeclr.Templates); + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 566 "VBNET.ATG" +p); + } + Expect(38); + +#line 566 "VBNET.ATG" + delegateDeclr.Parameters = p; + } + } else if (la.kind == 127) { + lexer.NextToken(); + Identifier(); + +#line 568 "VBNET.ATG" + delegateDeclr.Name = t.val; + TypeParameterList( +#line 569 "VBNET.ATG" +delegateDeclr.Templates); + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 570 "VBNET.ATG" +p); + } + Expect(38); + +#line 570 "VBNET.ATG" + delegateDeclr.Parameters = p; + } + if (la.kind == 63) { + lexer.NextToken(); + +#line 571 "VBNET.ATG" + TypeReference type; + TypeName( +#line 571 "VBNET.ATG" +out type); + +#line 571 "VBNET.ATG" + delegateDeclr.ReturnType = type; + } + } else SynErr(250); + +#line 573 "VBNET.ATG" + delegateDeclr.EndLocation = t.EndLocation; + EndOfStmt(); + +#line 576 "VBNET.ATG" + AddChild(delegateDeclr); + + break; + } + default: SynErr(251); break; + } + } + + void TypeParameterList( +#line 389 "VBNET.ATG" +List templates) { + +#line 391 "VBNET.ATG" + TemplateDefinition template; + + if ( +#line 395 "VBNET.ATG" +la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { + lexer.NextToken(); + Expect(169); + TypeParameter( +#line 396 "VBNET.ATG" +out template); + +#line 398 "VBNET.ATG" + if (template != null) templates.Add(template); + + while (la.kind == 22) { + lexer.NextToken(); + TypeParameter( +#line 401 "VBNET.ATG" +out template); + +#line 403 "VBNET.ATG" + if (template != null) templates.Add(template); + + } + Expect(38); + } + } + + void TypeParameter( +#line 411 "VBNET.ATG" +out TemplateDefinition template) { + +#line 412 "VBNET.ATG" + VarianceModifier modifier = VarianceModifier.Invariant; Location startLocation = la.Location; + if (la.kind == 138 || la.kind == 178) { + if (la.kind == 138) { + lexer.NextToken(); + +#line 415 "VBNET.ATG" + modifier = VarianceModifier.Contravariant; + } else { + lexer.NextToken(); + +#line 415 "VBNET.ATG" + modifier = VarianceModifier.Covariant; + } + } + Identifier(); + +#line 415 "VBNET.ATG" + template = new TemplateDefinition(t.val, null) { VarianceModifier = modifier }; + if (la.kind == 63) { + TypeParameterConstraints( +#line 416 "VBNET.ATG" +template); + } + +#line 419 "VBNET.ATG" + if (template != null) { + template.StartLocation = startLocation; + template.EndLocation = t.EndLocation; + } + + } + + void TypeParameterConstraints( +#line 427 "VBNET.ATG" +TemplateDefinition template) { + +#line 429 "VBNET.ATG" + TypeReference constraint; + + Expect(63); + if (la.kind == 35) { + lexer.NextToken(); + TypeParameterConstraint( +#line 435 "VBNET.ATG" +out constraint); + +#line 435 "VBNET.ATG" + if (constraint != null) { template.Bases.Add(constraint); } + while (la.kind == 22) { + lexer.NextToken(); + TypeParameterConstraint( +#line 438 "VBNET.ATG" +out constraint); + +#line 438 "VBNET.ATG" + if (constraint != null) { template.Bases.Add(constraint); } + } + Expect(36); + } else if (StartOf(7)) { + TypeParameterConstraint( +#line 441 "VBNET.ATG" +out constraint); + +#line 441 "VBNET.ATG" + if (constraint != null) { template.Bases.Add(constraint); } + } else SynErr(252); + } + + void TypeParameterConstraint( +#line 445 "VBNET.ATG" +out TypeReference constraint) { + +#line 446 "VBNET.ATG" + constraint = null; Location startLocation = la.Location; + if (la.kind == 84) { + lexer.NextToken(); + +#line 448 "VBNET.ATG" + constraint = TypeReference.ClassConstraint; + } else if (la.kind == 209) { + lexer.NextToken(); + +#line 449 "VBNET.ATG" + constraint = TypeReference.StructConstraint; + } else if (la.kind == 162) { + lexer.NextToken(); + +#line 450 "VBNET.ATG" + constraint = TypeReference.NewConstraint; + } else if (StartOf(8)) { + TypeName( +#line 451 "VBNET.ATG" +out constraint); + } else SynErr(253); + } + + void ClassBaseType( +#line 797 "VBNET.ATG" +out TypeReference typeRef) { + +#line 799 "VBNET.ATG" + typeRef = null; + + Expect(140); + TypeName( +#line 802 "VBNET.ATG" +out typeRef); + EndOfStmt(); + } + + void TypeImplementsClause( +#line 1617 "VBNET.ATG" +out List baseInterfaces) { + +#line 1619 "VBNET.ATG" + baseInterfaces = new List(); + TypeReference type = null; + + Expect(136); + TypeName( +#line 1622 "VBNET.ATG" +out type); + +#line 1624 "VBNET.ATG" + if (type != null) baseInterfaces.Add(type); + + while (la.kind == 22) { + lexer.NextToken(); + TypeName( +#line 1627 "VBNET.ATG" +out type); + +#line 1628 "VBNET.ATG" + if (type != null) baseInterfaces.Add(type); + } + EndOfStmt(); + } + + void ClassBody( +#line 590 "VBNET.ATG" +TypeDeclaration newType) { + +#line 591 "VBNET.ATG" + AttributeSection section; + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + while (StartOf(9)) { + +#line 594 "VBNET.ATG" + List attributes = new List(); + ModifierList m = new ModifierList(); + + while (la.kind == 40) { + AttributeSection( +#line 597 "VBNET.ATG" +out section); + +#line 597 "VBNET.ATG" + attributes.Add(section); + } + while (StartOf(10)) { + MemberModifier( +#line 598 "VBNET.ATG" +m); + } + ClassMemberDecl( +#line 599 "VBNET.ATG" +m, attributes); + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + } + } + + void ModuleBody( +#line 621 "VBNET.ATG" +TypeDeclaration newType) { + +#line 622 "VBNET.ATG" + AttributeSection section; + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + while (StartOf(9)) { + +#line 625 "VBNET.ATG" + List attributes = new List(); + ModifierList m = new ModifierList(); + + while (la.kind == 40) { + AttributeSection( +#line 628 "VBNET.ATG" +out section); + +#line 628 "VBNET.ATG" + attributes.Add(section); + } + while (StartOf(10)) { + MemberModifier( +#line 629 "VBNET.ATG" +m); + } + ClassMemberDecl( +#line 630 "VBNET.ATG" +m, attributes); + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + } + Expect(113); + Expect(155); + +#line 633 "VBNET.ATG" + newType.EndLocation = t.EndLocation; + EndOfStmt(); + } + + void StructureBody( +#line 604 "VBNET.ATG" +TypeDeclaration newType) { + +#line 605 "VBNET.ATG" + AttributeSection section; + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + while (StartOf(9)) { + +#line 608 "VBNET.ATG" + List attributes = new List(); + ModifierList m = new ModifierList(); + + while (la.kind == 40) { + AttributeSection( +#line 611 "VBNET.ATG" +out section); + +#line 611 "VBNET.ATG" + attributes.Add(section); + } + while (StartOf(10)) { + MemberModifier( +#line 612 "VBNET.ATG" +m); + } + StructureMemberDecl( +#line 613 "VBNET.ATG" +m, attributes); + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + } + Expect(113); + Expect(209); + +#line 616 "VBNET.ATG" + newType.EndLocation = t.EndLocation; + EndOfStmt(); + } + + void NonArrayTypeName( +#line 2722 "VBNET.ATG" +out TypeReference typeref, bool canBeUnbound) { + +#line 2724 "VBNET.ATG" + string name; + typeref = null; + bool isGlobal = false; + + if (StartOf(11)) { + if (la.kind == 130) { + lexer.NextToken(); + Expect(26); + +#line 2729 "VBNET.ATG" + isGlobal = true; + } + QualIdentAndTypeArguments( +#line 2730 "VBNET.ATG" +out typeref, canBeUnbound); + +#line 2731 "VBNET.ATG" + typeref.IsGlobal = isGlobal; + while (la.kind == 26) { + lexer.NextToken(); + +#line 2732 "VBNET.ATG" + TypeReference nestedTypeRef; + QualIdentAndTypeArguments( +#line 2733 "VBNET.ATG" +out nestedTypeRef, canBeUnbound); + +#line 2734 "VBNET.ATG" + typeref = new InnerClassTypeReference(typeref, nestedTypeRef.Type, nestedTypeRef.GenericTypes); + } + } else if (la.kind == 168) { + lexer.NextToken(); + +#line 2737 "VBNET.ATG" + typeref = new TypeReference("System.Object", true); + if (la.kind == 33) { + lexer.NextToken(); + +#line 2741 "VBNET.ATG" + List typeArguments = new List(1); + if (typeref != null) typeArguments.Add(typeref); + typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; + + } + } else if (StartOf(12)) { + PrimitiveTypeName( +#line 2747 "VBNET.ATG" +out name); + +#line 2747 "VBNET.ATG" + typeref = new TypeReference(name, true); + if (la.kind == 33) { + lexer.NextToken(); + +#line 2751 "VBNET.ATG" + List typeArguments = new List(1); + if (typeref != null) typeArguments.Add(typeref); + typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; + + } + } else SynErr(254); + } + + void EnumBody( +#line 637 "VBNET.ATG" +TypeDeclaration newType) { + +#line 638 "VBNET.ATG" + FieldDeclaration f; + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + while (StartOf(13)) { + EnumMemberDecl( +#line 641 "VBNET.ATG" +out f); + +#line 643 "VBNET.ATG" + AddChild(f); + + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + } + Expect(113); + Expect(115); + +#line 647 "VBNET.ATG" + newType.EndLocation = t.EndLocation; + EndOfStmt(); + } + + void InterfaceBase( +#line 1602 "VBNET.ATG" +out List bases) { + +#line 1604 "VBNET.ATG" + TypeReference type; + bases = new List(); + + Expect(140); + TypeName( +#line 1608 "VBNET.ATG" +out type); + +#line 1608 "VBNET.ATG" + if (type != null) bases.Add(type); + while (la.kind == 22) { + lexer.NextToken(); + TypeName( +#line 1611 "VBNET.ATG" +out type); + +#line 1611 "VBNET.ATG" + if (type != null) bases.Add(type); + } + EndOfStmt(); + } + + void InterfaceBody( +#line 651 "VBNET.ATG" +TypeDeclaration newType) { + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + while (StartOf(14)) { + InterfaceMemberDecl(); + while (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + } + Expect(113); + Expect(142); + +#line 657 "VBNET.ATG" + newType.EndLocation = t.EndLocation; + EndOfStmt(); + } + + void FormalParameterList( +#line 2939 "VBNET.ATG" +List parameter) { + +#line 2940 "VBNET.ATG" + ParameterDeclarationExpression p; + FormalParameter( +#line 2942 "VBNET.ATG" +out p); + +#line 2942 "VBNET.ATG" + if (p != null) parameter.Add(p); + while (la.kind == 22) { + lexer.NextToken(); + FormalParameter( +#line 2944 "VBNET.ATG" +out p); + +#line 2944 "VBNET.ATG" + if (p != null) parameter.Add(p); + } + } + + void MemberModifier( +#line 3720 "VBNET.ATG" +ModifierList m) { + switch (la.kind) { + case 156: { + lexer.NextToken(); + +#line 3721 "VBNET.ATG" + m.Add(Modifiers.Abstract, t.Location); + break; + } + case 102: { + lexer.NextToken(); + +#line 3722 "VBNET.ATG" + m.Add(Modifiers.Default, t.Location); + break; + } + case 125: { + lexer.NextToken(); + +#line 3723 "VBNET.ATG" + m.Add(Modifiers.Internal, t.Location); + break; + } + case 199: { + lexer.NextToken(); + +#line 3724 "VBNET.ATG" + m.Add(Modifiers.New, t.Location); + break; + } + case 181: { + lexer.NextToken(); + +#line 3725 "VBNET.ATG" + m.Add(Modifiers.Override, t.Location); + break; + } + case 157: { + lexer.NextToken(); + +#line 3726 "VBNET.ATG" + m.Add(Modifiers.Abstract, t.Location); + break; + } + case 185: { + lexer.NextToken(); + +#line 3727 "VBNET.ATG" + m.Add(Modifiers.Private, t.Location); + break; + } + case 187: { + lexer.NextToken(); + +#line 3728 "VBNET.ATG" + m.Add(Modifiers.Protected, t.Location); + break; + } + case 188: { + lexer.NextToken(); + +#line 3729 "VBNET.ATG" + m.Add(Modifiers.Public, t.Location); + break; + } + case 166: { + lexer.NextToken(); + +#line 3730 "VBNET.ATG" + m.Add(Modifiers.Sealed, t.Location); + break; + } + case 167: { + lexer.NextToken(); + +#line 3731 "VBNET.ATG" + m.Add(Modifiers.Sealed, t.Location); + break; + } + case 200: { + lexer.NextToken(); + +#line 3732 "VBNET.ATG" + m.Add(Modifiers.Static, t.Location); + break; + } + case 180: { + lexer.NextToken(); + +#line 3733 "VBNET.ATG" + m.Add(Modifiers.Virtual, t.Location); + break; + } + case 179: { + lexer.NextToken(); + +#line 3734 "VBNET.ATG" + m.Add(Modifiers.Overloads, t.Location); + break; + } + case 190: { + lexer.NextToken(); + +#line 3735 "VBNET.ATG" + m.Add(Modifiers.ReadOnly, t.Location); + break; + } + case 235: { + lexer.NextToken(); + +#line 3736 "VBNET.ATG" + m.Add(Modifiers.WriteOnly, t.Location); + break; + } + case 234: { + lexer.NextToken(); + +#line 3737 "VBNET.ATG" + m.Add(Modifiers.WithEvents, t.Location); + break; + } + case 105: { + lexer.NextToken(); + +#line 3738 "VBNET.ATG" + m.Add(Modifiers.Dim, t.Location); + break; + } + case 183: { + lexer.NextToken(); + +#line 3739 "VBNET.ATG" + m.Add(Modifiers.Partial, t.Location); + break; + } + default: SynErr(255); break; + } + } + + void ClassMemberDecl( +#line 793 "VBNET.ATG" +ModifierList m, List attributes) { + StructureMemberDecl( +#line 794 "VBNET.ATG" +m, attributes); + } + + void StructureMemberDecl( +#line 807 "VBNET.ATG" +ModifierList m, List attributes) { + +#line 809 "VBNET.ATG" + TypeReference type = null; + List p = new List(); + Statement stmt = null; + List variableDeclarators = new List(); + List templates = new List(); + + switch (la.kind) { + case 84: case 103: case 115: case 142: case 155: case 209: { + NonModuleDeclaration( +#line 816 "VBNET.ATG" +m, attributes); + break; + } + case 210: { + lexer.NextToken(); + +#line 820 "VBNET.ATG" + Location startPos = t.Location; + + if (StartOf(4)) { + +#line 824 "VBNET.ATG" + string name = String.Empty; + MethodDeclaration methodDeclaration; List handlesClause = null; + List implementsClause = null; + + Identifier(); + +#line 830 "VBNET.ATG" + name = t.val; + m.Check(Modifiers.VBMethods); + + TypeParameterList( +#line 833 "VBNET.ATG" +templates); + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 834 "VBNET.ATG" +p); + } + Expect(38); + } + if (la.kind == 134 || la.kind == 136) { + if (la.kind == 136) { + ImplementsClause( +#line 837 "VBNET.ATG" +out implementsClause); + } else { + HandlesClause( +#line 839 "VBNET.ATG" +out handlesClause); + } + } + +#line 842 "VBNET.ATG" + Location endLocation = t.EndLocation; + if ( +#line 845 "VBNET.ATG" +IsMustOverride(m)) { + EndOfStmt(); + +#line 848 "VBNET.ATG" + methodDeclaration = new MethodDeclaration { + Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, + StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, + TypeReference = new TypeReference("System.Void", true), + Templates = templates, + HandlesClause = handlesClause, + InterfaceImplementations = implementsClause + }; + AddChild(methodDeclaration); + + } else if (la.kind == 1) { + lexer.NextToken(); + +#line 861 "VBNET.ATG" + methodDeclaration = new MethodDeclaration { + Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, + StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, + TypeReference = new TypeReference("System.Void", true), + Templates = templates, + HandlesClause = handlesClause, + InterfaceImplementations = implementsClause + }; + AddChild(methodDeclaration); + + +#line 872 "VBNET.ATG" + if (ParseMethodBodies) { + Block( +#line 873 "VBNET.ATG" +out stmt); + Expect(113); + Expect(210); + +#line 875 "VBNET.ATG" + } else { + // don't parse method body + lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); + } + + +#line 881 "VBNET.ATG" + methodDeclaration.Body = (BlockStatement)stmt; + +#line 882 "VBNET.ATG" + methodDeclaration.Body.EndLocation = t.EndLocation; + EndOfStmt(); + } else SynErr(256); + } else if (la.kind == 162) { + lexer.NextToken(); + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 886 "VBNET.ATG" +p); + } + Expect(38); + } + +#line 887 "VBNET.ATG" + m.Check(Modifiers.Constructors); + +#line 888 "VBNET.ATG" + Location constructorEndLocation = t.EndLocation; + Expect(1); + +#line 891 "VBNET.ATG" + if (ParseMethodBodies) { + Block( +#line 892 "VBNET.ATG" +out stmt); + Expect(113); + Expect(210); + +#line 894 "VBNET.ATG" + } else { + // don't parse method body + lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); + } + + +#line 900 "VBNET.ATG" + Location endLocation = t.EndLocation; + EndOfStmt(); + +#line 903 "VBNET.ATG" + ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes); + cd.StartLocation = m.GetDeclarationLocation(startPos); + cd.EndLocation = constructorEndLocation; + cd.Body = (BlockStatement)stmt; + cd.Body.EndLocation = endLocation; + AddChild(cd); + + } else SynErr(257); + break; + } + case 127: { + lexer.NextToken(); + +#line 915 "VBNET.ATG" + m.Check(Modifiers.VBMethods); + string name = String.Empty; + Location startPos = t.Location; + MethodDeclaration methodDeclaration;List handlesClause = null; + List implementsClause = null; + AttributeSection returnTypeAttributeSection = null; + + Identifier(); + +#line 922 "VBNET.ATG" + name = t.val; + TypeParameterList( +#line 923 "VBNET.ATG" +templates); + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 924 "VBNET.ATG" +p); + } + Expect(38); + } + if (la.kind == 63) { + lexer.NextToken(); + while (la.kind == 40) { + AttributeSection( +#line 926 "VBNET.ATG" +out returnTypeAttributeSection); + +#line 928 "VBNET.ATG" + if (returnTypeAttributeSection != null) { + returnTypeAttributeSection.AttributeTarget = "return"; + attributes.Add(returnTypeAttributeSection); + } + + } + TypeName( +#line 934 "VBNET.ATG" +out type); + } + +#line 936 "VBNET.ATG" + if(type == null) { + type = new TypeReference("System.Object", true); + } + + if (la.kind == 134 || la.kind == 136) { + if (la.kind == 136) { + ImplementsClause( +#line 942 "VBNET.ATG" +out implementsClause); + } else { + HandlesClause( +#line 944 "VBNET.ATG" +out handlesClause); + } + } + +#line 947 "VBNET.ATG" + Location endLocation = t.EndLocation; + if ( +#line 950 "VBNET.ATG" +IsMustOverride(m)) { + EndOfStmt(); + +#line 953 "VBNET.ATG" + methodDeclaration = new MethodDeclaration { + Name = name, Modifier = m.Modifier, TypeReference = type, + Parameters = p, Attributes = attributes, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = endLocation, + HandlesClause = handlesClause, + Templates = templates, + InterfaceImplementations = implementsClause + }; + + AddChild(methodDeclaration); + + } else if (la.kind == 1) { + lexer.NextToken(); + +#line 968 "VBNET.ATG" + methodDeclaration = new MethodDeclaration { + Name = name, Modifier = m.Modifier, TypeReference = type, + Parameters = p, Attributes = attributes, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = endLocation, + Templates = templates, + HandlesClause = handlesClause, + InterfaceImplementations = implementsClause + }; + + AddChild(methodDeclaration); + + if (ParseMethodBodies) { + Block( +#line 981 "VBNET.ATG" +out stmt); + Expect(113); + Expect(127); + +#line 983 "VBNET.ATG" + } else { + // don't parse method body + lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement(); + } + methodDeclaration.Body = (BlockStatement)stmt; + methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation; + methodDeclaration.Body.EndLocation = t.EndLocation; + + EndOfStmt(); + } else SynErr(258); + break; + } + case 101: { + lexer.NextToken(); + +#line 997 "VBNET.ATG" + m.Check(Modifiers.VBExternalMethods); + Location startPos = t.Location; + CharsetModifier charsetModifer = CharsetModifier.None; + string library = String.Empty; + string alias = null; + string name = String.Empty; + + if (StartOf(15)) { + Charset( +#line 1004 "VBNET.ATG" +out charsetModifer); + } + if (la.kind == 210) { + lexer.NextToken(); + Identifier(); + +#line 1007 "VBNET.ATG" + name = t.val; + Expect(149); + Expect(3); + +#line 1008 "VBNET.ATG" + library = t.literalValue as string; + if (la.kind == 59) { + lexer.NextToken(); + Expect(3); + +#line 1009 "VBNET.ATG" + alias = t.literalValue as string; + } + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 1010 "VBNET.ATG" +p); + } + Expect(38); + } + EndOfStmt(); + +#line 1013 "VBNET.ATG" + DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer); + declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); + declareDeclaration.EndLocation = t.EndLocation; + AddChild(declareDeclaration); + + } else if (la.kind == 127) { + lexer.NextToken(); + Identifier(); + +#line 1020 "VBNET.ATG" + name = t.val; + Expect(149); + Expect(3); + +#line 1021 "VBNET.ATG" + library = t.literalValue as string; + if (la.kind == 59) { + lexer.NextToken(); + Expect(3); + +#line 1022 "VBNET.ATG" + alias = t.literalValue as string; + } + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 1023 "VBNET.ATG" +p); + } + Expect(38); + } + if (la.kind == 63) { + lexer.NextToken(); + TypeName( +#line 1024 "VBNET.ATG" +out type); + } + EndOfStmt(); + +#line 1027 "VBNET.ATG" + DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer); + declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); + declareDeclaration.EndLocation = t.EndLocation; + AddChild(declareDeclaration); + + } else SynErr(259); + break; + } + case 119: { + lexer.NextToken(); + +#line 1037 "VBNET.ATG" + m.Check(Modifiers.VBEvents); + Location startPos = t.Location; + EventDeclaration eventDeclaration; + string name = String.Empty; + List implementsClause = null; + + Identifier(); + +#line 1043 "VBNET.ATG" + name= t.val; + if (la.kind == 63) { + lexer.NextToken(); + TypeName( +#line 1045 "VBNET.ATG" +out type); + } else if (StartOf(16)) { + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 1047 "VBNET.ATG" +p); + } + Expect(38); + } + } else SynErr(260); + if (la.kind == 136) { + ImplementsClause( +#line 1049 "VBNET.ATG" +out implementsClause); + } + +#line 1051 "VBNET.ATG" + eventDeclaration = new EventDeclaration { + Name = name, TypeReference = type, Modifier = m.Modifier, + Parameters = p, Attributes = attributes, InterfaceImplementations = implementsClause, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = t.EndLocation + }; + AddChild(eventDeclaration); + + EndOfStmt(); + break; + } + case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 70: case 87: case 104: case 107: case 116: case 121: case 126: case 133: case 139: case 143: case 146: case 147: case 170: case 176: case 178: case 184: case 203: case 212: case 213: case 223: case 224: case 230: { + +#line 1062 "VBNET.ATG" + m.Check(Modifiers.Fields); + FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier); + + IdentifierForFieldDeclaration(); + +#line 1065 "VBNET.ATG" + string name = t.val; + +#line 1066 "VBNET.ATG" + fd.StartLocation = m.GetDeclarationLocation(t.Location); + VariableDeclaratorPartAfterIdentifier( +#line 1068 "VBNET.ATG" +variableDeclarators, name); + while (la.kind == 22) { + lexer.NextToken(); + VariableDeclarator( +#line 1069 "VBNET.ATG" +variableDeclarators); + } + EndOfStmt(); + +#line 1072 "VBNET.ATG" + fd.EndLocation = t.EndLocation; + fd.Fields = variableDeclarators; + AddChild(fd); + + break; + } + case 88: { + +#line 1077 "VBNET.ATG" + m.Check(Modifiers.Fields); + lexer.NextToken(); + +#line 1078 "VBNET.ATG" + m.Add(Modifiers.Const, t.Location); + +#line 1080 "VBNET.ATG" + FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); + fd.StartLocation = m.GetDeclarationLocation(t.Location); + List constantDeclarators = new List(); + + ConstantDeclarator( +#line 1084 "VBNET.ATG" +constantDeclarators); + while (la.kind == 22) { + lexer.NextToken(); + ConstantDeclarator( +#line 1085 "VBNET.ATG" +constantDeclarators); + } + +#line 1087 "VBNET.ATG" + fd.Fields = constantDeclarators; + fd.EndLocation = t.Location; + + EndOfStmt(); + +#line 1092 "VBNET.ATG" + fd.EndLocation = t.EndLocation; + AddChild(fd); + + break; + } + case 186: { + lexer.NextToken(); + +#line 1098 "VBNET.ATG" + m.Check(Modifiers.VBProperties); + Location startPos = t.Location; + List implementsClause = null; + AttributeSection returnTypeAttributeSection = null; + Expression initializer = null; + + Identifier(); + +#line 1104 "VBNET.ATG" + string propertyName = t.val; + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 1105 "VBNET.ATG" +p); + } + Expect(38); + } + if (la.kind == 63) { + lexer.NextToken(); + while (la.kind == 40) { + AttributeSection( +#line 1108 "VBNET.ATG" +out returnTypeAttributeSection); + +#line 1110 "VBNET.ATG" + if (returnTypeAttributeSection != null) { + returnTypeAttributeSection.AttributeTarget = "return"; + attributes.Add(returnTypeAttributeSection); + } + + } + if ( +#line 1117 "VBNET.ATG" +IsNewExpression()) { + ObjectCreateExpression( +#line 1117 "VBNET.ATG" +out initializer); + +#line 1119 "VBNET.ATG" + if (initializer is ObjectCreateExpression) { + type = ((ObjectCreateExpression)initializer).CreateType.Clone(); + } else { + type = ((ArrayCreateExpression)initializer).CreateType.Clone(); + } + + } else if (StartOf(8)) { + TypeName( +#line 1126 "VBNET.ATG" +out type); + } else SynErr(261); + } + if (la.kind == 20) { + lexer.NextToken(); + Expr( +#line 1129 "VBNET.ATG" +out initializer); + } + if (la.kind == 136) { + ImplementsClause( +#line 1130 "VBNET.ATG" +out implementsClause); + } + EndOfStmt(); + if ( +#line 1134 "VBNET.ATG" +IsMustOverride(m) || IsAutomaticProperty()) { + +#line 1136 "VBNET.ATG" + PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); + pDecl.StartLocation = m.GetDeclarationLocation(startPos); + pDecl.EndLocation = t.Location; + pDecl.TypeReference = type; + pDecl.InterfaceImplementations = implementsClause; + pDecl.Parameters = p; + if (initializer != null) + pDecl.Initializer = initializer; + AddChild(pDecl); + + } else if (StartOf(17)) { + +#line 1148 "VBNET.ATG" + PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); + pDecl.StartLocation = m.GetDeclarationLocation(startPos); + pDecl.EndLocation = t.Location; + pDecl.BodyStart = t.Location; + pDecl.TypeReference = type; + pDecl.InterfaceImplementations = implementsClause; + pDecl.Parameters = p; + PropertyGetRegion getRegion; + PropertySetRegion setRegion; + + AccessorDecls( +#line 1158 "VBNET.ATG" +out getRegion, out setRegion); + Expect(113); + Expect(186); + EndOfStmt(); + +#line 1162 "VBNET.ATG" + pDecl.GetRegion = getRegion; + pDecl.SetRegion = setRegion; + pDecl.BodyEnd = t.Location; // t = EndOfStmt; not "Property" + AddChild(pDecl); + + } else SynErr(262); + break; + } + case 98: { + lexer.NextToken(); + +#line 1169 "VBNET.ATG" + Location startPos = t.Location; + Expect(119); + +#line 1171 "VBNET.ATG" + m.Check(Modifiers.VBCustomEvents); + EventAddRemoveRegion eventAccessorDeclaration; + EventAddRegion addHandlerAccessorDeclaration = null; + EventRemoveRegion removeHandlerAccessorDeclaration = null; + EventRaiseRegion raiseEventAccessorDeclaration = null; + List implementsClause = null; + + Identifier(); + +#line 1178 "VBNET.ATG" + string customEventName = t.val; + Expect(63); + TypeName( +#line 1179 "VBNET.ATG" +out type); + if (la.kind == 136) { + ImplementsClause( +#line 1180 "VBNET.ATG" +out implementsClause); + } + EndOfStmt(); + while (StartOf(18)) { + EventAccessorDeclaration( +#line 1183 "VBNET.ATG" +out eventAccessorDeclaration); + +#line 1185 "VBNET.ATG" + if(eventAccessorDeclaration is EventAddRegion) + { + addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration; + } + else if(eventAccessorDeclaration is EventRemoveRegion) + { + removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration; + } + else if(eventAccessorDeclaration is EventRaiseRegion) + { + raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration; + } + + } + Expect(113); + Expect(119); + EndOfStmt(); + +#line 1201 "VBNET.ATG" + if(addHandlerAccessorDeclaration == null) + { + Error("Need to provide AddHandler accessor."); + } + + if(removeHandlerAccessorDeclaration == null) + { + Error("Need to provide RemoveHandler accessor."); + } + + if(raiseEventAccessorDeclaration == null) + { + Error("Need to provide RaiseEvent accessor."); + } + + EventDeclaration decl = new EventDeclaration { + TypeReference = type, Name = customEventName, Modifier = m.Modifier, + Attributes = attributes, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = t.EndLocation, + AddRegion = addHandlerAccessorDeclaration, + RemoveRegion = removeHandlerAccessorDeclaration, + RaiseRegion = raiseEventAccessorDeclaration + }; + AddChild(decl); + + break; + } + case 161: case 172: case 232: { + +#line 1227 "VBNET.ATG" + ConversionType opConversionType = ConversionType.None; + if (la.kind == 161 || la.kind == 232) { + if (la.kind == 232) { + lexer.NextToken(); + +#line 1228 "VBNET.ATG" + opConversionType = ConversionType.Implicit; + } else { + lexer.NextToken(); + +#line 1229 "VBNET.ATG" + opConversionType = ConversionType.Explicit; + } + } + Expect(172); + +#line 1232 "VBNET.ATG" + m.Check(Modifiers.VBOperators); + Location startPos = t.Location; + TypeReference returnType = NullTypeReference.Instance; + TypeReference operandType = NullTypeReference.Instance; + OverloadableOperatorType operatorType; + AttributeSection section; + ParameterDeclarationExpression param; + List parameters = new List(); + + OverloadableOperator( +#line 1241 "VBNET.ATG" +out operatorType); + Expect(37); + FormalParameter( +#line 1243 "VBNET.ATG" +out param); + +#line 1244 "VBNET.ATG" + if (param != null) parameters.Add(param); + if (la.kind == 22) { + lexer.NextToken(); + FormalParameter( +#line 1246 "VBNET.ATG" +out param); + +#line 1247 "VBNET.ATG" + if (param != null) parameters.Add(param); + } + Expect(38); + +#line 1250 "VBNET.ATG" + Location endPos = t.EndLocation; + if (la.kind == 63) { + lexer.NextToken(); + while (la.kind == 40) { + AttributeSection( +#line 1251 "VBNET.ATG" +out section); + +#line 1252 "VBNET.ATG" + if (section != null) { + section.AttributeTarget = "return"; + attributes.Add(section); + } + } + TypeName( +#line 1256 "VBNET.ATG" +out returnType); + +#line 1256 "VBNET.ATG" + endPos = t.EndLocation; + } + Expect(1); + Block( +#line 1258 "VBNET.ATG" +out stmt); + Expect(113); + Expect(172); + EndOfStmt(); + +#line 1260 "VBNET.ATG" + OperatorDeclaration operatorDeclaration = new OperatorDeclaration { + Modifier = m.Modifier, + Attributes = attributes, + Parameters = parameters, + TypeReference = returnType, + OverloadableOperator = operatorType, + ConversionType = opConversionType, + Body = (BlockStatement)stmt, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = endPos + }; + operatorDeclaration.Body.StartLocation = startPos; + operatorDeclaration.Body.EndLocation = t.Location; + AddChild(operatorDeclaration); + + break; + } + default: SynErr(263); break; + } + } + + void EnumMemberDecl( +#line 774 "VBNET.ATG" +out FieldDeclaration f) { + +#line 776 "VBNET.ATG" + Expression expr = null;List attributes = new List(); + AttributeSection section = null; + VariableDeclaration varDecl = null; + + while (la.kind == 40) { + AttributeSection( +#line 780 "VBNET.ATG" +out section); + +#line 780 "VBNET.ATG" + attributes.Add(section); + } + Identifier(); + +#line 783 "VBNET.ATG" + f = new FieldDeclaration(attributes); + varDecl = new VariableDeclaration(t.val); + f.Fields.Add(varDecl); + f.StartLocation = varDecl.StartLocation = t.Location; + + if (la.kind == 20) { + lexer.NextToken(); + Expr( +#line 788 "VBNET.ATG" +out expr); + +#line 788 "VBNET.ATG" + varDecl.Initializer = expr; + } + +#line 789 "VBNET.ATG" + f.EndLocation = varDecl.EndLocation = t.EndLocation; + EndOfStmt(); + } + + void InterfaceMemberDecl() { + +#line 665 "VBNET.ATG" + TypeReference type =null; + List p = new List(); + List templates = new List(); + AttributeSection section, returnTypeAttributeSection = null; + ModifierList mod = new ModifierList(); + List attributes = new List(); + string name; + + if (StartOf(19)) { + while (la.kind == 40) { + AttributeSection( +#line 673 "VBNET.ATG" +out section); + +#line 673 "VBNET.ATG" + attributes.Add(section); + } + while (StartOf(10)) { + MemberModifier( +#line 676 "VBNET.ATG" +mod); + } + if (la.kind == 119) { + lexer.NextToken(); + +#line 680 "VBNET.ATG" + mod.Check(Modifiers.VBInterfaceEvents); + Location startLocation = t.Location; + + Identifier(); + +#line 683 "VBNET.ATG" + name = t.val; + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 684 "VBNET.ATG" +p); + } + Expect(38); + } + if (la.kind == 63) { + lexer.NextToken(); + TypeName( +#line 685 "VBNET.ATG" +out type); + } + EndOfStmt(); + +#line 688 "VBNET.ATG" + EventDeclaration ed = new EventDeclaration { + Name = name, TypeReference = type, Modifier = mod.Modifier, + Parameters = p, Attributes = attributes, + StartLocation = startLocation, EndLocation = t.EndLocation + }; + AddChild(ed); + + } else if (la.kind == 210) { + lexer.NextToken(); + +#line 698 "VBNET.ATG" + Location startLocation = t.Location; + mod.Check(Modifiers.VBInterfaceMethods); + + Identifier(); + +#line 701 "VBNET.ATG" + name = t.val; + TypeParameterList( +#line 702 "VBNET.ATG" +templates); + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 703 "VBNET.ATG" +p); + } + Expect(38); + } + EndOfStmt(); + +#line 706 "VBNET.ATG" + MethodDeclaration md = new MethodDeclaration { + Name = name, + Modifier = mod.Modifier, + Parameters = p, + Attributes = attributes, + TypeReference = new TypeReference("System.Void", true), + StartLocation = startLocation, + EndLocation = t.EndLocation, + Templates = templates + }; + AddChild(md); + + } else if (la.kind == 127) { + lexer.NextToken(); + +#line 721 "VBNET.ATG" + mod.Check(Modifiers.VBInterfaceMethods); + Location startLocation = t.Location; + + Identifier(); + +#line 724 "VBNET.ATG" + name = t.val; + TypeParameterList( +#line 725 "VBNET.ATG" +templates); + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 726 "VBNET.ATG" +p); + } + Expect(38); + } + if (la.kind == 63) { + lexer.NextToken(); + while (la.kind == 40) { + AttributeSection( +#line 727 "VBNET.ATG" +out returnTypeAttributeSection); + } + TypeName( +#line 727 "VBNET.ATG" +out type); + } + +#line 729 "VBNET.ATG" + if(type == null) { + type = new TypeReference("System.Object", true); + } + MethodDeclaration md = new MethodDeclaration { + Name = name, Modifier = mod.Modifier, + TypeReference = type, Parameters = p, Attributes = attributes + }; + if (returnTypeAttributeSection != null) { + returnTypeAttributeSection.AttributeTarget = "return"; + md.Attributes.Add(returnTypeAttributeSection); + } + md.StartLocation = startLocation; + md.EndLocation = t.EndLocation; + md.Templates = templates; + AddChild(md); + + EndOfStmt(); + } else if (la.kind == 186) { + lexer.NextToken(); + +#line 749 "VBNET.ATG" + Location startLocation = t.Location; + mod.Check(Modifiers.VBInterfaceProperties); + + Identifier(); + +#line 752 "VBNET.ATG" + name = t.val; + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 753 "VBNET.ATG" +p); + } + Expect(38); + } + if (la.kind == 63) { + lexer.NextToken(); + TypeName( +#line 754 "VBNET.ATG" +out type); + } + +#line 756 "VBNET.ATG" + if(type == null) { + type = new TypeReference("System.Object", true); + } + + EndOfStmt(); + +#line 762 "VBNET.ATG" + PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes); + pd.Parameters = p; + pd.EndLocation = t.EndLocation; + pd.StartLocation = startLocation; + AddChild(pd); + + } else SynErr(264); + } else if (StartOf(20)) { + NonModuleDeclaration( +#line 770 "VBNET.ATG" +mod, attributes); + } else SynErr(265); + } + + void Expr( +#line 1661 "VBNET.ATG" +out Expression expr) { + +#line 1662 "VBNET.ATG" + expr = null; Location startLocation = la.Location; + if ( +#line 1665 "VBNET.ATG" +IsQueryExpression() ) { + QueryExpr( +#line 1666 "VBNET.ATG" +out expr); + } else if (la.kind == 127 || la.kind == 210) { + LambdaExpr( +#line 1667 "VBNET.ATG" +out expr); + } else if (StartOf(21)) { + DisjunctionExpr( +#line 1668 "VBNET.ATG" +out expr); + } else SynErr(266); + +#line 1671 "VBNET.ATG" + if (expr != null) { + expr.StartLocation = startLocation; + expr.EndLocation = t.EndLocation; + } + + } + + void ImplementsClause( +#line 1634 "VBNET.ATG" +out List baseInterfaces) { + +#line 1636 "VBNET.ATG" + baseInterfaces = new List(); + TypeReference type = null; + string memberName = null; + + Expect(136); + NonArrayTypeName( +#line 1641 "VBNET.ATG" +out type, false); + +#line 1642 "VBNET.ATG" + if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); + +#line 1643 "VBNET.ATG" + baseInterfaces.Add(new InterfaceImplementation(type, memberName)); + while (la.kind == 22) { + lexer.NextToken(); + NonArrayTypeName( +#line 1645 "VBNET.ATG" +out type, false); + +#line 1646 "VBNET.ATG" + if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); + +#line 1647 "VBNET.ATG" + baseInterfaces.Add(new InterfaceImplementation(type, memberName)); + } + } + + void HandlesClause( +#line 1592 "VBNET.ATG" +out List handlesClause) { + +#line 1594 "VBNET.ATG" + handlesClause = new List(); + string name; + + Expect(134); + EventMemberSpecifier( +#line 1597 "VBNET.ATG" +out name); + +#line 1597 "VBNET.ATG" + if (name != null) handlesClause.Add(name); + while (la.kind == 22) { + lexer.NextToken(); + EventMemberSpecifier( +#line 1598 "VBNET.ATG" +out name); + +#line 1598 "VBNET.ATG" + if (name != null) handlesClause.Add(name); + } + } + + void Block( +#line 2987 "VBNET.ATG" +out Statement stmt) { + +#line 2990 "VBNET.ATG" + BlockStatement blockStmt = new BlockStatement(); + /* in snippet parsing mode, t might be null */ + if (t != null) blockStmt.StartLocation = t.EndLocation; + BlockStart(blockStmt); + + while (StartOf(22) || +#line 2996 "VBNET.ATG" +IsEndStmtAhead()) { + if ( +#line 2996 "VBNET.ATG" +IsEndStmtAhead()) { + +#line 2997 "VBNET.ATG" + Token first = la; + Expect(113); + EndOfStmt(); + +#line 3000 "VBNET.ATG" + AddChild(new EndStatement() { + StartLocation = first.Location, + EndLocation = first.EndLocation } + ); + + } else { + Statement(); + EndOfStmt(); + } + } + +#line 3009 "VBNET.ATG" + stmt = blockStmt; + if (t != null) blockStmt.EndLocation = t.EndLocation; + BlockEnd(); + + } + + void Charset( +#line 1584 "VBNET.ATG" +out CharsetModifier charsetModifier) { + +#line 1585 "VBNET.ATG" + charsetModifier = CharsetModifier.None; + if (la.kind == 127 || la.kind == 210) { + } else if (la.kind == 62) { + lexer.NextToken(); + +#line 1586 "VBNET.ATG" + charsetModifier = CharsetModifier.Ansi; + } else if (la.kind == 66) { + lexer.NextToken(); + +#line 1587 "VBNET.ATG" + charsetModifier = CharsetModifier.Auto; + } else if (la.kind == 223) { + lexer.NextToken(); + +#line 1588 "VBNET.ATG" + charsetModifier = CharsetModifier.Unicode; + } else SynErr(267); + } + + void IdentifierForFieldDeclaration() { + switch (la.kind) { + case 2: { + lexer.NextToken(); + break; + } + case 58: { + lexer.NextToken(); + break; + } + case 62: { + lexer.NextToken(); + break; + } + case 64: { + lexer.NextToken(); + break; + } + case 65: { + lexer.NextToken(); + break; + } + case 66: { + lexer.NextToken(); + break; + } + case 67: { + lexer.NextToken(); + break; + } + case 70: { + lexer.NextToken(); + break; + } + case 87: { + lexer.NextToken(); + break; + } + case 104: { + lexer.NextToken(); + break; + } + case 107: { + lexer.NextToken(); + break; + } + case 116: { + lexer.NextToken(); + break; + } + case 121: { + lexer.NextToken(); + break; + } + case 126: { + lexer.NextToken(); + break; + } + case 133: { + lexer.NextToken(); + break; + } + case 139: { + lexer.NextToken(); + break; + } + case 143: { + lexer.NextToken(); + break; + } + case 146: { + lexer.NextToken(); + break; + } + case 147: { + lexer.NextToken(); + break; + } + case 170: { + lexer.NextToken(); + break; + } + case 176: { + lexer.NextToken(); + break; + } + case 178: { + lexer.NextToken(); + break; + } + case 184: { + lexer.NextToken(); + break; + } + case 203: { + lexer.NextToken(); + break; + } + case 212: { + lexer.NextToken(); + break; + } + case 213: { + lexer.NextToken(); + break; + } + case 223: { + lexer.NextToken(); + break; + } + case 224: { + lexer.NextToken(); + break; + } + case 230: { + lexer.NextToken(); + break; + } + default: SynErr(268); break; + } + } + + void VariableDeclaratorPartAfterIdentifier( +#line 1463 "VBNET.ATG" +List fieldDeclaration, string name) { + +#line 1465 "VBNET.ATG" + Expression expr = null; + TypeReference type = null; + ArrayList rank = null; + List dimension = null; + Location startLocation = t.Location; + + if ( +#line 1471 "VBNET.ATG" +IsSize() && !IsDims()) { + ArrayInitializationModifier( +#line 1471 "VBNET.ATG" +out dimension); + } + if ( +#line 1472 "VBNET.ATG" +IsDims()) { + ArrayNameModifier( +#line 1472 "VBNET.ATG" +out rank); + } + if ( +#line 1474 "VBNET.ATG" +IsObjectCreation()) { + Expect(63); + ObjectCreateExpression( +#line 1474 "VBNET.ATG" +out expr); + +#line 1476 "VBNET.ATG" + if (expr is ObjectCreateExpression) { + type = ((ObjectCreateExpression)expr).CreateType.Clone(); + } else { + type = ((ArrayCreateExpression)expr).CreateType.Clone(); + } + + } else if (StartOf(23)) { + if (la.kind == 63) { + lexer.NextToken(); + TypeName( +#line 1483 "VBNET.ATG" +out type); + +#line 1485 "VBNET.ATG" + if (type != null) { + for (int i = fieldDeclaration.Count - 1; i >= 0; i--) { + VariableDeclaration vd = fieldDeclaration[i]; + if (vd.TypeReference.Type.Length > 0) break; + TypeReference newType = type.Clone(); + newType.RankSpecifier = vd.TypeReference.RankSpecifier; + vd.TypeReference = newType; + } + } + + } + +#line 1497 "VBNET.ATG" + if (type == null && (dimension != null || rank != null)) { + type = new TypeReference(""); + } + if (dimension != null) { + if(type.RankSpecifier != null) { + Error("array rank only allowed one time"); + } else { + if (rank == null) { + type.RankSpecifier = new int[] { dimension.Count - 1 }; + } else { + rank.Insert(0, dimension.Count - 1); + type.RankSpecifier = (int[])rank.ToArray(typeof(int)); + } + expr = new ArrayCreateExpression(type.Clone(), dimension); + } + } else if (rank != null) { + if(type.RankSpecifier != null) { + Error("array rank only allowed one time"); + } else { + type.RankSpecifier = (int[])rank.ToArray(typeof(int)); + } + } + + if (la.kind == 20) { + lexer.NextToken(); + Expr( +#line 1520 "VBNET.ATG" +out expr); + } + } else SynErr(269); + +#line 1523 "VBNET.ATG" + VariableDeclaration varDecl = new VariableDeclaration(name, expr, type); + varDecl.StartLocation = startLocation; + varDecl.EndLocation = t.Location; + fieldDeclaration.Add(varDecl); + + } + + void VariableDeclarator( +#line 1457 "VBNET.ATG" +List fieldDeclaration) { + Identifier(); + +#line 1459 "VBNET.ATG" + string name = t.val; + VariableDeclaratorPartAfterIdentifier( +#line 1460 "VBNET.ATG" +fieldDeclaration, name); + } + + void ConstantDeclarator( +#line 1438 "VBNET.ATG" +List constantDeclaration) { + +#line 1440 "VBNET.ATG" + Expression expr = null; + TypeReference type = null; + string name = String.Empty; + Location location; + + Identifier(); + +#line 1445 "VBNET.ATG" + name = t.val; location = t.Location; + if (la.kind == 63) { + lexer.NextToken(); + TypeName( +#line 1446 "VBNET.ATG" +out type); + } + Expect(20); + Expr( +#line 1447 "VBNET.ATG" +out expr); + +#line 1449 "VBNET.ATG" + VariableDeclaration f = new VariableDeclaration(name, expr); + f.TypeReference = type; + f.StartLocation = location; + constantDeclaration.Add(f); + + } + + void ObjectCreateExpression( +#line 2123 "VBNET.ATG" +out Expression oce) { + +#line 2125 "VBNET.ATG" + TypeReference type = null; + CollectionInitializerExpression initializer = null; + List arguments = null; + ArrayList dimensions = null; + oce = null; + Location startLocation = la.Location; + bool canBeNormal; bool canBeReDim; + + Expect(162); + if (StartOf(8)) { + NonArrayTypeName( +#line 2134 "VBNET.ATG" +out type, false); + if (la.kind == 37) { + lexer.NextToken(); + NormalOrReDimArgumentList( +#line 2135 "VBNET.ATG" +out arguments, out canBeNormal, out canBeReDim); + Expect(38); + if (la.kind == 35 || +#line 2136 "VBNET.ATG" +la.kind == Tokens.OpenParenthesis) { + if ( +#line 2136 "VBNET.ATG" +la.kind == Tokens.OpenParenthesis) { + ArrayTypeModifiers( +#line 2137 "VBNET.ATG" +out dimensions); + CollectionInitializer( +#line 2138 "VBNET.ATG" +out initializer); + } else { + CollectionInitializer( +#line 2139 "VBNET.ATG" +out initializer); + } + } + +#line 2141 "VBNET.ATG" + if (canBeReDim && !canBeNormal && initializer == null) initializer = new CollectionInitializerExpression(); + } + } + +#line 2145 "VBNET.ATG" + if (initializer == null) { + oce = new ObjectCreateExpression(type, arguments); + } else { + if (dimensions == null) dimensions = new ArrayList(); + dimensions.Insert(0, (arguments == null) ? 0 : Math.Max(arguments.Count - 1, 0)); + type.RankSpecifier = (int[])dimensions.ToArray(typeof(int)); + ArrayCreateExpression ace = new ArrayCreateExpression(type, initializer); + ace.Arguments = arguments; + oce = ace; + } + + if (la.kind == 126 || la.kind == 233) { + if (la.kind == 233) { + +#line 2160 "VBNET.ATG" + MemberInitializerExpression memberInitializer = null; + Expression anonymousMember = null; + + lexer.NextToken(); + +#line 2165 "VBNET.ATG" + CollectionInitializerExpression memberInitializers = new CollectionInitializerExpression(); + memberInitializers.StartLocation = la.Location; + + Expect(35); + if (la.kind == 26 || la.kind == 147) { + MemberInitializer( +#line 2170 "VBNET.ATG" +out memberInitializer); + +#line 2171 "VBNET.ATG" + memberInitializers.CreateExpressions.Add(memberInitializer); + } else if (StartOf(24)) { + Expr( +#line 2172 "VBNET.ATG" +out anonymousMember); + +#line 2173 "VBNET.ATG" + memberInitializers.CreateExpressions.Add(anonymousMember); + } else SynErr(270); + while (la.kind == 22) { + lexer.NextToken(); + if (la.kind == 26 || la.kind == 147) { + MemberInitializer( +#line 2177 "VBNET.ATG" +out memberInitializer); + +#line 2178 "VBNET.ATG" + memberInitializers.CreateExpressions.Add(memberInitializer); + } else if (StartOf(24)) { + Expr( +#line 2179 "VBNET.ATG" +out anonymousMember); + +#line 2180 "VBNET.ATG" + memberInitializers.CreateExpressions.Add(anonymousMember); + } else SynErr(271); + } + Expect(36); + +#line 2185 "VBNET.ATG" + memberInitializers.EndLocation = t.Location; + if(oce is ObjectCreateExpression) + { + ((ObjectCreateExpression)oce).ObjectInitializer = memberInitializers; + } + + } else { + lexer.NextToken(); + CollectionInitializer( +#line 2195 "VBNET.ATG" +out initializer); + +#line 2197 "VBNET.ATG" + if(oce is ObjectCreateExpression) + ((ObjectCreateExpression)oce).ObjectInitializer = initializer; + + } + } + +#line 2203 "VBNET.ATG" + if (oce != null) { + oce.StartLocation = startLocation; + oce.EndLocation = t.EndLocation; + } + + } + + void AccessorDecls( +#line 1372 "VBNET.ATG" +out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { + +#line 1374 "VBNET.ATG" + List attributes = new List(); + AttributeSection section; + getBlock = null; + setBlock = null; + + while (la.kind == 40) { + AttributeSection( +#line 1379 "VBNET.ATG" +out section); + +#line 1379 "VBNET.ATG" + attributes.Add(section); + } + if (StartOf(25)) { + GetAccessorDecl( +#line 1381 "VBNET.ATG" +out getBlock, attributes); + if (StartOf(26)) { + +#line 1383 "VBNET.ATG" + attributes = new List(); + while (la.kind == 40) { + AttributeSection( +#line 1384 "VBNET.ATG" +out section); + +#line 1384 "VBNET.ATG" + attributes.Add(section); + } + SetAccessorDecl( +#line 1385 "VBNET.ATG" +out setBlock, attributes); + } + } else if (StartOf(27)) { + SetAccessorDecl( +#line 1388 "VBNET.ATG" +out setBlock, attributes); + if (StartOf(28)) { + +#line 1390 "VBNET.ATG" + attributes = new List(); + while (la.kind == 40) { + AttributeSection( +#line 1391 "VBNET.ATG" +out section); + +#line 1391 "VBNET.ATG" + attributes.Add(section); + } + GetAccessorDecl( +#line 1392 "VBNET.ATG" +out getBlock, attributes); + } + } else SynErr(272); + } + + void EventAccessorDeclaration( +#line 1335 "VBNET.ATG" +out EventAddRemoveRegion eventAccessorDeclaration) { + +#line 1337 "VBNET.ATG" + Statement stmt = null; + List p = new List(); + AttributeSection section; + List attributes = new List(); + eventAccessorDeclaration = null; + + while (la.kind == 40) { + AttributeSection( +#line 1343 "VBNET.ATG" +out section); + +#line 1343 "VBNET.ATG" + attributes.Add(section); + } + if (la.kind == 56) { + lexer.NextToken(); + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 1345 "VBNET.ATG" +p); + } + Expect(38); + } + Expect(1); + Block( +#line 1346 "VBNET.ATG" +out stmt); + Expect(113); + Expect(56); + EndOfStmt(); + +#line 1348 "VBNET.ATG" + eventAccessorDeclaration = new EventAddRegion(attributes); + eventAccessorDeclaration.Block = (BlockStatement)stmt; + eventAccessorDeclaration.Parameters = p; + + } else if (la.kind == 193) { + lexer.NextToken(); + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 1353 "VBNET.ATG" +p); + } + Expect(38); + } + Expect(1); + Block( +#line 1354 "VBNET.ATG" +out stmt); + Expect(113); + Expect(193); + EndOfStmt(); + +#line 1356 "VBNET.ATG" + eventAccessorDeclaration = new EventRemoveRegion(attributes); + eventAccessorDeclaration.Block = (BlockStatement)stmt; + eventAccessorDeclaration.Parameters = p; + + } else if (la.kind == 189) { + lexer.NextToken(); + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 1361 "VBNET.ATG" +p); + } + Expect(38); + } + Expect(1); + Block( +#line 1362 "VBNET.ATG" +out stmt); + Expect(113); + Expect(189); + EndOfStmt(); + +#line 1364 "VBNET.ATG" + eventAccessorDeclaration = new EventRaiseRegion(attributes); + eventAccessorDeclaration.Block = (BlockStatement)stmt; + eventAccessorDeclaration.Parameters = p; + + } else SynErr(273); + } + + void OverloadableOperator( +#line 1277 "VBNET.ATG" +out OverloadableOperatorType operatorType) { + +#line 1278 "VBNET.ATG" + operatorType = OverloadableOperatorType.None; + switch (la.kind) { + case 31: { + lexer.NextToken(); + +#line 1280 "VBNET.ATG" + operatorType = OverloadableOperatorType.Add; + break; + } + case 30: { + lexer.NextToken(); + +#line 1282 "VBNET.ATG" + operatorType = OverloadableOperatorType.Subtract; + break; + } + case 34: { + lexer.NextToken(); + +#line 1284 "VBNET.ATG" + operatorType = OverloadableOperatorType.Multiply; + break; + } + case 24: { + lexer.NextToken(); + +#line 1286 "VBNET.ATG" + operatorType = OverloadableOperatorType.Divide; + break; + } + case 25: { + lexer.NextToken(); + +#line 1288 "VBNET.ATG" + operatorType = OverloadableOperatorType.DivideInteger; + break; + } + case 23: { + lexer.NextToken(); + +#line 1290 "VBNET.ATG" + operatorType = OverloadableOperatorType.Concat; + break; + } + case 150: { + lexer.NextToken(); + +#line 1292 "VBNET.ATG" + operatorType = OverloadableOperatorType.Like; + break; + } + case 154: { + lexer.NextToken(); + +#line 1294 "VBNET.ATG" + operatorType = OverloadableOperatorType.Modulus; + break; + } + case 60: { + lexer.NextToken(); + +#line 1296 "VBNET.ATG" + operatorType = OverloadableOperatorType.BitwiseAnd; + break; + } + case 175: { + lexer.NextToken(); + +#line 1298 "VBNET.ATG" + operatorType = OverloadableOperatorType.BitwiseOr; + break; + } + case 236: { + lexer.NextToken(); + +#line 1300 "VBNET.ATG" + operatorType = OverloadableOperatorType.ExclusiveOr; + break; + } + case 32: { + lexer.NextToken(); + +#line 1302 "VBNET.ATG" + operatorType = OverloadableOperatorType.Power; + break; + } + case 44: { + lexer.NextToken(); + +#line 1304 "VBNET.ATG" + operatorType = OverloadableOperatorType.ShiftLeft; + break; + } + case 45: { + lexer.NextToken(); + +#line 1306 "VBNET.ATG" + operatorType = OverloadableOperatorType.ShiftRight; + break; + } + case 20: { + lexer.NextToken(); + +#line 1308 "VBNET.ATG" + operatorType = OverloadableOperatorType.Equality; + break; + } + case 41: { + lexer.NextToken(); + +#line 1310 "VBNET.ATG" + operatorType = OverloadableOperatorType.InEquality; + break; + } + case 40: { + lexer.NextToken(); + +#line 1312 "VBNET.ATG" + operatorType = OverloadableOperatorType.LessThan; + break; + } + case 43: { + lexer.NextToken(); + +#line 1314 "VBNET.ATG" + operatorType = OverloadableOperatorType.LessThanOrEqual; + break; + } + case 39: { + lexer.NextToken(); + +#line 1316 "VBNET.ATG" + operatorType = OverloadableOperatorType.GreaterThan; + break; + } + case 42: { + lexer.NextToken(); + +#line 1318 "VBNET.ATG" + operatorType = OverloadableOperatorType.GreaterThanOrEqual; + break; + } + case 94: { + lexer.NextToken(); + +#line 1320 "VBNET.ATG" + operatorType = OverloadableOperatorType.CType; + break; + } + case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 70: case 87: case 98: case 104: case 107: case 116: case 121: case 126: case 133: case 139: case 143: case 146: case 147: case 170: case 176: case 178: case 184: case 203: case 212: case 213: case 223: case 224: case 230: { + Identifier(); + +#line 1324 "VBNET.ATG" + string opName = t.val; + if (string.Equals(opName, "istrue", StringComparison.InvariantCultureIgnoreCase)) { + operatorType = OverloadableOperatorType.IsTrue; + } else if (string.Equals(opName, "isfalse", StringComparison.InvariantCultureIgnoreCase)) { + operatorType = OverloadableOperatorType.IsFalse; + } else { + Error("Invalid operator. Possible operators are '+', '-', 'Not', 'IsTrue', 'IsFalse'."); + } + + break; + } + default: SynErr(274); break; + } + } + + void FormalParameter( +#line 2948 "VBNET.ATG" +out ParameterDeclarationExpression p) { + +#line 2950 "VBNET.ATG" + AttributeSection section; + List attributes = new List(); + TypeReference type = null; + ParamModifierList mod = new ParamModifierList(this); + Expression expr = null; + p = null; + ArrayList arrayModifiers = null; + Location startLocation = la.Location; + + while (la.kind == 40) { + AttributeSection( +#line 2960 "VBNET.ATG" +out section); + +#line 2960 "VBNET.ATG" + attributes.Add(section); + } + while (StartOf(29)) { + ParameterModifier( +#line 2961 "VBNET.ATG" +mod); + } + Identifier(); + +#line 2962 "VBNET.ATG" + string parameterName = t.val; + if ( +#line 2963 "VBNET.ATG" +IsDims()) { + ArrayTypeModifiers( +#line 2963 "VBNET.ATG" +out arrayModifiers); + } + if (la.kind == 63) { + lexer.NextToken(); + TypeName( +#line 2964 "VBNET.ATG" +out type); + } + +#line 2966 "VBNET.ATG" + if(type != null) { + if (arrayModifiers != null) { + if (type.RankSpecifier != null) { + Error("array rank only allowed one time"); + } else { + type.RankSpecifier = (int[])arrayModifiers.ToArray(typeof(int)); + } + } + } + + if (la.kind == 20) { + lexer.NextToken(); + Expr( +#line 2976 "VBNET.ATG" +out expr); + } + +#line 2978 "VBNET.ATG" + mod.Check(); + p = new ParameterDeclarationExpression(type, parameterName, mod.Modifier, expr); + p.Attributes = attributes; + p.StartLocation = startLocation; + p.EndLocation = t.EndLocation; + + } + + void GetAccessorDecl( +#line 1398 "VBNET.ATG" +out PropertyGetRegion getBlock, List attributes) { + +#line 1399 "VBNET.ATG" + Statement stmt = null; Modifiers m; + PropertyAccessorAccessModifier( +#line 1401 "VBNET.ATG" +out m); + Expect(128); + +#line 1403 "VBNET.ATG" + Location startLocation = t.Location; + Expect(1); + Block( +#line 1405 "VBNET.ATG" +out stmt); + +#line 1406 "VBNET.ATG" + getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); + Expect(113); + Expect(128); + +#line 1408 "VBNET.ATG" + getBlock.Modifier = m; + +#line 1409 "VBNET.ATG" + getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; + EndOfStmt(); + } + + void SetAccessorDecl( +#line 1414 "VBNET.ATG" +out PropertySetRegion setBlock, List attributes) { + +#line 1416 "VBNET.ATG" + Statement stmt = null; + List p = new List(); + Modifiers m; + + PropertyAccessorAccessModifier( +#line 1421 "VBNET.ATG" +out m); + Expect(198); + +#line 1423 "VBNET.ATG" + Location startLocation = t.Location; + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 1424 "VBNET.ATG" +p); + } + Expect(38); + } + Expect(1); + Block( +#line 1426 "VBNET.ATG" +out stmt); + +#line 1428 "VBNET.ATG" + setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); + setBlock.Modifier = m; + setBlock.Parameters = p; + + Expect(113); + Expect(198); + +#line 1433 "VBNET.ATG" + setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; + EndOfStmt(); + } + + void PropertyAccessorAccessModifier( +#line 3742 "VBNET.ATG" +out Modifiers m) { + +#line 3743 "VBNET.ATG" + m = Modifiers.None; + while (StartOf(30)) { + if (la.kind == 188) { + lexer.NextToken(); + +#line 3745 "VBNET.ATG" + m |= Modifiers.Public; + } else if (la.kind == 187) { + lexer.NextToken(); + +#line 3746 "VBNET.ATG" + m |= Modifiers.Protected; + } else if (la.kind == 125) { + lexer.NextToken(); + +#line 3747 "VBNET.ATG" + m |= Modifiers.Internal; + } else { + lexer.NextToken(); + +#line 3748 "VBNET.ATG" + m |= Modifiers.Private; + } + } + } + + void ArrayInitializationModifier( +#line 1531 "VBNET.ATG" +out List arrayModifiers) { + +#line 1533 "VBNET.ATG" + arrayModifiers = null; + + Expect(37); + InitializationRankList( +#line 1535 "VBNET.ATG" +out arrayModifiers); + Expect(38); + } + + void ArrayNameModifier( +#line 2775 "VBNET.ATG" +out ArrayList arrayModifiers) { + +#line 2777 "VBNET.ATG" + arrayModifiers = null; + + ArrayTypeModifiers( +#line 2779 "VBNET.ATG" +out arrayModifiers); + } + + void InitializationRankList( +#line 1539 "VBNET.ATG" +out List rank) { + +#line 1541 "VBNET.ATG" + rank = new List(); + Expression expr = null; + + Expr( +#line 1544 "VBNET.ATG" +out expr); + if (la.kind == 216) { + lexer.NextToken(); + +#line 1545 "VBNET.ATG" + EnsureIsZero(expr); + Expr( +#line 1546 "VBNET.ATG" +out expr); + } + +#line 1548 "VBNET.ATG" + if (expr != null) { rank.Add(expr); } + while (la.kind == 22) { + lexer.NextToken(); + Expr( +#line 1550 "VBNET.ATG" +out expr); + if (la.kind == 216) { + lexer.NextToken(); + +#line 1551 "VBNET.ATG" + EnsureIsZero(expr); + Expr( +#line 1552 "VBNET.ATG" +out expr); + } + +#line 1554 "VBNET.ATG" + if (expr != null) { rank.Add(expr); } + } + } + + void CollectionInitializer( +#line 1559 "VBNET.ATG" +out CollectionInitializerExpression outExpr) { + +#line 1561 "VBNET.ATG" + Expression expr = null; + CollectionInitializerExpression initializer = new CollectionInitializerExpression(); + Location startLocation = la.Location; + + Expect(35); + if (StartOf(24)) { + Expr( +#line 1567 "VBNET.ATG" +out expr); + +#line 1569 "VBNET.ATG" + if (expr != null) { initializer.CreateExpressions.Add(expr); } + + while ( +#line 1572 "VBNET.ATG" +NotFinalComma()) { + Expect(22); + Expr( +#line 1572 "VBNET.ATG" +out expr); + +#line 1573 "VBNET.ATG" + if (expr != null) { initializer.CreateExpressions.Add(expr); } + } + } + Expect(36); + +#line 1578 "VBNET.ATG" + outExpr = initializer; + outExpr.StartLocation = startLocation; + outExpr.EndLocation = t.EndLocation; + + } + + void EventMemberSpecifier( +#line 1651 "VBNET.ATG" +out string name) { + +#line 1652 "VBNET.ATG" + string eventName; + if (StartOf(4)) { + Identifier(); + } else if (la.kind == 158) { + lexer.NextToken(); + } else if (la.kind == 153) { + lexer.NextToken(); + } else SynErr(275); + +#line 1655 "VBNET.ATG" + name = t.val; + Expect(26); + IdentifierOrKeyword( +#line 1657 "VBNET.ATG" +out eventName); + +#line 1658 "VBNET.ATG" + name = name + "." + eventName; + } + + void IdentifierOrKeyword( +#line 3675 "VBNET.ATG" +out string name) { + lexer.NextToken(); + +#line 3677 "VBNET.ATG" + name = t.val; + } + + void QueryExpr( +#line 2296 "VBNET.ATG" +out Expression expr) { + +#line 2298 "VBNET.ATG" + QueryExpressionVB qexpr = new QueryExpressionVB(); + qexpr.StartLocation = la.Location; + expr = qexpr; + + FromOrAggregateQueryOperator( +#line 2302 "VBNET.ATG" +qexpr.Clauses); + while (StartOf(31)) { + QueryOperator( +#line 2303 "VBNET.ATG" +qexpr.Clauses); + } + +#line 2305 "VBNET.ATG" + qexpr.EndLocation = t.EndLocation; + + } + + void LambdaExpr( +#line 2210 "VBNET.ATG" +out Expression expr) { + +#line 2212 "VBNET.ATG" + LambdaExpression lambda = null; + + if (la.kind == 210) { + SubLambdaExpression( +#line 2214 "VBNET.ATG" +out lambda); + } else if (la.kind == 127) { + FunctionLambdaExpression( +#line 2215 "VBNET.ATG" +out lambda); + } else SynErr(276); + +#line 2216 "VBNET.ATG" + expr = lambda; + } + + void DisjunctionExpr( +#line 1960 "VBNET.ATG" +out Expression outExpr) { + +#line 1962 "VBNET.ATG" + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; + + ConjunctionExpr( +#line 1966 "VBNET.ATG" +out outExpr); + while (la.kind == 175 || la.kind == 177 || la.kind == 236) { + if (la.kind == 175) { + lexer.NextToken(); + +#line 1969 "VBNET.ATG" + op = BinaryOperatorType.BitwiseOr; + } else if (la.kind == 177) { + lexer.NextToken(); + +#line 1970 "VBNET.ATG" + op = BinaryOperatorType.LogicalOr; + } else { + lexer.NextToken(); + +#line 1971 "VBNET.ATG" + op = BinaryOperatorType.ExclusiveOr; + } + ConjunctionExpr( +#line 1973 "VBNET.ATG" +out expr); + +#line 1973 "VBNET.ATG" + outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void AssignmentOperator( +#line 1678 "VBNET.ATG" +out AssignmentOperatorType op) { + +#line 1679 "VBNET.ATG" + op = AssignmentOperatorType.None; + switch (la.kind) { + case 20: { + lexer.NextToken(); + +#line 1680 "VBNET.ATG" + op = AssignmentOperatorType.Assign; + break; + } + case 54: { + lexer.NextToken(); + +#line 1681 "VBNET.ATG" + op = AssignmentOperatorType.ConcatString; + break; + } + case 46: { + lexer.NextToken(); + +#line 1682 "VBNET.ATG" + op = AssignmentOperatorType.Add; + break; + } + case 48: { + lexer.NextToken(); + +#line 1683 "VBNET.ATG" + op = AssignmentOperatorType.Subtract; + break; + } + case 49: { + lexer.NextToken(); + +#line 1684 "VBNET.ATG" + op = AssignmentOperatorType.Multiply; + break; + } + case 50: { + lexer.NextToken(); + +#line 1685 "VBNET.ATG" + op = AssignmentOperatorType.Divide; + break; + } + case 51: { + lexer.NextToken(); + +#line 1686 "VBNET.ATG" + op = AssignmentOperatorType.DivideInteger; + break; + } + case 47: { + lexer.NextToken(); + +#line 1687 "VBNET.ATG" + op = AssignmentOperatorType.Power; + break; + } + case 52: { + lexer.NextToken(); + +#line 1688 "VBNET.ATG" + op = AssignmentOperatorType.ShiftLeft; + break; + } + case 53: { + lexer.NextToken(); + +#line 1689 "VBNET.ATG" + op = AssignmentOperatorType.ShiftRight; + break; + } + default: SynErr(277); break; + } + } + + void SimpleExpr( +#line 1693 "VBNET.ATG" +out Expression pexpr) { + +#line 1694 "VBNET.ATG" + string name; Location startLocation = la.Location; + SimpleNonInvocationExpression( +#line 1697 "VBNET.ATG" +out pexpr); + while (StartOf(32)) { + if (la.kind == 26) { + lexer.NextToken(); + if (la.kind == 10) { + lexer.NextToken(); + IdentifierOrKeyword( +#line 1700 "VBNET.ATG" +out name); + Expect(11); + +#line 1701 "VBNET.ATG" + pexpr = new XmlMemberAccessExpression(pexpr, XmlAxisType.Element, name, true); + } else if (StartOf(33)) { + IdentifierOrKeyword( +#line 1702 "VBNET.ATG" +out name); + +#line 1703 "VBNET.ATG" + pexpr = new MemberReferenceExpression(pexpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } else SynErr(278); + if ( +#line 1705 "VBNET.ATG" +la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { + lexer.NextToken(); + Expect(169); + TypeArgumentList( +#line 1706 "VBNET.ATG" +((MemberReferenceExpression)pexpr).TypeArguments); + Expect(38); + } + } else if (la.kind == 29) { + lexer.NextToken(); + IdentifierOrKeyword( +#line 1708 "VBNET.ATG" +out name); + +#line 1708 "VBNET.ATG" + pexpr = new BinaryOperatorExpression(pexpr, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation }); + } else if (la.kind == 27 || la.kind == 28) { + +#line 1709 "VBNET.ATG" + XmlAxisType type = XmlAxisType.Attribute; bool isXmlName = false; + if (la.kind == 28) { + lexer.NextToken(); + } else if (la.kind == 27) { + lexer.NextToken(); + +#line 1710 "VBNET.ATG" + type = XmlAxisType.Descendents; + } else SynErr(279); + if (la.kind == 10) { + lexer.NextToken(); + +#line 1710 "VBNET.ATG" + isXmlName = true; + } + IdentifierOrKeyword( +#line 1710 "VBNET.ATG" +out name); + if (la.kind == 11) { + lexer.NextToken(); + } + +#line 1711 "VBNET.ATG" + pexpr = new XmlMemberAccessExpression(pexpr, type, name, isXmlName); + } else { + InvocationExpression( +#line 1712 "VBNET.ATG" +ref pexpr); + } + } + +#line 1716 "VBNET.ATG" + if (pexpr != null) { + pexpr.StartLocation = startLocation; + pexpr.EndLocation = t.EndLocation; + } + + } + + void SimpleNonInvocationExpression( +#line 1723 "VBNET.ATG" +out Expression pexpr) { + +#line 1725 "VBNET.ATG" + Expression expr; + CollectionInitializerExpression cie; + TypeReference type = null; + string name = String.Empty; + Location startLocation = la.Location; + pexpr = null; + + if (StartOf(34)) { + switch (la.kind) { + case 3: { + lexer.NextToken(); + +#line 1735 "VBNET.ATG" + pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; + break; + } + case 4: { + lexer.NextToken(); + +#line 1736 "VBNET.ATG" + pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; + break; + } + case 7: { + lexer.NextToken(); + +#line 1737 "VBNET.ATG" + pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; + break; + } + case 6: { + lexer.NextToken(); + +#line 1738 "VBNET.ATG" + pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; + break; + } + case 5: { + lexer.NextToken(); + +#line 1739 "VBNET.ATG" + pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; + break; + } + case 9: { + lexer.NextToken(); + +#line 1740 "VBNET.ATG" + pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; + break; + } + case 8: { + lexer.NextToken(); + +#line 1741 "VBNET.ATG" + pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; + break; + } + case 217: { + lexer.NextToken(); + +#line 1743 "VBNET.ATG" + pexpr = new PrimitiveExpression(true, "true"); + break; + } + case 122: { + lexer.NextToken(); + +#line 1744 "VBNET.ATG" + pexpr = new PrimitiveExpression(false, "false"); + break; + } + case 165: { + lexer.NextToken(); + +#line 1745 "VBNET.ATG" + pexpr = new PrimitiveExpression(null, "null"); + break; + } + case 37: { + lexer.NextToken(); + Expr( +#line 1746 "VBNET.ATG" +out expr); + Expect(38); + +#line 1746 "VBNET.ATG" + pexpr = new ParenthesizedExpression(expr); + break; + } + case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 70: case 87: case 98: case 104: case 107: case 116: case 121: case 126: case 133: case 139: case 143: case 146: case 147: case 170: case 176: case 178: case 184: case 203: case 212: case 213: case 223: case 224: case 230: { + Identifier(); + +#line 1748 "VBNET.ATG" + pexpr = new IdentifierExpression(t.val); + pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; + + if ( +#line 1751 "VBNET.ATG" +la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { + lexer.NextToken(); + Expect(169); + TypeArgumentList( +#line 1752 "VBNET.ATG" +((IdentifierExpression)pexpr).TypeArguments); + Expect(38); + } + break; + } + case 68: case 71: case 82: case 99: case 100: case 109: case 141: case 151: case 168: case 196: case 201: case 202: case 208: case 221: case 222: case 225: { + +#line 1754 "VBNET.ATG" + string val = String.Empty; + if (StartOf(12)) { + PrimitiveTypeName( +#line 1755 "VBNET.ATG" +out val); + } else if (la.kind == 168) { + lexer.NextToken(); + +#line 1755 "VBNET.ATG" + val = "System.Object"; + } else SynErr(280); + +#line 1756 "VBNET.ATG" + pexpr = new TypeReferenceExpression(new TypeReference(val, true)); + break; + } + case 153: { + lexer.NextToken(); + +#line 1757 "VBNET.ATG" + pexpr = new ThisReferenceExpression(); + break; + } + case 158: case 159: { + +#line 1758 "VBNET.ATG" + Expression retExpr = null; + if (la.kind == 158) { + lexer.NextToken(); + +#line 1759 "VBNET.ATG" + retExpr = new BaseReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation }; + } else if (la.kind == 159) { + lexer.NextToken(); + +#line 1760 "VBNET.ATG" + retExpr = new ClassReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation }; + } else SynErr(281); + Expect(26); + IdentifierOrKeyword( +#line 1762 "VBNET.ATG" +out name); + +#line 1762 "VBNET.ATG" + pexpr = new MemberReferenceExpression(retExpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; + break; + } + case 130: { + lexer.NextToken(); + Expect(26); + Identifier(); + +#line 1764 "VBNET.ATG" + type = new TypeReference(t.val ?? ""); + +#line 1766 "VBNET.ATG" + type.IsGlobal = true; + +#line 1767 "VBNET.ATG" + pexpr = new TypeReferenceExpression(type); + break; + } + case 162: { + ObjectCreateExpression( +#line 1768 "VBNET.ATG" +out expr); + +#line 1768 "VBNET.ATG" + pexpr = expr; + break; + } + case 35: { + CollectionInitializer( +#line 1769 "VBNET.ATG" +out cie); + +#line 1769 "VBNET.ATG" + pexpr = cie; + break; + } + case 94: case 106: case 219: { + +#line 1771 "VBNET.ATG" + CastType castType = CastType.Cast; + if (la.kind == 106) { + lexer.NextToken(); + } else if (la.kind == 94) { + lexer.NextToken(); + +#line 1773 "VBNET.ATG" + castType = CastType.Conversion; + } else if (la.kind == 219) { + lexer.NextToken(); + +#line 1774 "VBNET.ATG" + castType = CastType.TryCast; + } else SynErr(282); + Expect(37); + Expr( +#line 1776 "VBNET.ATG" +out expr); + Expect(22); + TypeName( +#line 1776 "VBNET.ATG" +out type); + Expect(38); + +#line 1777 "VBNET.ATG" + pexpr = new CastExpression(type, expr, castType); + break; + } + case 76: case 77: case 78: case 79: case 80: case 81: case 83: case 85: case 86: case 90: case 91: case 92: case 93: case 95: case 96: case 97: { + CastTarget( +#line 1778 "VBNET.ATG" +out type); + Expect(37); + Expr( +#line 1778 "VBNET.ATG" +out expr); + Expect(38); + +#line 1778 "VBNET.ATG" + pexpr = new CastExpression(type, expr, CastType.PrimitiveConversion); + break; + } + case 57: { + lexer.NextToken(); + Expr( +#line 1779 "VBNET.ATG" +out expr); + +#line 1779 "VBNET.ATG" + pexpr = new AddressOfExpression(expr); + break; + } + case 129: { + lexer.NextToken(); + Expect(37); + GetTypeTypeName( +#line 1780 "VBNET.ATG" +out type); + Expect(38); + +#line 1780 "VBNET.ATG" + pexpr = new TypeOfExpression(type); + break; + } + case 220: { + lexer.NextToken(); + SimpleExpr( +#line 1781 "VBNET.ATG" +out expr); + Expect(144); + TypeName( +#line 1781 "VBNET.ATG" +out type); + +#line 1781 "VBNET.ATG" + pexpr = new TypeOfIsExpression(expr, type); + break; + } + case 135: { + ConditionalExpression( +#line 1782 "VBNET.ATG" +out pexpr); + break; + } + case 10: case 16: case 17: case 18: case 19: { + XmlLiteralExpression( +#line 1783 "VBNET.ATG" +out pexpr); + break; + } + } + } else if (StartOf(35)) { + if (la.kind == 26) { + lexer.NextToken(); + if (la.kind == 10) { + lexer.NextToken(); + IdentifierOrKeyword( +#line 1789 "VBNET.ATG" +out name); + Expect(11); + +#line 1790 "VBNET.ATG" + pexpr = new XmlMemberAccessExpression(null, XmlAxisType.Element, name, true) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } else if (StartOf(33)) { + IdentifierOrKeyword( +#line 1791 "VBNET.ATG" +out name); + +#line 1792 "VBNET.ATG" + pexpr = new MemberReferenceExpression(null, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } else SynErr(283); + } else if (la.kind == 29) { + lexer.NextToken(); + IdentifierOrKeyword( +#line 1794 "VBNET.ATG" +out name); + +#line 1794 "VBNET.ATG" + pexpr = new BinaryOperatorExpression(null, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation }); + } else { + +#line 1795 "VBNET.ATG" + XmlAxisType axisType = XmlAxisType.Element; bool isXmlIdentifier = false; + if (la.kind == 27) { + lexer.NextToken(); + +#line 1796 "VBNET.ATG" + axisType = XmlAxisType.Descendents; + } else if (la.kind == 28) { + lexer.NextToken(); + +#line 1796 "VBNET.ATG" + axisType = XmlAxisType.Attribute; + } else SynErr(284); + if (la.kind == 10) { + lexer.NextToken(); + +#line 1797 "VBNET.ATG" + isXmlIdentifier = true; + } + IdentifierOrKeyword( +#line 1797 "VBNET.ATG" +out name); + if (la.kind == 11) { + lexer.NextToken(); + } + +#line 1798 "VBNET.ATG" + pexpr = new XmlMemberAccessExpression(null, axisType, name, isXmlIdentifier); + } + } else SynErr(285); + +#line 1803 "VBNET.ATG" + if (pexpr != null) { + pexpr.StartLocation = startLocation; + pexpr.EndLocation = t.EndLocation; + } + + } + + void TypeArgumentList( +#line 2811 "VBNET.ATG" +List typeArguments) { + +#line 2813 "VBNET.ATG" + TypeReference typeref; + + TypeName( +#line 2815 "VBNET.ATG" +out typeref); + +#line 2815 "VBNET.ATG" + if (typeref != null) typeArguments.Add(typeref); + while (la.kind == 22) { + lexer.NextToken(); + TypeName( +#line 2818 "VBNET.ATG" +out typeref); + +#line 2818 "VBNET.ATG" + if (typeref != null) typeArguments.Add(typeref); + } + } + + void InvocationExpression( +#line 1924 "VBNET.ATG" +ref Expression pexpr) { + +#line 1925 "VBNET.ATG" + List parameters = null; + Expect(37); + +#line 1927 "VBNET.ATG" + Location start = t.Location; + ArgumentList( +#line 1928 "VBNET.ATG" +out parameters); + Expect(38); + +#line 1931 "VBNET.ATG" + pexpr = new InvocationExpression(pexpr, parameters); + + +#line 1933 "VBNET.ATG" + pexpr.StartLocation = start; pexpr.EndLocation = t.Location; + } + + void PrimitiveTypeName( +#line 3682 "VBNET.ATG" +out string type) { + +#line 3683 "VBNET.ATG" + type = String.Empty; + switch (la.kind) { + case 68: { + lexer.NextToken(); + +#line 3684 "VBNET.ATG" + type = "System.Boolean"; + break; + } + case 99: { + lexer.NextToken(); + +#line 3685 "VBNET.ATG" + type = "System.DateTime"; + break; + } + case 82: { + lexer.NextToken(); + +#line 3686 "VBNET.ATG" + type = "System.Char"; + break; + } + case 208: { + lexer.NextToken(); + +#line 3687 "VBNET.ATG" + type = "System.String"; + break; + } + case 100: { + lexer.NextToken(); + +#line 3688 "VBNET.ATG" + type = "System.Decimal"; + break; + } + case 71: { + lexer.NextToken(); + +#line 3689 "VBNET.ATG" + type = "System.Byte"; + break; + } + case 201: { + lexer.NextToken(); + +#line 3690 "VBNET.ATG" + type = "System.Int16"; + break; + } + case 141: { + lexer.NextToken(); + +#line 3691 "VBNET.ATG" + type = "System.Int32"; + break; + } + case 151: { + lexer.NextToken(); + +#line 3692 "VBNET.ATG" + type = "System.Int64"; + break; + } + case 202: { + lexer.NextToken(); + +#line 3693 "VBNET.ATG" + type = "System.Single"; + break; + } + case 109: { + lexer.NextToken(); + +#line 3694 "VBNET.ATG" + type = "System.Double"; + break; + } + case 221: { + lexer.NextToken(); + +#line 3695 "VBNET.ATG" + type = "System.UInt32"; + break; + } + case 222: { + lexer.NextToken(); + +#line 3696 "VBNET.ATG" + type = "System.UInt64"; + break; + } + case 225: { + lexer.NextToken(); + +#line 3697 "VBNET.ATG" + type = "System.UInt16"; + break; + } + case 196: { + lexer.NextToken(); + +#line 3698 "VBNET.ATG" + type = "System.SByte"; + break; + } + default: SynErr(286); break; + } + } + + void CastTarget( +#line 1938 "VBNET.ATG" +out TypeReference type) { + +#line 1940 "VBNET.ATG" + type = null; + + switch (la.kind) { + case 76: { + lexer.NextToken(); + +#line 1942 "VBNET.ATG" + type = new TypeReference("System.Boolean", true); + break; + } + case 77: { + lexer.NextToken(); + +#line 1943 "VBNET.ATG" + type = new TypeReference("System.Byte", true); + break; + } + case 90: { + lexer.NextToken(); + +#line 1944 "VBNET.ATG" + type = new TypeReference("System.SByte", true); + break; + } + case 78: { + lexer.NextToken(); + +#line 1945 "VBNET.ATG" + type = new TypeReference("System.Char", true); + break; + } + case 79: { + lexer.NextToken(); + +#line 1946 "VBNET.ATG" + type = new TypeReference("System.DateTime", true); + break; + } + case 81: { + lexer.NextToken(); + +#line 1947 "VBNET.ATG" + type = new TypeReference("System.Decimal", true); + break; + } + case 80: { + lexer.NextToken(); + +#line 1948 "VBNET.ATG" + type = new TypeReference("System.Double", true); + break; + } + case 91: { + lexer.NextToken(); + +#line 1949 "VBNET.ATG" + type = new TypeReference("System.Int16", true); + break; + } + case 83: { + lexer.NextToken(); + +#line 1950 "VBNET.ATG" + type = new TypeReference("System.Int32", true); + break; + } + case 85: { + lexer.NextToken(); + +#line 1951 "VBNET.ATG" + type = new TypeReference("System.Int64", true); + break; + } + case 97: { + lexer.NextToken(); + +#line 1952 "VBNET.ATG" + type = new TypeReference("System.UInt16", true); + break; + } + case 95: { + lexer.NextToken(); + +#line 1953 "VBNET.ATG" + type = new TypeReference("System.UInt32", true); + break; + } + case 96: { + lexer.NextToken(); + +#line 1954 "VBNET.ATG" + type = new TypeReference("System.UInt64", true); + break; + } + case 86: { + lexer.NextToken(); + +#line 1955 "VBNET.ATG" + type = new TypeReference("System.Object", true); + break; + } + case 92: { + lexer.NextToken(); + +#line 1956 "VBNET.ATG" + type = new TypeReference("System.Single", true); + break; + } + case 93: { + lexer.NextToken(); + +#line 1957 "VBNET.ATG" + type = new TypeReference("System.String", true); + break; + } + default: SynErr(287); break; + } + } + + void GetTypeTypeName( +#line 2710 "VBNET.ATG" +out TypeReference typeref) { + +#line 2711 "VBNET.ATG" + ArrayList rank = null; + NonArrayTypeName( +#line 2713 "VBNET.ATG" +out typeref, true); + ArrayTypeModifiers( +#line 2714 "VBNET.ATG" +out rank); + +#line 2715 "VBNET.ATG" + if (rank != null && typeref != null) { + typeref.RankSpecifier = (int[])rank.ToArray(typeof(int)); + } + + } + + void ConditionalExpression( +#line 1890 "VBNET.ATG" +out Expression expr) { + +#line 1892 "VBNET.ATG" + ConditionalExpression conditionalExpression = new ConditionalExpression(); + BinaryOperatorExpression binaryOperatorExpression = new BinaryOperatorExpression(); + conditionalExpression.StartLocation = binaryOperatorExpression.StartLocation = la.Location; + + Expression condition = null; + Expression trueExpr = null; + Expression falseExpr = null; + + Expect(135); + Expect(37); + Expr( +#line 1901 "VBNET.ATG" +out condition); + Expect(22); + Expr( +#line 1901 "VBNET.ATG" +out trueExpr); + if (la.kind == 22) { + lexer.NextToken(); + Expr( +#line 1901 "VBNET.ATG" +out falseExpr); + } + Expect(38); + +#line 1903 "VBNET.ATG" + if(falseExpr != null) + { + conditionalExpression.Condition = condition; + conditionalExpression.TrueExpression = trueExpr; + conditionalExpression.FalseExpression = falseExpr; + conditionalExpression.EndLocation = t.EndLocation; + + expr = conditionalExpression; + } + else + { + binaryOperatorExpression.Left = condition; + binaryOperatorExpression.Right = trueExpr; + binaryOperatorExpression.Op = BinaryOperatorType.NullCoalescing; + binaryOperatorExpression.EndLocation = t.EndLocation; + + expr = binaryOperatorExpression; + } + + } + + void XmlLiteralExpression( +#line 1810 "VBNET.ATG" +out Expression pexpr) { + +#line 1812 "VBNET.ATG" + List exprs = new List(); + XmlExpression currentExpression = null; + + if (StartOf(36)) { + XmlContentExpression( +#line 1817 "VBNET.ATG" +exprs); + while (StartOf(36)) { + XmlContentExpression( +#line 1817 "VBNET.ATG" +exprs); + } + if (la.kind == 10) { + XmlElement( +#line 1817 "VBNET.ATG" +out currentExpression); + +#line 1817 "VBNET.ATG" + exprs.Add(currentExpression); + while (StartOf(36)) { + XmlContentExpression( +#line 1817 "VBNET.ATG" +exprs); + } + } + } else if (la.kind == 10) { + XmlElement( +#line 1819 "VBNET.ATG" +out currentExpression); + +#line 1819 "VBNET.ATG" + exprs.Add(currentExpression); + while (StartOf(36)) { + XmlContentExpression( +#line 1819 "VBNET.ATG" +exprs); + } + } else SynErr(288); + +#line 1822 "VBNET.ATG" + if (exprs.Count > 1) { + pexpr = new XmlDocumentExpression() { Expressions = exprs }; + } else { + pexpr = exprs[0]; + } + + } + + void XmlContentExpression( +#line 1830 "VBNET.ATG" +List exprs) { + +#line 1831 "VBNET.ATG" + XmlContentExpression expr = null; + if (la.kind == 16) { + lexer.NextToken(); + +#line 1833 "VBNET.ATG" + expr = new XmlContentExpression(t.val, XmlContentType.Text); + } else if (la.kind == 18) { + lexer.NextToken(); + +#line 1834 "VBNET.ATG" + expr = new XmlContentExpression(t.val, XmlContentType.CData); + } else if (la.kind == 17) { + lexer.NextToken(); + +#line 1835 "VBNET.ATG" + expr = new XmlContentExpression(t.val, XmlContentType.Comment); + } else if (la.kind == 19) { + lexer.NextToken(); + +#line 1836 "VBNET.ATG" + expr = new XmlContentExpression(t.val, XmlContentType.ProcessingInstruction); + } else SynErr(289); + +#line 1839 "VBNET.ATG" + expr.StartLocation = t.Location; + expr.EndLocation = t.EndLocation; + exprs.Add(expr); + + } + + void XmlElement( +#line 1865 "VBNET.ATG" +out XmlExpression expr) { + +#line 1866 "VBNET.ATG" + XmlElementExpression el = new XmlElementExpression(); + Expect(10); + +#line 1869 "VBNET.ATG" + el.StartLocation = t.Location; + if (la.kind == 12) { + lexer.NextToken(); + +#line 1870 "VBNET.ATG" + Expression innerExpression; + Expr( +#line 1870 "VBNET.ATG" +out innerExpression); + Expect(13); + +#line 1871 "VBNET.ATG" + el.NameExpression = new XmlEmbeddedExpression() { InlineVBExpression = innerExpression }; + } else if (StartOf(4)) { + Identifier(); + +#line 1872 "VBNET.ATG" + el.XmlName = t.val; + } else SynErr(290); + while (StartOf(37)) { + XmlAttribute( +#line 1872 "VBNET.ATG" +el.Attributes); + } + if (la.kind == 14) { + lexer.NextToken(); + +#line 1873 "VBNET.ATG" + el.EndLocation = t.EndLocation; + } else if (la.kind == 11) { + lexer.NextToken(); + while (StartOf(38)) { + +#line 1873 "VBNET.ATG" + XmlExpression child; + XmlNestedContent( +#line 1873 "VBNET.ATG" +out child); + +#line 1873 "VBNET.ATG" + el.Children.Add(child); + } + Expect(15); + while (StartOf(39)) { + lexer.NextToken(); + } + Expect(11); + +#line 1873 "VBNET.ATG" + el.EndLocation = t.EndLocation; + } else SynErr(291); + +#line 1875 "VBNET.ATG" + expr = el; + } + + void XmlNestedContent( +#line 1845 "VBNET.ATG" +out XmlExpression expr) { + +#line 1846 "VBNET.ATG" + XmlExpression tmpExpr = null; Location start = la.Location; + switch (la.kind) { + case 16: { + lexer.NextToken(); + +#line 1849 "VBNET.ATG" + tmpExpr = new XmlContentExpression(t.val, XmlContentType.Text); + break; + } + case 18: { + lexer.NextToken(); + +#line 1850 "VBNET.ATG" + tmpExpr = new XmlContentExpression(t.val, XmlContentType.CData); + break; + } + case 17: { + lexer.NextToken(); + +#line 1851 "VBNET.ATG" + tmpExpr = new XmlContentExpression(t.val, XmlContentType.Comment); + break; + } + case 19: { + lexer.NextToken(); + +#line 1852 "VBNET.ATG" + tmpExpr = new XmlContentExpression(t.val, XmlContentType.ProcessingInstruction); + break; + } + case 12: { + lexer.NextToken(); + +#line 1853 "VBNET.ATG" + Expression innerExpression; + Expr( +#line 1853 "VBNET.ATG" +out innerExpression); + Expect(13); + +#line 1853 "VBNET.ATG" + tmpExpr = new XmlEmbeddedExpression() { InlineVBExpression = innerExpression }; + break; + } + case 10: { + XmlElement( +#line 1854 "VBNET.ATG" +out tmpExpr); + break; + } + default: SynErr(292); break; + } + +#line 1857 "VBNET.ATG" + if (tmpExpr.StartLocation.IsEmpty) + tmpExpr.StartLocation = start; + if (tmpExpr.EndLocation.IsEmpty) + tmpExpr.EndLocation = t.EndLocation; + expr = tmpExpr; + + } + + void XmlAttribute( +#line 1878 "VBNET.ATG" +List attrs) { + +#line 1879 "VBNET.ATG" + Location start = la.Location; + if (StartOf(4)) { + Identifier(); + +#line 1881 "VBNET.ATG" + string name = t.val; + Expect(20); + +#line 1882 "VBNET.ATG" + string literalValue = null; Expression expressionValue = null; bool useDoubleQuotes = false; + if (la.kind == 3) { + lexer.NextToken(); + +#line 1883 "VBNET.ATG" + literalValue = t.literalValue.ToString(); useDoubleQuotes = t.val[0] == '"'; + } else if (la.kind == 12) { + lexer.NextToken(); + Expr( +#line 1883 "VBNET.ATG" +out expressionValue); + Expect(13); + } else SynErr(293); + +#line 1884 "VBNET.ATG" + attrs.Add(new XmlAttributeExpression() { Name = name, ExpressionValue = expressionValue, LiteralValue = literalValue, UseDoubleQuotes = useDoubleQuotes, StartLocation = start, EndLocation = t.EndLocation }); + } else if (la.kind == 12) { + lexer.NextToken(); + +#line 1886 "VBNET.ATG" + Expression innerExpression; + Expr( +#line 1886 "VBNET.ATG" +out innerExpression); + Expect(13); + +#line 1887 "VBNET.ATG" + attrs.Add(new XmlEmbeddedExpression() { InlineVBExpression = innerExpression, StartLocation = start, EndLocation = t.EndLocation }); + } else SynErr(294); + } + + void ArgumentList( +#line 2639 "VBNET.ATG" +out List arguments) { + +#line 2641 "VBNET.ATG" + arguments = new List(); + Expression expr = null; + + if (StartOf(24)) { + Argument( +#line 2644 "VBNET.ATG" +out expr); + } + while (la.kind == 22) { + lexer.NextToken(); + +#line 2645 "VBNET.ATG" + arguments.Add(expr ?? Expression.Null); expr = null; + if (StartOf(24)) { + Argument( +#line 2646 "VBNET.ATG" +out expr); + } + +#line 2647 "VBNET.ATG" + if (expr == null) expr = Expression.Null; + } + +#line 2649 "VBNET.ATG" + if (expr != null) arguments.Add(expr); + } + + void ConjunctionExpr( +#line 1977 "VBNET.ATG" +out Expression outExpr) { + +#line 1979 "VBNET.ATG" + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; + + NotExpr( +#line 1983 "VBNET.ATG" +out outExpr); + while (la.kind == 60 || la.kind == 61) { + if (la.kind == 60) { + lexer.NextToken(); + +#line 1986 "VBNET.ATG" + op = BinaryOperatorType.BitwiseAnd; + } else { + lexer.NextToken(); + +#line 1987 "VBNET.ATG" + op = BinaryOperatorType.LogicalAnd; + } + NotExpr( +#line 1989 "VBNET.ATG" +out expr); + +#line 1989 "VBNET.ATG" + outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void NotExpr( +#line 1993 "VBNET.ATG" +out Expression outExpr) { + +#line 1994 "VBNET.ATG" + UnaryOperatorType uop = UnaryOperatorType.None; + while (la.kind == 164) { + lexer.NextToken(); + +#line 1995 "VBNET.ATG" + uop = UnaryOperatorType.Not; + } + ComparisonExpr( +#line 1996 "VBNET.ATG" +out outExpr); + +#line 1997 "VBNET.ATG" + if (uop != UnaryOperatorType.None) + outExpr = new UnaryOperatorExpression(outExpr, uop); + + } + + void ComparisonExpr( +#line 2002 "VBNET.ATG" +out Expression outExpr) { + +#line 2004 "VBNET.ATG" + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; + + ShiftExpr( +#line 2008 "VBNET.ATG" +out outExpr); + while (StartOf(40)) { + switch (la.kind) { + case 40: { + lexer.NextToken(); + +#line 2011 "VBNET.ATG" + op = BinaryOperatorType.LessThan; + break; + } + case 39: { + lexer.NextToken(); + +#line 2012 "VBNET.ATG" + op = BinaryOperatorType.GreaterThan; + break; + } + case 43: { + lexer.NextToken(); + +#line 2013 "VBNET.ATG" + op = BinaryOperatorType.LessThanOrEqual; + break; + } + case 42: { + lexer.NextToken(); + +#line 2014 "VBNET.ATG" + op = BinaryOperatorType.GreaterThanOrEqual; + break; + } + case 41: { + lexer.NextToken(); + +#line 2015 "VBNET.ATG" + op = BinaryOperatorType.InEquality; + break; + } + case 20: { + lexer.NextToken(); + +#line 2016 "VBNET.ATG" + op = BinaryOperatorType.Equality; + break; + } + case 150: { + lexer.NextToken(); + +#line 2017 "VBNET.ATG" + op = BinaryOperatorType.Like; + break; + } + case 144: { + lexer.NextToken(); + +#line 2018 "VBNET.ATG" + op = BinaryOperatorType.ReferenceEquality; + break; + } + case 145: { + lexer.NextToken(); + +#line 2019 "VBNET.ATG" + op = BinaryOperatorType.ReferenceInequality; + break; + } + } + if (StartOf(41)) { + ShiftExpr( +#line 2022 "VBNET.ATG" +out expr); + +#line 2022 "VBNET.ATG" + outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } else if (la.kind == 164) { + +#line 2023 "VBNET.ATG" + Location startLocation2 = la.Location; + lexer.NextToken(); + ShiftExpr( +#line 2025 "VBNET.ATG" +out expr); + +#line 2025 "VBNET.ATG" + outExpr = new BinaryOperatorExpression(outExpr, op, new UnaryOperatorExpression(expr, UnaryOperatorType.Not) { StartLocation = startLocation2, EndLocation = t.EndLocation }) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } else SynErr(295); + } + } + + void ShiftExpr( +#line 2030 "VBNET.ATG" +out Expression outExpr) { + +#line 2032 "VBNET.ATG" + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; + + ConcatenationExpr( +#line 2036 "VBNET.ATG" +out outExpr); + while (la.kind == 44 || la.kind == 45) { + if (la.kind == 44) { + lexer.NextToken(); + +#line 2039 "VBNET.ATG" + op = BinaryOperatorType.ShiftLeft; + } else { + lexer.NextToken(); + +#line 2040 "VBNET.ATG" + op = BinaryOperatorType.ShiftRight; + } + ConcatenationExpr( +#line 2042 "VBNET.ATG" +out expr); + +#line 2042 "VBNET.ATG" + outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void ConcatenationExpr( +#line 2046 "VBNET.ATG" +out Expression outExpr) { + +#line 2047 "VBNET.ATG" + Expression expr; Location startLocation = la.Location; + AdditiveExpr( +#line 2049 "VBNET.ATG" +out outExpr); + while (la.kind == 23) { + lexer.NextToken(); + AdditiveExpr( +#line 2049 "VBNET.ATG" +out expr); + +#line 2049 "VBNET.ATG" + outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Concat, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void AdditiveExpr( +#line 2052 "VBNET.ATG" +out Expression outExpr) { + +#line 2054 "VBNET.ATG" + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; + + ModuloExpr( +#line 2058 "VBNET.ATG" +out outExpr); + while (la.kind == 30 || la.kind == 31) { + if (la.kind == 31) { + lexer.NextToken(); + +#line 2061 "VBNET.ATG" + op = BinaryOperatorType.Add; + } else { + lexer.NextToken(); + +#line 2062 "VBNET.ATG" + op = BinaryOperatorType.Subtract; + } + ModuloExpr( +#line 2064 "VBNET.ATG" +out expr); + +#line 2064 "VBNET.ATG" + outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void ModuloExpr( +#line 2068 "VBNET.ATG" +out Expression outExpr) { + +#line 2069 "VBNET.ATG" + Expression expr; Location startLocation = la.Location; + IntegerDivisionExpr( +#line 2071 "VBNET.ATG" +out outExpr); + while (la.kind == 154) { + lexer.NextToken(); + IntegerDivisionExpr( +#line 2071 "VBNET.ATG" +out expr); + +#line 2071 "VBNET.ATG" + outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Modulus, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void IntegerDivisionExpr( +#line 2074 "VBNET.ATG" +out Expression outExpr) { + +#line 2075 "VBNET.ATG" + Expression expr; Location startLocation = la.Location; + MultiplicativeExpr( +#line 2077 "VBNET.ATG" +out outExpr); + while (la.kind == 25) { + lexer.NextToken(); + MultiplicativeExpr( +#line 2077 "VBNET.ATG" +out expr); + +#line 2077 "VBNET.ATG" + outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.DivideInteger, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void MultiplicativeExpr( +#line 2080 "VBNET.ATG" +out Expression outExpr) { + +#line 2082 "VBNET.ATG" + Expression expr; + BinaryOperatorType op = BinaryOperatorType.None; + Location startLocation = la.Location; + + UnaryExpr( +#line 2086 "VBNET.ATG" +out outExpr); + while (la.kind == 24 || la.kind == 34) { + if (la.kind == 34) { + lexer.NextToken(); + +#line 2089 "VBNET.ATG" + op = BinaryOperatorType.Multiply; + } else { + lexer.NextToken(); + +#line 2090 "VBNET.ATG" + op = BinaryOperatorType.Divide; + } + UnaryExpr( +#line 2092 "VBNET.ATG" +out expr); + +#line 2092 "VBNET.ATG" + outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void UnaryExpr( +#line 2096 "VBNET.ATG" +out Expression uExpr) { + +#line 2098 "VBNET.ATG" + Expression expr; + UnaryOperatorType uop = UnaryOperatorType.None; + Location startLocation = la.Location; + bool isUOp = false; + + while (la.kind == 30 || la.kind == 31 || la.kind == 34) { + if (la.kind == 31) { + lexer.NextToken(); + +#line 2103 "VBNET.ATG" + uop = UnaryOperatorType.Plus; isUOp = true; + } else if (la.kind == 30) { + lexer.NextToken(); + +#line 2104 "VBNET.ATG" + uop = UnaryOperatorType.Minus; isUOp = true; + } else { + lexer.NextToken(); + +#line 2105 "VBNET.ATG" + uop = UnaryOperatorType.Dereference; isUOp = true; + } + } + ExponentiationExpr( +#line 2107 "VBNET.ATG" +out expr); + +#line 2109 "VBNET.ATG" + if (isUOp) { + uExpr = new UnaryOperatorExpression(expr, uop) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } else { + uExpr = expr; + } + + } + + void ExponentiationExpr( +#line 2117 "VBNET.ATG" +out Expression outExpr) { + +#line 2118 "VBNET.ATG" + Expression expr; Location startLocation = la.Location; + SimpleExpr( +#line 2120 "VBNET.ATG" +out outExpr); + while (la.kind == 32) { + lexer.NextToken(); + SimpleExpr( +#line 2120 "VBNET.ATG" +out expr); + +#line 2120 "VBNET.ATG" + outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Power, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } + } + + void NormalOrReDimArgumentList( +#line 2653 "VBNET.ATG" +out List arguments, out bool canBeNormal, out bool canBeRedim) { + +#line 2655 "VBNET.ATG" + arguments = new List(); + canBeNormal = true; canBeRedim = !IsNamedAssign(); + Expression expr = null; + + if (StartOf(24)) { + Argument( +#line 2660 "VBNET.ATG" +out expr); + if (la.kind == 216) { + lexer.NextToken(); + +#line 2661 "VBNET.ATG" + EnsureIsZero(expr); canBeNormal = false; + Expr( +#line 2662 "VBNET.ATG" +out expr); + } + } + while (la.kind == 22) { + lexer.NextToken(); + +#line 2665 "VBNET.ATG" + if (expr == null) canBeRedim = false; + +#line 2666 "VBNET.ATG" + arguments.Add(expr ?? Expression.Null); expr = null; + +#line 2667 "VBNET.ATG" + canBeRedim &= !IsNamedAssign(); + if (StartOf(24)) { + Argument( +#line 2668 "VBNET.ATG" +out expr); + if (la.kind == 216) { + lexer.NextToken(); + +#line 2669 "VBNET.ATG" + EnsureIsZero(expr); canBeNormal = false; + Expr( +#line 2670 "VBNET.ATG" +out expr); + } + } + +#line 2672 "VBNET.ATG" + if (expr == null) { canBeRedim = false; expr = Expression.Null; } + } + +#line 2674 "VBNET.ATG" + if (expr != null) arguments.Add(expr); else canBeRedim = false; + } + + void ArrayTypeModifiers( +#line 2784 "VBNET.ATG" +out ArrayList arrayModifiers) { + +#line 2786 "VBNET.ATG" + arrayModifiers = new ArrayList(); + int i = 0; + + while ( +#line 2789 "VBNET.ATG" +IsDims()) { + Expect(37); + if (la.kind == 22 || la.kind == 38) { + RankList( +#line 2791 "VBNET.ATG" +out i); + } + +#line 2793 "VBNET.ATG" + arrayModifiers.Add(i); + + Expect(38); + } + +#line 2798 "VBNET.ATG" + if(arrayModifiers.Count == 0) { + arrayModifiers = null; + } + + } + + void MemberInitializer( +#line 2620 "VBNET.ATG" +out MemberInitializerExpression memberInitializer) { + +#line 2622 "VBNET.ATG" + memberInitializer = new MemberInitializerExpression(); + memberInitializer.StartLocation = la.Location; + Expression initExpr = null; + bool isKey = false; + string name = null; + + if (la.kind == 147) { + lexer.NextToken(); + +#line 2628 "VBNET.ATG" + isKey = true; + } + Expect(26); + IdentifierOrKeyword( +#line 2629 "VBNET.ATG" +out name); + Expect(20); + Expr( +#line 2629 "VBNET.ATG" +out initExpr); + +#line 2631 "VBNET.ATG" + memberInitializer.Name = name; + memberInitializer.Expression = initExpr; + memberInitializer.IsKey = isKey; + memberInitializer.EndLocation = t.EndLocation; + + } + + void SubLambdaExpression( +#line 2219 "VBNET.ATG" +out LambdaExpression lambda) { + +#line 2221 "VBNET.ATG" + lambda = new LambdaExpression(); + lambda.ReturnType = new TypeReference("System.Void", true); + Expression inner = null; + Statement statement = null; + lambda.StartLocation = la.Location; + + Expect(210); + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 2228 "VBNET.ATG" +lambda.Parameters); + } + Expect(38); + } + if (StartOf(42)) { + if (StartOf(24)) { + Expr( +#line 2231 "VBNET.ATG" +out inner); + +#line 2233 "VBNET.ATG" + lambda.ExpressionBody = inner; + lambda.EndLocation = t.EndLocation; // la.Location? + lambda.ExtendedEndLocation = la.Location; + + } else { + EmbeddedStatement( +#line 2238 "VBNET.ATG" +out statement); + +#line 2240 "VBNET.ATG" + lambda.StatementBody = statement; + lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; + + } + } else if (la.kind == 1) { + lexer.NextToken(); + Block( +#line 2247 "VBNET.ATG" +out statement); + Expect(113); + Expect(210); + +#line 2250 "VBNET.ATG" + lambda.StatementBody = statement; + lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; + + } else SynErr(296); + } + + void FunctionLambdaExpression( +#line 2257 "VBNET.ATG" +out LambdaExpression lambda) { + +#line 2259 "VBNET.ATG" + lambda = new LambdaExpression(); + TypeReference typeRef = null; + Expression inner = null; + Statement statement = null; + lambda.StartLocation = la.Location; + + Expect(127); + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(6)) { + FormalParameterList( +#line 2266 "VBNET.ATG" +lambda.Parameters); + } + Expect(38); + } + if (la.kind == 63) { + lexer.NextToken(); + TypeName( +#line 2267 "VBNET.ATG" +out typeRef); + +#line 2267 "VBNET.ATG" + lambda.ReturnType = typeRef; + } + if (StartOf(42)) { + if (StartOf(24)) { + Expr( +#line 2270 "VBNET.ATG" +out inner); + +#line 2272 "VBNET.ATG" + lambda.ExpressionBody = inner; + lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; + + } else { + EmbeddedStatement( +#line 2277 "VBNET.ATG" +out statement); + +#line 2279 "VBNET.ATG" + lambda.StatementBody = statement; + lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; + + } + } else if (la.kind == 1) { + lexer.NextToken(); + Block( +#line 2286 "VBNET.ATG" +out statement); + Expect(113); + Expect(127); + +#line 2289 "VBNET.ATG" + lambda.StatementBody = statement; + lambda.EndLocation = t.EndLocation; + lambda.ExtendedEndLocation = la.Location; + + } else SynErr(297); + } + + void EmbeddedStatement( +#line 3070 "VBNET.ATG" +out Statement statement) { + +#line 3072 "VBNET.ATG" + Statement embeddedStatement = null; + statement = null; + Expression expr = null; + string name = String.Empty; + List p = null; + Location startLocation = la.Location; + + if (la.kind == 120) { + lexer.NextToken(); + +#line 3080 "VBNET.ATG" + ExitType exitType = ExitType.None; + switch (la.kind) { + case 210: { + lexer.NextToken(); + +#line 3082 "VBNET.ATG" + exitType = ExitType.Sub; + break; + } + case 127: { + lexer.NextToken(); + +#line 3084 "VBNET.ATG" + exitType = ExitType.Function; + break; + } + case 186: { + lexer.NextToken(); + +#line 3086 "VBNET.ATG" + exitType = ExitType.Property; + break; + } + case 108: { + lexer.NextToken(); + +#line 3088 "VBNET.ATG" + exitType = ExitType.Do; + break; + } + case 124: { + lexer.NextToken(); + +#line 3090 "VBNET.ATG" + exitType = ExitType.For; + break; + } + case 218: { + lexer.NextToken(); + +#line 3092 "VBNET.ATG" + exitType = ExitType.Try; + break; + } + case 231: { + lexer.NextToken(); + +#line 3094 "VBNET.ATG" + exitType = ExitType.While; + break; + } + case 197: { + lexer.NextToken(); + +#line 3096 "VBNET.ATG" + exitType = ExitType.Select; + break; + } + default: SynErr(298); break; + } + +#line 3098 "VBNET.ATG" + statement = new ExitStatement(exitType); + } else if (la.kind == 218) { + TryStatement( +#line 3099 "VBNET.ATG" +out statement); + } else if (la.kind == 89) { + lexer.NextToken(); + +#line 3100 "VBNET.ATG" + ContinueType continueType = ContinueType.None; + if (la.kind == 108 || la.kind == 124 || la.kind == 231) { + if (la.kind == 108) { + lexer.NextToken(); + +#line 3100 "VBNET.ATG" + continueType = ContinueType.Do; + } else if (la.kind == 124) { + lexer.NextToken(); + +#line 3100 "VBNET.ATG" + continueType = ContinueType.For; + } else { + lexer.NextToken(); + +#line 3100 "VBNET.ATG" + continueType = ContinueType.While; + } + } + +#line 3100 "VBNET.ATG" + statement = new ContinueStatement(continueType); + } else if (la.kind == 215) { + lexer.NextToken(); + if (StartOf(24)) { + Expr( +#line 3102 "VBNET.ATG" +out expr); + } + +#line 3102 "VBNET.ATG" + statement = new ThrowStatement(expr); + } else if (la.kind == 195) { + lexer.NextToken(); + if (StartOf(24)) { + Expr( +#line 3104 "VBNET.ATG" +out expr); + } + +#line 3104 "VBNET.ATG" + statement = new ReturnStatement(expr); + } else if (la.kind == 211) { + lexer.NextToken(); + Expr( +#line 3106 "VBNET.ATG" +out expr); + EndOfStmt(); + Block( +#line 3106 "VBNET.ATG" +out embeddedStatement); + Expect(113); + Expect(211); + +#line 3107 "VBNET.ATG" + statement = new LockStatement(expr, embeddedStatement); + } else if (la.kind == 189) { + lexer.NextToken(); + Identifier(); + +#line 3109 "VBNET.ATG" + name = t.val; + if (la.kind == 37) { + lexer.NextToken(); + if (StartOf(43)) { + ArgumentList( +#line 3110 "VBNET.ATG" +out p); + } + Expect(38); + } + +#line 3112 "VBNET.ATG" + statement = new RaiseEventStatement(name, p); + + } else if (la.kind == 233) { + WithStatement( +#line 3115 "VBNET.ATG" +out statement); + } else if (la.kind == 56) { + lexer.NextToken(); + +#line 3117 "VBNET.ATG" + Expression handlerExpr = null; + Expr( +#line 3118 "VBNET.ATG" +out expr); + Expect(22); + Expr( +#line 3118 "VBNET.ATG" +out handlerExpr); + +#line 3120 "VBNET.ATG" + statement = new AddHandlerStatement(expr, handlerExpr); + + } else if (la.kind == 193) { + lexer.NextToken(); + +#line 3123 "VBNET.ATG" + Expression handlerExpr = null; + Expr( +#line 3124 "VBNET.ATG" +out expr); + Expect(22); + Expr( +#line 3124 "VBNET.ATG" +out handlerExpr); + +#line 3126 "VBNET.ATG" + statement = new RemoveHandlerStatement(expr, handlerExpr); + + } else if (la.kind == 231) { + lexer.NextToken(); + Expr( +#line 3129 "VBNET.ATG" +out expr); + EndOfStmt(); + Block( +#line 3130 "VBNET.ATG" +out embeddedStatement); + Expect(113); + Expect(231); + +#line 3132 "VBNET.ATG" + statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); + + } else if (la.kind == 108) { + lexer.NextToken(); + +#line 3137 "VBNET.ATG" + ConditionType conditionType = ConditionType.None; + + if (la.kind == 224 || la.kind == 231) { + WhileOrUntil( +#line 3140 "VBNET.ATG" +out conditionType); + Expr( +#line 3140 "VBNET.ATG" +out expr); + EndOfStmt(); + Block( +#line 3141 "VBNET.ATG" +out embeddedStatement); + Expect(152); + +#line 3144 "VBNET.ATG" + statement = new DoLoopStatement(expr, + embeddedStatement, + conditionType == ConditionType.While ? ConditionType.DoWhile : conditionType, + ConditionPosition.Start); + + } else if (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + Block( +#line 3151 "VBNET.ATG" +out embeddedStatement); + Expect(152); + if (la.kind == 224 || la.kind == 231) { + WhileOrUntil( +#line 3152 "VBNET.ATG" +out conditionType); + Expr( +#line 3152 "VBNET.ATG" +out expr); + } + +#line 3154 "VBNET.ATG" + statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End); + + } else SynErr(299); + } else if (la.kind == 124) { + lexer.NextToken(); + +#line 3159 "VBNET.ATG" + Expression group = null; + TypeReference typeReference; + string typeName; + + if (la.kind == 110) { + lexer.NextToken(); + LoopControlVariable( +#line 3165 "VBNET.ATG" +out typeReference, out typeName); + Expect(138); + Expr( +#line 3166 "VBNET.ATG" +out group); + EndOfStmt(); + Block( +#line 3167 "VBNET.ATG" +out embeddedStatement); + Expect(163); + if (StartOf(24)) { + Expr( +#line 3168 "VBNET.ATG" +out expr); + } + +#line 3170 "VBNET.ATG" + statement = new ForeachStatement(typeReference, + typeName, + group, + embeddedStatement, + expr); + statement.StartLocation = startLocation; + statement.EndLocation = t.EndLocation; + + + } else if (StartOf(44)) { + +#line 3181 "VBNET.ATG" + Expression start = null; + Expression end = null; + Expression step = null; + Expression variableExpr = null; + Expression nextExpr = null; + List nextExpressions = null; + + if ( +#line 3188 "VBNET.ATG" +IsLoopVariableDeclaration()) { + LoopControlVariable( +#line 3189 "VBNET.ATG" +out typeReference, out typeName); + } else { + +#line 3191 "VBNET.ATG" + typeReference = null; typeName = null; + SimpleExpr( +#line 3192 "VBNET.ATG" +out variableExpr); + } + Expect(20); + Expr( +#line 3194 "VBNET.ATG" +out start); + Expect(216); + Expr( +#line 3194 "VBNET.ATG" +out end); + if (la.kind == 205) { + lexer.NextToken(); + Expr( +#line 3194 "VBNET.ATG" +out step); + } + EndOfStmt(); + Block( +#line 3195 "VBNET.ATG" +out embeddedStatement); + Expect(163); + if (StartOf(24)) { + Expr( +#line 3198 "VBNET.ATG" +out nextExpr); + +#line 3200 "VBNET.ATG" + nextExpressions = new List(); + nextExpressions.Add(nextExpr); + + while (la.kind == 22) { + lexer.NextToken(); + Expr( +#line 3203 "VBNET.ATG" +out nextExpr); + +#line 3203 "VBNET.ATG" + nextExpressions.Add(nextExpr); + } + } + +#line 3206 "VBNET.ATG" + statement = new ForNextStatement { + TypeReference = typeReference, + VariableName = typeName, + LoopVariableExpression = variableExpr, + Start = start, + End = end, + Step = step, + EmbeddedStatement = embeddedStatement, + NextExpressions = nextExpressions + }; + + } else SynErr(300); + } else if (la.kind == 118) { + lexer.NextToken(); + Expr( +#line 3219 "VBNET.ATG" +out expr); + +#line 3219 "VBNET.ATG" + statement = new ErrorStatement(expr); + } else if (la.kind == 191) { + lexer.NextToken(); + +#line 3221 "VBNET.ATG" + bool isPreserve = false; + if (la.kind == 184) { + lexer.NextToken(); + +#line 3221 "VBNET.ATG" + isPreserve = true; + } + ReDimClause( +#line 3222 "VBNET.ATG" +out expr); + +#line 3224 "VBNET.ATG" + ReDimStatement reDimStatement = new ReDimStatement(isPreserve); + statement = reDimStatement; + SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression); + + while (la.kind == 22) { + lexer.NextToken(); + ReDimClause( +#line 3228 "VBNET.ATG" +out expr); + +#line 3229 "VBNET.ATG" + SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression); + } + } else if (la.kind == 117) { + lexer.NextToken(); + Expr( +#line 3233 "VBNET.ATG" +out expr); + +#line 3235 "VBNET.ATG" + EraseStatement eraseStatement = new EraseStatement(); + if (expr != null) { SafeAdd(eraseStatement, eraseStatement.Expressions, expr);} + + while (la.kind == 22) { + lexer.NextToken(); + Expr( +#line 3238 "VBNET.ATG" +out expr); + +#line 3238 "VBNET.ATG" + if (expr != null) { SafeAdd(eraseStatement, eraseStatement.Expressions, expr); } + } + +#line 3239 "VBNET.ATG" + statement = eraseStatement; + } else if (la.kind == 206) { + lexer.NextToken(); + +#line 3241 "VBNET.ATG" + statement = new StopStatement(); + } else if ( +#line 3243 "VBNET.ATG" +la.kind == Tokens.If) { + Expect(135); + +#line 3244 "VBNET.ATG" + Location ifStartLocation = t.Location; + Expr( +#line 3244 "VBNET.ATG" +out expr); + if (la.kind == 214) { + lexer.NextToken(); + } + if (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + Block( +#line 3247 "VBNET.ATG" +out embeddedStatement); + +#line 3249 "VBNET.ATG" + IfElseStatement ifStatement = new IfElseStatement(expr, embeddedStatement); + ifStatement.StartLocation = ifStartLocation; + Location elseIfStart; + + while (la.kind == 112 || +#line 3255 "VBNET.ATG" +IsElseIf()) { + if ( +#line 3255 "VBNET.ATG" +IsElseIf()) { + Expect(111); + +#line 3255 "VBNET.ATG" + elseIfStart = t.Location; + Expect(135); + } else { + lexer.NextToken(); + +#line 3256 "VBNET.ATG" + elseIfStart = t.Location; + } + +#line 3258 "VBNET.ATG" + Expression condition = null; Statement block = null; + Expr( +#line 3259 "VBNET.ATG" +out condition); + if (la.kind == 214) { + lexer.NextToken(); + } + EndOfStmt(); + Block( +#line 3260 "VBNET.ATG" +out block); + +#line 3262 "VBNET.ATG" + ElseIfSection elseIfSection = new ElseIfSection(condition, block); + elseIfSection.StartLocation = elseIfStart; + elseIfSection.EndLocation = t.Location; + elseIfSection.Parent = ifStatement; + ifStatement.ElseIfSections.Add(elseIfSection); + + } + if (la.kind == 111) { + lexer.NextToken(); + if (la.kind == 1 || la.kind == 21) { + EndOfStmt(); + } + Block( +#line 3271 "VBNET.ATG" +out embeddedStatement); + +#line 3273 "VBNET.ATG" + ifStatement.FalseStatement.Add(embeddedStatement); + + } + Expect(113); + Expect(135); + +#line 3277 "VBNET.ATG" + ifStatement.EndLocation = t.Location; + statement = ifStatement; + + } else if (StartOf(45)) { + +#line 3282 "VBNET.ATG" + IfElseStatement ifStatement = new IfElseStatement(expr); + ifStatement.StartLocation = ifStartLocation; + + SingleLineStatementList( +#line 3285 "VBNET.ATG" +ifStatement.TrueStatement); + if (la.kind == 111) { + lexer.NextToken(); + if (StartOf(45)) { + SingleLineStatementList( +#line 3288 "VBNET.ATG" +ifStatement.FalseStatement); + } + } + +#line 3290 "VBNET.ATG" + ifStatement.EndLocation = t.Location; statement = ifStatement; + } else SynErr(301); + } else if (la.kind == 197) { + lexer.NextToken(); + if (la.kind == 74) { + lexer.NextToken(); + } + Expr( +#line 3293 "VBNET.ATG" +out expr); + EndOfStmt(); + +#line 3294 "VBNET.ATG" + List selectSections = new List(); + Statement block = null; + + while (la.kind == 74) { + +#line 3298 "VBNET.ATG" + List caseClauses = null; Location caseLocation = la.Location; + lexer.NextToken(); + CaseClauses( +#line 3299 "VBNET.ATG" +out caseClauses); + if ( +#line 3299 "VBNET.ATG" +IsNotStatementSeparator()) { + lexer.NextToken(); + } + EndOfStmt(); + +#line 3301 "VBNET.ATG" + SwitchSection selectSection = new SwitchSection(caseClauses); + selectSection.StartLocation = caseLocation; + + Block( +#line 3304 "VBNET.ATG" +out block); + +#line 3306 "VBNET.ATG" + selectSection.Children = block.Children; + selectSection.EndLocation = t.EndLocation; + selectSections.Add(selectSection); + + } + +#line 3312 "VBNET.ATG" + statement = new SwitchStatement(expr, selectSections); + + Expect(113); + Expect(197); + } else if (la.kind == 171) { + +#line 3315 "VBNET.ATG" + OnErrorStatement onErrorStatement = null; + OnErrorStatement( +#line 3316 "VBNET.ATG" +out onErrorStatement); + +#line 3316 "VBNET.ATG" + statement = onErrorStatement; + } else if (la.kind == 132) { + +#line 3317 "VBNET.ATG" + GotoStatement goToStatement = null; + GotoStatement( +#line 3318 "VBNET.ATG" +out goToStatement); + +#line 3318 "VBNET.ATG" + statement = goToStatement; + } else if (la.kind == 194) { + +#line 3319 "VBNET.ATG" + ResumeStatement resumeStatement = null; + ResumeStatement( +#line 3320 "VBNET.ATG" +out resumeStatement); + +#line 3320 "VBNET.ATG" + statement = resumeStatement; + } else if (StartOf(44)) { + +#line 3323 "VBNET.ATG" + Expression val = null; + AssignmentOperatorType op; + Location startLoc = la.Location; + + bool mustBeAssignment = la.kind == Tokens.Plus || la.kind == Tokens.Minus || + la.kind == Tokens.Not || la.kind == Tokens.Times; + + SimpleExpr( +#line 3330 "VBNET.ATG" +out expr); + if (StartOf(46)) { + AssignmentOperator( +#line 3332 "VBNET.ATG" +out op); + Expr( +#line 3332 "VBNET.ATG" +out val); + +#line 3334 "VBNET.ATG" + expr = new AssignmentExpression(expr, op, val); + expr.StartLocation = startLoc; + expr.EndLocation = t.EndLocation; + + } else if (StartOf(47)) { + +#line 3338 "VBNET.ATG" + if (mustBeAssignment) Error("error in assignment."); + } else SynErr(302); + +#line 3341 "VBNET.ATG" + // a field reference expression that stands alone is a + // invocation expression without parantheses and arguments + if(expr is MemberReferenceExpression || expr is IdentifierExpression) { + Location endLocation = expr.EndLocation; + expr = new InvocationExpression(expr); + expr.StartLocation = startLoc; + expr.EndLocation = endLocation; + } + statement = new ExpressionStatement(expr); + + } else if (la.kind == 73) { + lexer.NextToken(); + SimpleExpr( +#line 3351 "VBNET.ATG" +out expr); + +#line 3351 "VBNET.ATG" + statement = new ExpressionStatement(expr); + } else if (la.kind == 226) { + lexer.NextToken(); + +#line 3353 "VBNET.ATG" + Statement block; + if ( +#line 3354 "VBNET.ATG" +Peek(1).kind == Tokens.As) { + +#line 3355 "VBNET.ATG" + LocalVariableDeclaration resourceAquisition = new LocalVariableDeclaration(Modifiers.None); + VariableDeclarator( +#line 3356 "VBNET.ATG" +resourceAquisition.Variables); + while (la.kind == 22) { + lexer.NextToken(); + VariableDeclarator( +#line 3358 "VBNET.ATG" +resourceAquisition.Variables); + } + Block( +#line 3360 "VBNET.ATG" +out block); + +#line 3362 "VBNET.ATG" + statement = new UsingStatement(resourceAquisition, block); + + } else if (StartOf(24)) { + Expr( +#line 3364 "VBNET.ATG" +out expr); + Block( +#line 3365 "VBNET.ATG" +out block); + +#line 3366 "VBNET.ATG" + statement = new UsingStatement(new ExpressionStatement(expr), block); + } else SynErr(303); + Expect(113); + Expect(226); + } else if (StartOf(48)) { + LocalDeclarationStatement( +#line 3369 "VBNET.ATG" +out statement); + } else SynErr(304); + +#line 3372 "VBNET.ATG" + if (statement != null) { + statement.StartLocation = startLocation; + statement.EndLocation = t.EndLocation; + } + + } + + void FromOrAggregateQueryOperator( +#line 2309 "VBNET.ATG" +List middleClauses) { + +#line 2311 "VBNET.ATG" + QueryExpressionFromClause fromClause = null; + QueryExpressionAggregateClause aggregateClause = null; + + if (la.kind == 126) { + FromQueryOperator( +#line 2314 "VBNET.ATG" +out fromClause); + +#line 2315 "VBNET.ATG" + middleClauses.Add(fromClause); + } else if (la.kind == 58) { + AggregateQueryOperator( +#line 2316 "VBNET.ATG" +out aggregateClause); + +#line 2317 "VBNET.ATG" + middleClauses.Add(aggregateClause); + } else SynErr(305); + } + + void QueryOperator( +#line 2320 "VBNET.ATG" +List middleClauses) { + +#line 2322 "VBNET.ATG" + QueryExpressionJoinVBClause joinClause = null; + QueryExpressionGroupVBClause groupByClause = null; + QueryExpressionPartitionVBClause partitionClause = null; + QueryExpressionGroupJoinVBClause groupJoinClause = null; + QueryExpressionFromClause fromClause = null; + QueryExpressionAggregateClause aggregateClause = null; + + if (la.kind == 126) { + FromQueryOperator( +#line 2329 "VBNET.ATG" +out fromClause); + +#line 2330 "VBNET.ATG" + middleClauses.Add(fromClause); + } else if (la.kind == 58) { + AggregateQueryOperator( +#line 2331 "VBNET.ATG" +out aggregateClause); + +#line 2332 "VBNET.ATG" + middleClauses.Add(aggregateClause); + } else if (la.kind == 197) { + SelectQueryOperator( +#line 2333 "VBNET.ATG" +middleClauses); + } else if (la.kind == 107) { + DistinctQueryOperator( +#line 2334 "VBNET.ATG" +middleClauses); + } else if (la.kind == 230) { + WhereQueryOperator( +#line 2335 "VBNET.ATG" +middleClauses); + } else if (la.kind == 176) { + OrderByQueryOperator( +#line 2336 "VBNET.ATG" +middleClauses); + } else if (la.kind == 203 || la.kind == 212) { + PartitionQueryOperator( +#line 2337 "VBNET.ATG" +out partitionClause); + +#line 2338 "VBNET.ATG" + middleClauses.Add(partitionClause); + } else if (la.kind == 148) { + LetQueryOperator( +#line 2339 "VBNET.ATG" +middleClauses); + } else if (la.kind == 146) { + JoinQueryOperator( +#line 2340 "VBNET.ATG" +out joinClause); + +#line 2341 "VBNET.ATG" + middleClauses.Add(joinClause); + } else if ( +#line 2342 "VBNET.ATG" +la.kind == Tokens.Group && Peek(1).kind == Tokens.Join) { + GroupJoinQueryOperator( +#line 2342 "VBNET.ATG" +out groupJoinClause); + +#line 2343 "VBNET.ATG" + middleClauses.Add(groupJoinClause); + } else if (la.kind == 133) { + GroupByQueryOperator( +#line 2344 "VBNET.ATG" +out groupByClause); + +#line 2345 "VBNET.ATG" + middleClauses.Add(groupByClause); + } else SynErr(306); + } + + void FromQueryOperator( +#line 2420 "VBNET.ATG" +out QueryExpressionFromClause fromClause) { + +#line 2422 "VBNET.ATG" + fromClause = new QueryExpressionFromClause(); + fromClause.StartLocation = la.Location; + + Expect(126); + CollectionRangeVariableDeclarationList( +#line 2425 "VBNET.ATG" +fromClause.Sources); + +#line 2427 "VBNET.ATG" + fromClause.EndLocation = t.EndLocation; + + } + + void AggregateQueryOperator( +#line 2489 "VBNET.ATG" +out QueryExpressionAggregateClause aggregateClause) { + +#line 2491 "VBNET.ATG" + aggregateClause = new QueryExpressionAggregateClause(); + aggregateClause.IntoVariables = new List(); + aggregateClause.StartLocation = la.Location; + CollectionRangeVariable source; + + Expect(58); + CollectionRangeVariableDeclaration( +#line 2496 "VBNET.ATG" +out source); + +#line 2498 "VBNET.ATG" + aggregateClause.Source = source; + + while (StartOf(31)) { + QueryOperator( +#line 2501 "VBNET.ATG" +aggregateClause.MiddleClauses); + } + Expect(143); + ExpressionRangeVariableDeclarationList( +#line 2503 "VBNET.ATG" +aggregateClause.IntoVariables); + +#line 2505 "VBNET.ATG" + aggregateClause.EndLocation = t.EndLocation; + + } + + void SelectQueryOperator( +#line 2431 "VBNET.ATG" +List middleClauses) { + +#line 2433 "VBNET.ATG" + QueryExpressionSelectVBClause selectClause = new QueryExpressionSelectVBClause(); + selectClause.StartLocation = la.Location; + + Expect(197); + ExpressionRangeVariableDeclarationList( +#line 2436 "VBNET.ATG" +selectClause.Variables); + +#line 2438 "VBNET.ATG" + selectClause.EndLocation = t.Location; + middleClauses.Add(selectClause); + + } + + void DistinctQueryOperator( +#line 2443 "VBNET.ATG" +List middleClauses) { + +#line 2445 "VBNET.ATG" + QueryExpressionDistinctClause distinctClause = new QueryExpressionDistinctClause(); + distinctClause.StartLocation = la.Location; + + Expect(107); + +#line 2450 "VBNET.ATG" + distinctClause.EndLocation = t.EndLocation; + middleClauses.Add(distinctClause); + + } + + void WhereQueryOperator( +#line 2455 "VBNET.ATG" +List middleClauses) { + +#line 2457 "VBNET.ATG" + QueryExpressionWhereClause whereClause = new QueryExpressionWhereClause(); + whereClause.StartLocation = la.Location; + Expression operand = null; + + Expect(230); + Expr( +#line 2461 "VBNET.ATG" +out operand); + +#line 2463 "VBNET.ATG" + whereClause.Condition = operand; + whereClause.EndLocation = t.EndLocation; + + middleClauses.Add(whereClause); + + } + + void OrderByQueryOperator( +#line 2348 "VBNET.ATG" +List middleClauses) { + +#line 2350 "VBNET.ATG" + QueryExpressionOrderClause orderClause = new QueryExpressionOrderClause(); + orderClause.StartLocation = la.Location; + List orderings = null; + + Expect(176); + Expect(70); + OrderExpressionList( +#line 2354 "VBNET.ATG" +out orderings); + +#line 2356 "VBNET.ATG" + orderClause.Orderings = orderings; + orderClause.EndLocation = t.EndLocation; + middleClauses.Add(orderClause); + + } + + void PartitionQueryOperator( +#line 2470 "VBNET.ATG" +out QueryExpressionPartitionVBClause partitionClause) { + +#line 2472 "VBNET.ATG" + partitionClause = new QueryExpressionPartitionVBClause(); + partitionClause.StartLocation = la.Location; + Expression expr = null; + + if (la.kind == 212) { + lexer.NextToken(); + +#line 2477 "VBNET.ATG" + partitionClause.PartitionType = QueryExpressionPartitionType.Take; + if (la.kind == 231) { + lexer.NextToken(); + +#line 2478 "VBNET.ATG" + partitionClause.PartitionType = QueryExpressionPartitionType.TakeWhile; + } + } else if (la.kind == 203) { + lexer.NextToken(); + +#line 2479 "VBNET.ATG" + partitionClause.PartitionType = QueryExpressionPartitionType.Skip; + if (la.kind == 231) { + lexer.NextToken(); + +#line 2480 "VBNET.ATG" + partitionClause.PartitionType = QueryExpressionPartitionType.SkipWhile; + } + } else SynErr(307); + Expr( +#line 2482 "VBNET.ATG" +out expr); + +#line 2484 "VBNET.ATG" + partitionClause.Expression = expr; + partitionClause.EndLocation = t.EndLocation; + + } + + void LetQueryOperator( +#line 2509 "VBNET.ATG" +List middleClauses) { + +#line 2511 "VBNET.ATG" + QueryExpressionLetVBClause letClause = new QueryExpressionLetVBClause(); + letClause.StartLocation = la.Location; + + Expect(148); + ExpressionRangeVariableDeclarationList( +#line 2514 "VBNET.ATG" +letClause.Variables); + +#line 2516 "VBNET.ATG" + letClause.EndLocation = t.EndLocation; + middleClauses.Add(letClause); + + } + + void JoinQueryOperator( +#line 2553 "VBNET.ATG" +out QueryExpressionJoinVBClause joinClause) { + +#line 2555 "VBNET.ATG" + joinClause = new QueryExpressionJoinVBClause(); + joinClause.StartLocation = la.Location; + CollectionRangeVariable joinVariable = null; + QueryExpressionJoinVBClause subJoin = null; + QueryExpressionJoinConditionVB condition = null; + + + Expect(146); + CollectionRangeVariableDeclaration( +#line 2562 "VBNET.ATG" +out joinVariable); + +#line 2563 "VBNET.ATG" + joinClause.JoinVariable = joinVariable; + if (la.kind == 146) { + JoinQueryOperator( +#line 2565 "VBNET.ATG" +out subJoin); + +#line 2566 "VBNET.ATG" + joinClause.SubJoin = subJoin; + } + Expect(171); + JoinCondition( +#line 2569 "VBNET.ATG" +out condition); + +#line 2570 "VBNET.ATG" + SafeAdd(joinClause, joinClause.Conditions, condition); + while (la.kind == 60) { + lexer.NextToken(); + JoinCondition( +#line 2572 "VBNET.ATG" +out condition); + +#line 2573 "VBNET.ATG" + SafeAdd(joinClause, joinClause.Conditions, condition); + } + +#line 2576 "VBNET.ATG" + joinClause.EndLocation = t.EndLocation; + + } + + void GroupJoinQueryOperator( +#line 2406 "VBNET.ATG" +out QueryExpressionGroupJoinVBClause groupJoinClause) { + +#line 2408 "VBNET.ATG" + groupJoinClause = new QueryExpressionGroupJoinVBClause(); + groupJoinClause.StartLocation = la.Location; + QueryExpressionJoinVBClause joinClause = null; + + Expect(133); + JoinQueryOperator( +#line 2412 "VBNET.ATG" +out joinClause); + Expect(143); + ExpressionRangeVariableDeclarationList( +#line 2413 "VBNET.ATG" +groupJoinClause.IntoVariables); + +#line 2415 "VBNET.ATG" + groupJoinClause.JoinClause = joinClause; + groupJoinClause.EndLocation = t.EndLocation; + + } + + void GroupByQueryOperator( +#line 2393 "VBNET.ATG" +out QueryExpressionGroupVBClause groupByClause) { + +#line 2395 "VBNET.ATG" + groupByClause = new QueryExpressionGroupVBClause(); + groupByClause.StartLocation = la.Location; + + Expect(133); + ExpressionRangeVariableDeclarationList( +#line 2398 "VBNET.ATG" +groupByClause.GroupVariables); + Expect(70); + ExpressionRangeVariableDeclarationList( +#line 2399 "VBNET.ATG" +groupByClause.ByVariables); + Expect(143); + ExpressionRangeVariableDeclarationList( +#line 2400 "VBNET.ATG" +groupByClause.IntoVariables); + +#line 2402 "VBNET.ATG" + groupByClause.EndLocation = t.EndLocation; + + } + + void OrderExpressionList( +#line 2362 "VBNET.ATG" +out List orderings) { + +#line 2364 "VBNET.ATG" + orderings = new List(); + QueryExpressionOrdering ordering = null; + + OrderExpression( +#line 2367 "VBNET.ATG" +out ordering); + +#line 2368 "VBNET.ATG" + orderings.Add(ordering); + while (la.kind == 22) { + lexer.NextToken(); + OrderExpression( +#line 2370 "VBNET.ATG" +out ordering); + +#line 2371 "VBNET.ATG" + orderings.Add(ordering); + } + } + + void OrderExpression( +#line 2375 "VBNET.ATG" +out QueryExpressionOrdering ordering) { + +#line 2377 "VBNET.ATG" + ordering = new QueryExpressionOrdering(); + ordering.StartLocation = la.Location; + ordering.Direction = QueryExpressionOrderingDirection.None; + Expression orderExpr = null; + + Expr( +#line 2382 "VBNET.ATG" +out orderExpr); + +#line 2384 "VBNET.ATG" + ordering.Criteria = orderExpr; + + if (la.kind == 64 || la.kind == 104) { + if (la.kind == 64) { + lexer.NextToken(); + +#line 2387 "VBNET.ATG" + ordering.Direction = QueryExpressionOrderingDirection.Ascending; + } else { + lexer.NextToken(); + +#line 2388 "VBNET.ATG" + ordering.Direction = QueryExpressionOrderingDirection.Descending; + } + } + +#line 2390 "VBNET.ATG" + ordering.EndLocation = t.EndLocation; + } + + void ExpressionRangeVariableDeclarationList( +#line 2521 "VBNET.ATG" +List variables) { + +#line 2523 "VBNET.ATG" + ExpressionRangeVariable variable = null; + + ExpressionRangeVariableDeclaration( +#line 2525 "VBNET.ATG" +out variable); + +#line 2526 "VBNET.ATG" + variables.Add(variable); + while (la.kind == 22) { + lexer.NextToken(); + ExpressionRangeVariableDeclaration( +#line 2527 "VBNET.ATG" +out variable); + +#line 2527 "VBNET.ATG" + variables.Add(variable); + } + } + + void CollectionRangeVariableDeclarationList( +#line 2580 "VBNET.ATG" +List rangeVariables) { + +#line 2581 "VBNET.ATG" + CollectionRangeVariable variableDeclaration; + CollectionRangeVariableDeclaration( +#line 2583 "VBNET.ATG" +out variableDeclaration); + +#line 2584 "VBNET.ATG" + rangeVariables.Add(variableDeclaration); + while (la.kind == 22) { + lexer.NextToken(); + CollectionRangeVariableDeclaration( +#line 2585 "VBNET.ATG" +out variableDeclaration); + +#line 2585 "VBNET.ATG" + rangeVariables.Add(variableDeclaration); + } + } + + void CollectionRangeVariableDeclaration( +#line 2588 "VBNET.ATG" +out CollectionRangeVariable rangeVariable) { + +#line 2590 "VBNET.ATG" + rangeVariable = new CollectionRangeVariable(); + rangeVariable.StartLocation = la.Location; + TypeReference typeName = null; + Expression inExpr = null; + + Identifier(); + +#line 2595 "VBNET.ATG" + rangeVariable.Identifier = t.val; + if (la.kind == 63) { + lexer.NextToken(); + TypeName( +#line 2596 "VBNET.ATG" +out typeName); + +#line 2596 "VBNET.ATG" + rangeVariable.Type = typeName; + } + Expect(138); + Expr( +#line 2597 "VBNET.ATG" +out inExpr); + +#line 2599 "VBNET.ATG" + rangeVariable.Expression = inExpr; + rangeVariable.EndLocation = t.EndLocation; + + } + + void ExpressionRangeVariableDeclaration( +#line 2530 "VBNET.ATG" +out ExpressionRangeVariable variable) { + +#line 2532 "VBNET.ATG" + variable = new ExpressionRangeVariable(); + variable.StartLocation = la.Location; + Expression rhs = null; + TypeReference typeName = null; + + if ( +#line 2538 "VBNET.ATG" +IsIdentifiedExpressionRange()) { + Identifier(); + +#line 2539 "VBNET.ATG" + variable.Identifier = t.val; + if (la.kind == 63) { + lexer.NextToken(); + TypeName( +#line 2541 "VBNET.ATG" +out typeName); + +#line 2542 "VBNET.ATG" + variable.Type = typeName; + } + Expect(20); + } + Expr( +#line 2546 "VBNET.ATG" +out rhs); + +#line 2548 "VBNET.ATG" + variable.Expression = rhs; + variable.EndLocation = t.EndLocation; + + } + + void JoinCondition( +#line 2604 "VBNET.ATG" +out QueryExpressionJoinConditionVB condition) { + +#line 2606 "VBNET.ATG" + condition = new QueryExpressionJoinConditionVB(); + condition.StartLocation = la.Location; + + Expression lhs = null; + Expression rhs = null; + + Expr( +#line 2612 "VBNET.ATG" +out lhs); + Expect(116); + Expr( +#line 2612 "VBNET.ATG" +out rhs); + +#line 2614 "VBNET.ATG" + condition.LeftSide = lhs; + condition.RightSide = rhs; + condition.EndLocation = t.EndLocation; + + } + + void Argument( +#line 2678 "VBNET.ATG" +out Expression argumentexpr) { + +#line 2680 "VBNET.ATG" + Expression expr; + argumentexpr = null; + string name; + Location startLocation = la.Location; + + if ( +#line 2685 "VBNET.ATG" +IsNamedAssign()) { + Identifier(); + +#line 2685 "VBNET.ATG" + name = t.val; + Expect(55); + Expr( +#line 2685 "VBNET.ATG" +out expr); + +#line 2687 "VBNET.ATG" + argumentexpr = new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; + + } else if (StartOf(24)) { + Expr( +#line 2690 "VBNET.ATG" +out argumentexpr); + } else SynErr(308); + } + + void QualIdentAndTypeArguments( +#line 2758 "VBNET.ATG" +out TypeReference typeref, bool canBeUnbound) { + +#line 2759 "VBNET.ATG" + string name; typeref = null; + Qualident( +#line 2761 "VBNET.ATG" +out name); + +#line 2762 "VBNET.ATG" + typeref = new TypeReference(name); + if ( +#line 2763 "VBNET.ATG" +la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { + lexer.NextToken(); + Expect(169); + if ( +#line 2765 "VBNET.ATG" +canBeUnbound && (la.kind == Tokens.CloseParenthesis || la.kind == Tokens.Comma)) { + +#line 2766 "VBNET.ATG" + typeref.GenericTypes.Add(NullTypeReference.Instance); + while (la.kind == 22) { + lexer.NextToken(); + +#line 2767 "VBNET.ATG" + typeref.GenericTypes.Add(NullTypeReference.Instance); + } + } else if (StartOf(8)) { + TypeArgumentList( +#line 2768 "VBNET.ATG" +typeref.GenericTypes); + } else SynErr(309); + Expect(38); + } + } + + void RankList( +#line 2805 "VBNET.ATG" +out int i) { + +#line 2806 "VBNET.ATG" + i = 0; + while (la.kind == 22) { + lexer.NextToken(); + +#line 2807 "VBNET.ATG" + ++i; + } + } + + void Attribute( +#line 2846 "VBNET.ATG" +out ASTAttribute attribute) { + +#line 2848 "VBNET.ATG" + string name; + List positional = new List(); + List named = new List(); + Location startLocation = la.Location; + + if (la.kind == 130) { + lexer.NextToken(); + Expect(26); + } + Qualident( +#line 2854 "VBNET.ATG" +out name); + if (la.kind == 37) { + AttributeArguments( +#line 2855 "VBNET.ATG" +positional, named); + } + +#line 2857 "VBNET.ATG" + attribute = new ASTAttribute(name, positional, named) { StartLocation = startLocation, EndLocation = t.EndLocation }; + + } + + void AttributeArguments( +#line 2862 "VBNET.ATG" +List positional, List named) { + +#line 2864 "VBNET.ATG" + bool nameFound = false; + string name = ""; + Expression expr; + + Expect(37); + if ( +#line 2870 "VBNET.ATG" +IsNotClosingParenthesis()) { + +#line 2871 "VBNET.ATG" + Location startLocation = la.Location; + if ( +#line 2873 "VBNET.ATG" +IsNamedAssign()) { + +#line 2873 "VBNET.ATG" + nameFound = true; + IdentifierOrKeyword( +#line 2874 "VBNET.ATG" +out name); + if (la.kind == 55) { + lexer.NextToken(); + } else if (la.kind == 20) { + lexer.NextToken(); + } else SynErr(310); + } + Expr( +#line 2876 "VBNET.ATG" +out expr); + +#line 2878 "VBNET.ATG" + if (expr != null) { + if (string.IsNullOrEmpty(name)) { positional.Add(expr); } + else { named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }); name = ""; } + } + + while (la.kind == 22) { + lexer.NextToken(); + if ( +#line 2886 "VBNET.ATG" +IsNamedAssign()) { + +#line 2886 "VBNET.ATG" + nameFound = true; + IdentifierOrKeyword( +#line 2887 "VBNET.ATG" +out name); + if (la.kind == 55) { + lexer.NextToken(); + } else if (la.kind == 20) { + lexer.NextToken(); + } else SynErr(311); + } else if (StartOf(24)) { + +#line 2889 "VBNET.ATG" + if (nameFound) Error("no positional argument after named argument"); + } else SynErr(312); + Expr( +#line 2890 "VBNET.ATG" +out expr); + +#line 2890 "VBNET.ATG" + if (expr != null) { if(name == "") positional.Add(expr); + else { named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }); name = ""; } + } + + } + } + Expect(38); + } + + void ParameterModifier( +#line 3701 "VBNET.ATG" +ParamModifierList m) { + if (la.kind == 72) { + lexer.NextToken(); + +#line 3702 "VBNET.ATG" + m.Add(ParameterModifiers.In); + } else if (la.kind == 69) { + lexer.NextToken(); + +#line 3703 "VBNET.ATG" + m.Add(ParameterModifiers.Ref); + } else if (la.kind == 174) { + lexer.NextToken(); + +#line 3704 "VBNET.ATG" + m.Add(ParameterModifiers.Optional); + } else if (la.kind == 182) { + lexer.NextToken(); + +#line 3705 "VBNET.ATG" + m.Add(ParameterModifiers.Params); + } else SynErr(313); + } + + void Statement() { + +#line 3017 "VBNET.ATG" + Statement stmt = null; + Location startPos = la.Location; + string label = String.Empty; + + + if (la.kind == 1 || la.kind == 21) { + } else if ( +#line 3023 "VBNET.ATG" +IsLabel()) { + LabelName( +#line 3023 "VBNET.ATG" +out label); + +#line 3025 "VBNET.ATG" + AddChild(new LabelStatement(t.val)); + + Expect(21); + Statement(); + } else if (StartOf(49)) { + EmbeddedStatement( +#line 3028 "VBNET.ATG" +out stmt); + +#line 3028 "VBNET.ATG" + AddChild(stmt); + } else SynErr(314); + +#line 3031 "VBNET.ATG" + if (stmt != null) { + stmt.StartLocation = startPos; + stmt.EndLocation = t.Location; + } + + } + + void LabelName( +#line 3471 "VBNET.ATG" +out string name) { + +#line 3473 "VBNET.ATG" + name = String.Empty; + + if (StartOf(4)) { + Identifier(); + +#line 3475 "VBNET.ATG" + name = t.val; + } else if (la.kind == 5) { + lexer.NextToken(); + +#line 3476 "VBNET.ATG" + name = t.val; + } else SynErr(315); + } + + void LocalDeclarationStatement( +#line 3039 "VBNET.ATG" +out Statement statement) { + +#line 3041 "VBNET.ATG" + ModifierList m = new ModifierList(); + LocalVariableDeclaration localVariableDeclaration; + bool dimfound = false; + + while (la.kind == 88 || la.kind == 105 || la.kind == 204) { + if (la.kind == 88) { + lexer.NextToken(); + +#line 3047 "VBNET.ATG" + m.Add(Modifiers.Const, t.Location); + } else if (la.kind == 204) { + lexer.NextToken(); + +#line 3048 "VBNET.ATG" + m.Add(Modifiers.Static, t.Location); + } else { + lexer.NextToken(); + +#line 3049 "VBNET.ATG" + dimfound = true; + } + } + +#line 3052 "VBNET.ATG" + if(dimfound && (m.Modifier & Modifiers.Const) != 0) { + Error("Dim is not allowed on constants."); + } + + if(m.isNone && dimfound == false) { + Error("Const, Dim or Static expected"); + } + + localVariableDeclaration = new LocalVariableDeclaration(m.Modifier); + localVariableDeclaration.StartLocation = t.Location; + + VariableDeclarator( +#line 3063 "VBNET.ATG" +localVariableDeclaration.Variables); + while (la.kind == 22) { + lexer.NextToken(); + VariableDeclarator( +#line 3064 "VBNET.ATG" +localVariableDeclaration.Variables); + } + +#line 3066 "VBNET.ATG" + statement = localVariableDeclaration; + + } + + void TryStatement( +#line 3589 "VBNET.ATG" +out Statement tryStatement) { + +#line 3591 "VBNET.ATG" + Statement blockStmt = null, finallyStmt = null;List catchClauses = null; + + Expect(218); + EndOfStmt(); + Block( +#line 3594 "VBNET.ATG" +out blockStmt); + if (la.kind == 75 || la.kind == 113 || la.kind == 123) { + CatchClauses( +#line 3595 "VBNET.ATG" +out catchClauses); + } + if (la.kind == 123) { + lexer.NextToken(); + EndOfStmt(); + Block( +#line 3596 "VBNET.ATG" +out finallyStmt); + } + Expect(113); + Expect(218); + +#line 3599 "VBNET.ATG" + tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); + + } + + void WithStatement( +#line 3569 "VBNET.ATG" +out Statement withStatement) { + +#line 3571 "VBNET.ATG" + Statement blockStmt = null; + Expression expr = null; + + Expect(233); + +#line 3574 "VBNET.ATG" + Location start = t.Location; + Expr( +#line 3575 "VBNET.ATG" +out expr); + EndOfStmt(); + +#line 3577 "VBNET.ATG" + withStatement = new WithStatement(expr); + withStatement.StartLocation = start; + + Block( +#line 3580 "VBNET.ATG" +out blockStmt); + +#line 3582 "VBNET.ATG" + ((WithStatement)withStatement).Body = (BlockStatement)blockStmt; + + Expect(113); + Expect(233); + +#line 3585 "VBNET.ATG" + withStatement.EndLocation = t.Location; + } + + void WhileOrUntil( +#line 3562 "VBNET.ATG" +out ConditionType conditionType) { + +#line 3563 "VBNET.ATG" + conditionType = ConditionType.None; + if (la.kind == 231) { + lexer.NextToken(); + +#line 3564 "VBNET.ATG" + conditionType = ConditionType.While; + } else if (la.kind == 224) { + lexer.NextToken(); + +#line 3565 "VBNET.ATG" + conditionType = ConditionType.Until; + } else SynErr(316); + } + + void LoopControlVariable( +#line 3393 "VBNET.ATG" +out TypeReference type, out string name) { + +#line 3394 "VBNET.ATG" + ArrayList arrayModifiers = null; + type = null; + + Qualident( +#line 3398 "VBNET.ATG" +out name); + if ( +#line 3399 "VBNET.ATG" +IsDims()) { + ArrayTypeModifiers( +#line 3399 "VBNET.ATG" +out arrayModifiers); + } + if (la.kind == 63) { + lexer.NextToken(); + TypeName( +#line 3400 "VBNET.ATG" +out type); + +#line 3400 "VBNET.ATG" + if (name.IndexOf('.') > 0) { Error("No type def for 'for each' member indexer allowed."); } + } + +#line 3402 "VBNET.ATG" + if (type != null) { + if(type.RankSpecifier != null && arrayModifiers != null) { + Error("array rank only allowed one time"); + } else if (arrayModifiers != null) { + type.RankSpecifier = (int[])arrayModifiers.ToArray(typeof(int)); + } + } + + } + + void ReDimClause( +#line 3480 "VBNET.ATG" +out Expression expr) { + SimpleNonInvocationExpression( +#line 3482 "VBNET.ATG" +out expr); + ReDimClauseInternal( +#line 3483 "VBNET.ATG" +ref expr); + } + + void SingleLineStatementList( +#line 3379 "VBNET.ATG" +List list) { + +#line 3380 "VBNET.ATG" + Statement embeddedStatement = null; + if (la.kind == 113) { + lexer.NextToken(); + +#line 3382 "VBNET.ATG" + embeddedStatement = new EndStatement() { StartLocation = t.Location, EndLocation = t.EndLocation }; + } else if (StartOf(49)) { + EmbeddedStatement( +#line 3383 "VBNET.ATG" +out embeddedStatement); + } else SynErr(317); + +#line 3384 "VBNET.ATG" + if (embeddedStatement != null) list.Add(embeddedStatement); + while (la.kind == 21) { + lexer.NextToken(); + while (la.kind == 21) { + lexer.NextToken(); + } + if (la.kind == 113) { + lexer.NextToken(); + +#line 3386 "VBNET.ATG" + embeddedStatement = new EndStatement() { StartLocation = t.Location, EndLocation = t.EndLocation }; + } else if (StartOf(49)) { + EmbeddedStatement( +#line 3387 "VBNET.ATG" +out embeddedStatement); + } else SynErr(318); + +#line 3388 "VBNET.ATG" + if (embeddedStatement != null) list.Add(embeddedStatement); + } + } + + void CaseClauses( +#line 3522 "VBNET.ATG" +out List caseClauses) { + +#line 3524 "VBNET.ATG" + caseClauses = new List(); + CaseLabel caseClause = null; + + CaseClause( +#line 3527 "VBNET.ATG" +out caseClause); + +#line 3527 "VBNET.ATG" + if (caseClause != null) { caseClauses.Add(caseClause); } + while (la.kind == 22) { + lexer.NextToken(); + CaseClause( +#line 3528 "VBNET.ATG" +out caseClause); + +#line 3528 "VBNET.ATG" + if (caseClause != null) { caseClauses.Add(caseClause); } + } + } + + void OnErrorStatement( +#line 3413 "VBNET.ATG" +out OnErrorStatement stmt) { + +#line 3415 "VBNET.ATG" + stmt = null; + Location startLocation = la.Location; + GotoStatement goToStatement = null; + + Expect(171); + Expect(118); + if ( +#line 3422 "VBNET.ATG" +IsNegativeLabelName()) { + Expect(132); + Expect(30); + Expect(5); + +#line 3424 "VBNET.ATG" + long intLabel = Int64.Parse(t.val); + if(intLabel != 1) { + Error("invalid label in on error statement."); + } + stmt = new OnErrorStatement(new GotoStatement((intLabel * -1).ToString())); + + } else if (la.kind == 132) { + GotoStatement( +#line 3430 "VBNET.ATG" +out goToStatement); + +#line 3432 "VBNET.ATG" + string val = goToStatement.Label; + + // if value is numeric, make sure that is 0 + try { + long intLabel = Int64.Parse(val); + if(intLabel != 0) { + Error("invalid label in on error statement."); + } + } catch { + } + stmt = new OnErrorStatement(goToStatement); + + } else if (la.kind == 194) { + lexer.NextToken(); + Expect(163); + +#line 3446 "VBNET.ATG" + stmt = new OnErrorStatement(new ResumeStatement(true)); + + } else SynErr(319); + +#line 3450 "VBNET.ATG" + if (stmt != null) { + stmt.StartLocation = startLocation; + stmt.EndLocation = t.EndLocation; + } + + } + + void GotoStatement( +#line 3458 "VBNET.ATG" +out GotoStatement goToStatement) { + +#line 3459 "VBNET.ATG" + string label = String.Empty; Location startLocation = la.Location; + Expect(132); + LabelName( +#line 3461 "VBNET.ATG" +out label); + +#line 3463 "VBNET.ATG" + goToStatement = new GotoStatement(label) { + StartLocation = startLocation, + EndLocation = t.EndLocation + }; + + } + + void ResumeStatement( +#line 3511 "VBNET.ATG" +out ResumeStatement resumeStatement) { + +#line 3513 "VBNET.ATG" + resumeStatement = null; + string label = String.Empty; + + if ( +#line 3516 "VBNET.ATG" +IsResumeNext()) { + Expect(194); + Expect(163); + +#line 3517 "VBNET.ATG" + resumeStatement = new ResumeStatement(true); + } else if (la.kind == 194) { + lexer.NextToken(); + if (StartOf(50)) { + LabelName( +#line 3518 "VBNET.ATG" +out label); + } + +#line 3518 "VBNET.ATG" + resumeStatement = new ResumeStatement(label); + } else SynErr(320); + } + + void ReDimClauseInternal( +#line 3486 "VBNET.ATG" +ref Expression expr) { + +#line 3487 "VBNET.ATG" + List arguments; bool canBeNormal; bool canBeRedim; string name; Location startLocation = la.Location; + while (la.kind == 26 || +#line 3490 "VBNET.ATG" +la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { + if (la.kind == 26) { + lexer.NextToken(); + IdentifierOrKeyword( +#line 3489 "VBNET.ATG" +out name); + +#line 3489 "VBNET.ATG" + expr = new MemberReferenceExpression(expr, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; + } else { + InvocationExpression( +#line 3491 "VBNET.ATG" +ref expr); + +#line 3493 "VBNET.ATG" + expr.StartLocation = startLocation; + expr.EndLocation = t.EndLocation; + + } + } + Expect(37); + NormalOrReDimArgumentList( +#line 3498 "VBNET.ATG" +out arguments, out canBeNormal, out canBeRedim); + Expect(38); + +#line 3500 "VBNET.ATG" + expr = new InvocationExpression(expr, arguments); + if (canBeRedim == false || canBeNormal && (la.kind == Tokens.Dot || la.kind == Tokens.OpenParenthesis)) { + if (this.Errors.Count == 0) { + // don't recurse on parse errors - could result in endless recursion + ReDimClauseInternal(ref expr); + } + } + + } + + void CaseClause( +#line 3532 "VBNET.ATG" +out CaseLabel caseClause) { + +#line 3534 "VBNET.ATG" + Expression expr = null; + Expression sexpr = null; + BinaryOperatorType op = BinaryOperatorType.None; + caseClause = null; + + if (la.kind == 111) { + lexer.NextToken(); + +#line 3540 "VBNET.ATG" + caseClause = new CaseLabel(); + } else if (StartOf(51)) { + if (la.kind == 144) { + lexer.NextToken(); + } + switch (la.kind) { + case 40: { + lexer.NextToken(); + +#line 3544 "VBNET.ATG" + op = BinaryOperatorType.LessThan; + break; + } + case 39: { + lexer.NextToken(); + +#line 3545 "VBNET.ATG" + op = BinaryOperatorType.GreaterThan; + break; + } + case 43: { + lexer.NextToken(); + +#line 3546 "VBNET.ATG" + op = BinaryOperatorType.LessThanOrEqual; + break; + } + case 42: { + lexer.NextToken(); + +#line 3547 "VBNET.ATG" + op = BinaryOperatorType.GreaterThanOrEqual; + break; + } + case 20: { + lexer.NextToken(); + +#line 3548 "VBNET.ATG" + op = BinaryOperatorType.Equality; + break; + } + case 41: { + lexer.NextToken(); + +#line 3549 "VBNET.ATG" + op = BinaryOperatorType.InEquality; + break; + } + default: SynErr(321); break; + } + Expr( +#line 3551 "VBNET.ATG" +out expr); + +#line 3553 "VBNET.ATG" + caseClause = new CaseLabel(op, expr); + + } else if (StartOf(24)) { + Expr( +#line 3555 "VBNET.ATG" +out expr); + if (la.kind == 216) { + lexer.NextToken(); + Expr( +#line 3555 "VBNET.ATG" +out sexpr); + } + +#line 3557 "VBNET.ATG" + caseClause = new CaseLabel(expr, sexpr); + + } else SynErr(322); + } + + void CatchClauses( +#line 3604 "VBNET.ATG" +out List catchClauses) { + +#line 3606 "VBNET.ATG" + catchClauses = new List(); + TypeReference type = null; + Statement blockStmt = null; + Expression expr = null; + string name = String.Empty; + + while (la.kind == 75) { + lexer.NextToken(); + if (StartOf(4)) { + Identifier(); + +#line 3614 "VBNET.ATG" + name = t.val; + if (la.kind == 63) { + lexer.NextToken(); + TypeName( +#line 3614 "VBNET.ATG" +out type); + } + } + if (la.kind == 229) { + lexer.NextToken(); + Expr( +#line 3615 "VBNET.ATG" +out expr); + } + EndOfStmt(); + Block( +#line 3617 "VBNET.ATG" +out blockStmt); + +#line 3618 "VBNET.ATG" + catchClauses.Add(new CatchClause(type, name, blockStmt, expr)); + } + } + + + + void ParseRoot() + { + VBNET(); + + } + + protected override void SynErr(int line, int col, int errorNumber) + { + string s; + switch (errorNumber) { + case 0: s = "EOF expected"; break; + case 1: s = "EOL expected"; break; + case 2: s = "ident expected"; break; + case 3: s = "LiteralString expected"; break; + case 4: s = "LiteralCharacter expected"; break; + case 5: s = "LiteralInteger expected"; break; + case 6: s = "LiteralDouble expected"; break; + case 7: s = "LiteralSingle expected"; break; + case 8: s = "LiteralDecimal expected"; break; + case 9: s = "LiteralDate expected"; break; + case 10: s = "XmlOpenTag expected"; break; + case 11: s = "XmlCloseTag expected"; break; + case 12: s = "XmlStartInlineVB expected"; break; + case 13: s = "XmlEndInlineVB expected"; break; + case 14: s = "XmlCloseTagEmptyElement expected"; break; + case 15: s = "XmlOpenEndTag expected"; break; + case 16: s = "XmlContent expected"; break; + case 17: s = "XmlComment expected"; break; + case 18: s = "XmlCData expected"; break; + case 19: s = "XmlProcessingInstruction expected"; break; + case 20: s = "\"=\" expected"; break; + case 21: s = "\":\" expected"; break; + case 22: s = "\",\" expected"; break; + case 23: s = "\"&\" expected"; break; + case 24: s = "\"/\" expected"; break; + case 25: s = "\"\\\\\" expected"; break; + case 26: s = "\".\" expected"; break; + case 27: s = "\"...\" expected"; break; + case 28: s = "\".@\" expected"; break; + case 29: s = "\"!\" expected"; break; + case 30: s = "\"-\" expected"; break; + case 31: s = "\"+\" expected"; break; + case 32: s = "\"^\" expected"; break; + case 33: s = "\"?\" expected"; break; + case 34: s = "\"*\" expected"; break; + case 35: s = "\"{\" expected"; break; + case 36: s = "\"}\" expected"; break; + case 37: s = "\"(\" expected"; break; + case 38: s = "\")\" expected"; break; + case 39: s = "\">\" expected"; break; + case 40: s = "\"<\" expected"; break; + case 41: s = "\"<>\" expected"; break; + case 42: s = "\">=\" expected"; break; + case 43: s = "\"<=\" expected"; break; + case 44: s = "\"<<\" expected"; break; + case 45: s = "\">>\" expected"; break; + case 46: s = "\"+=\" expected"; break; + case 47: s = "\"^=\" expected"; break; + case 48: s = "\"-=\" expected"; break; + case 49: s = "\"*=\" expected"; break; + case 50: s = "\"/=\" expected"; break; + case 51: s = "\"\\\\=\" expected"; break; + case 52: s = "\"<<=\" expected"; break; + case 53: s = "\">>=\" expected"; break; + case 54: s = "\"&=\" expected"; break; + case 55: s = "\":=\" expected"; break; + case 56: s = "\"AddHandler\" expected"; break; + case 57: s = "\"AddressOf\" expected"; break; + case 58: s = "\"Aggregate\" expected"; break; + case 59: s = "\"Alias\" expected"; break; + case 60: s = "\"And\" expected"; break; + case 61: s = "\"AndAlso\" expected"; break; + case 62: s = "\"Ansi\" expected"; break; + case 63: s = "\"As\" expected"; break; + case 64: s = "\"Ascending\" expected"; break; + case 65: s = "\"Assembly\" expected"; break; + case 66: s = "\"Auto\" expected"; break; + case 67: s = "\"Binary\" expected"; break; + case 68: s = "\"Boolean\" expected"; break; + case 69: s = "\"ByRef\" expected"; break; + case 70: s = "\"By\" expected"; break; + case 71: s = "\"Byte\" expected"; break; + case 72: s = "\"ByVal\" expected"; break; + case 73: s = "\"Call\" expected"; break; + case 74: s = "\"Case\" expected"; break; + case 75: s = "\"Catch\" expected"; break; + case 76: s = "\"CBool\" expected"; break; + case 77: s = "\"CByte\" expected"; break; + case 78: s = "\"CChar\" expected"; break; + case 79: s = "\"CDate\" expected"; break; + case 80: s = "\"CDbl\" expected"; break; + case 81: s = "\"CDec\" expected"; break; + case 82: s = "\"Char\" expected"; break; + case 83: s = "\"CInt\" expected"; break; + case 84: s = "\"Class\" expected"; break; + case 85: s = "\"CLng\" expected"; break; + case 86: s = "\"CObj\" expected"; break; + case 87: s = "\"Compare\" expected"; break; + case 88: s = "\"Const\" expected"; break; + case 89: s = "\"Continue\" expected"; break; + case 90: s = "\"CSByte\" expected"; break; + case 91: s = "\"CShort\" expected"; break; + case 92: s = "\"CSng\" expected"; break; + case 93: s = "\"CStr\" expected"; break; + case 94: s = "\"CType\" expected"; break; + case 95: s = "\"CUInt\" expected"; break; + case 96: s = "\"CULng\" expected"; break; + case 97: s = "\"CUShort\" expected"; break; + case 98: s = "\"Custom\" expected"; break; + case 99: s = "\"Date\" expected"; break; + case 100: s = "\"Decimal\" expected"; break; + case 101: s = "\"Declare\" expected"; break; + case 102: s = "\"Default\" expected"; break; + case 103: s = "\"Delegate\" expected"; break; + case 104: s = "\"Descending\" expected"; break; + case 105: s = "\"Dim\" expected"; break; + case 106: s = "\"DirectCast\" expected"; break; + case 107: s = "\"Distinct\" expected"; break; + case 108: s = "\"Do\" expected"; break; + case 109: s = "\"Double\" expected"; break; + case 110: s = "\"Each\" expected"; break; + case 111: s = "\"Else\" expected"; break; + case 112: s = "\"ElseIf\" expected"; break; + case 113: s = "\"End\" expected"; break; + case 114: s = "\"EndIf\" expected"; break; + case 115: s = "\"Enum\" expected"; break; + case 116: s = "\"Equals\" expected"; break; + case 117: s = "\"Erase\" expected"; break; + case 118: s = "\"Error\" expected"; break; + case 119: s = "\"Event\" expected"; break; + case 120: s = "\"Exit\" expected"; break; + case 121: s = "\"Explicit\" expected"; break; + case 122: s = "\"False\" expected"; break; + case 123: s = "\"Finally\" expected"; break; + case 124: s = "\"For\" expected"; break; + case 125: s = "\"Friend\" expected"; break; + case 126: s = "\"From\" expected"; break; + case 127: s = "\"Function\" expected"; break; + case 128: s = "\"Get\" expected"; break; + case 129: s = "\"GetType\" expected"; break; + case 130: s = "\"Global\" expected"; break; + case 131: s = "\"GoSub\" expected"; break; + case 132: s = "\"GoTo\" expected"; break; + case 133: s = "\"Group\" expected"; break; + case 134: s = "\"Handles\" expected"; break; + case 135: s = "\"If\" expected"; break; + case 136: s = "\"Implements\" expected"; break; + case 137: s = "\"Imports\" expected"; break; + case 138: s = "\"In\" expected"; break; + case 139: s = "\"Infer\" expected"; break; + case 140: s = "\"Inherits\" expected"; break; + case 141: s = "\"Integer\" expected"; break; + case 142: s = "\"Interface\" expected"; break; + case 143: s = "\"Into\" expected"; break; + case 144: s = "\"Is\" expected"; break; + case 145: s = "\"IsNot\" expected"; break; + case 146: s = "\"Join\" expected"; break; + case 147: s = "\"Key\" expected"; break; + case 148: s = "\"Let\" expected"; break; + case 149: s = "\"Lib\" expected"; break; + case 150: s = "\"Like\" expected"; break; + case 151: s = "\"Long\" expected"; break; + case 152: s = "\"Loop\" expected"; break; + case 153: s = "\"Me\" expected"; break; + case 154: s = "\"Mod\" expected"; break; + case 155: s = "\"Module\" expected"; break; + case 156: s = "\"MustInherit\" expected"; break; + case 157: s = "\"MustOverride\" expected"; break; + case 158: s = "\"MyBase\" expected"; break; + case 159: s = "\"MyClass\" expected"; break; + case 160: s = "\"Namespace\" expected"; break; + case 161: s = "\"Narrowing\" expected"; break; + case 162: s = "\"New\" expected"; break; + case 163: s = "\"Next\" expected"; break; + case 164: s = "\"Not\" expected"; break; + case 165: s = "\"Nothing\" expected"; break; + case 166: s = "\"NotInheritable\" expected"; break; + case 167: s = "\"NotOverridable\" expected"; break; + case 168: s = "\"Object\" expected"; break; + case 169: s = "\"Of\" expected"; break; + case 170: s = "\"Off\" expected"; break; + case 171: s = "\"On\" expected"; break; + case 172: s = "\"Operator\" expected"; break; + case 173: s = "\"Option\" expected"; break; + case 174: s = "\"Optional\" expected"; break; + case 175: s = "\"Or\" expected"; break; + case 176: s = "\"Order\" expected"; break; + case 177: s = "\"OrElse\" expected"; break; + case 178: s = "\"Out\" expected"; break; + case 179: s = "\"Overloads\" expected"; break; + case 180: s = "\"Overridable\" expected"; break; + case 181: s = "\"Overrides\" expected"; break; + case 182: s = "\"ParamArray\" expected"; break; + case 183: s = "\"Partial\" expected"; break; + case 184: s = "\"Preserve\" expected"; break; + case 185: s = "\"Private\" expected"; break; + case 186: s = "\"Property\" expected"; break; + case 187: s = "\"Protected\" expected"; break; + case 188: s = "\"Public\" expected"; break; + case 189: s = "\"RaiseEvent\" expected"; break; + case 190: s = "\"ReadOnly\" expected"; break; + case 191: s = "\"ReDim\" expected"; break; + case 192: s = "\"Rem\" expected"; break; + case 193: s = "\"RemoveHandler\" expected"; break; + case 194: s = "\"Resume\" expected"; break; + case 195: s = "\"Return\" expected"; break; + case 196: s = "\"SByte\" expected"; break; + case 197: s = "\"Select\" expected"; break; + case 198: s = "\"Set\" expected"; break; + case 199: s = "\"Shadows\" expected"; break; + case 200: s = "\"Shared\" expected"; break; + case 201: s = "\"Short\" expected"; break; + case 202: s = "\"Single\" expected"; break; + case 203: s = "\"Skip\" expected"; break; + case 204: s = "\"Static\" expected"; break; + case 205: s = "\"Step\" expected"; break; + case 206: s = "\"Stop\" expected"; break; + case 207: s = "\"Strict\" expected"; break; + case 208: s = "\"String\" expected"; break; + case 209: s = "\"Structure\" expected"; break; + case 210: s = "\"Sub\" expected"; break; + case 211: s = "\"SyncLock\" expected"; break; + case 212: s = "\"Take\" expected"; break; + case 213: s = "\"Text\" expected"; break; + case 214: s = "\"Then\" expected"; break; + case 215: s = "\"Throw\" expected"; break; + case 216: s = "\"To\" expected"; break; + case 217: s = "\"True\" expected"; break; + case 218: s = "\"Try\" expected"; break; + case 219: s = "\"TryCast\" expected"; break; + case 220: s = "\"TypeOf\" expected"; break; + case 221: s = "\"UInteger\" expected"; break; + case 222: s = "\"ULong\" expected"; break; + case 223: s = "\"Unicode\" expected"; break; + case 224: s = "\"Until\" expected"; break; + case 225: s = "\"UShort\" expected"; break; + case 226: s = "\"Using\" expected"; break; + case 227: s = "\"Variant\" expected"; break; + case 228: s = "\"Wend\" expected"; break; + case 229: s = "\"When\" expected"; break; + case 230: s = "\"Where\" expected"; break; + case 231: s = "\"While\" expected"; break; + case 232: s = "\"Widening\" expected"; break; + case 233: s = "\"With\" expected"; break; + case 234: s = "\"WithEvents\" expected"; break; + case 235: s = "\"WriteOnly\" expected"; break; + case 236: s = "\"Xor\" expected"; break; + case 237: s = "\"GetXmlNamespace\" expected"; break; + case 238: s = "??? expected"; break; + case 239: s = "this symbol not expected in EndOfStmt"; break; + case 240: s = "invalid EndOfStmt"; break; + case 241: s = "invalid OptionStmt"; break; + case 242: s = "invalid OptionStmt"; break; + case 243: s = "invalid GlobalAttributeSection"; break; + case 244: s = "invalid GlobalAttributeSection"; break; + case 245: s = "invalid NamespaceMemberDecl"; break; + case 246: s = "invalid OptionValue"; break; + case 247: s = "invalid ImportClause"; break; + case 248: s = "invalid Identifier"; break; + case 249: s = "invalid TypeModifier"; break; + case 250: s = "invalid NonModuleDeclaration"; break; + case 251: s = "invalid NonModuleDeclaration"; break; + case 252: s = "invalid TypeParameterConstraints"; break; + case 253: s = "invalid TypeParameterConstraint"; break; + case 254: s = "invalid NonArrayTypeName"; break; + case 255: s = "invalid MemberModifier"; break; + case 256: s = "invalid StructureMemberDecl"; break; + case 257: s = "invalid StructureMemberDecl"; break; + case 258: s = "invalid StructureMemberDecl"; break; + case 259: s = "invalid StructureMemberDecl"; break; + case 260: s = "invalid StructureMemberDecl"; break; + case 261: s = "invalid StructureMemberDecl"; break; + case 262: s = "invalid StructureMemberDecl"; break; + case 263: s = "invalid StructureMemberDecl"; break; + case 264: s = "invalid InterfaceMemberDecl"; break; + case 265: s = "invalid InterfaceMemberDecl"; break; + case 266: s = "invalid Expr"; break; + case 267: s = "invalid Charset"; break; + case 268: s = "invalid IdentifierForFieldDeclaration"; break; + case 269: s = "invalid VariableDeclaratorPartAfterIdentifier"; break; + case 270: s = "invalid ObjectCreateExpression"; break; + case 271: s = "invalid ObjectCreateExpression"; break; + case 272: s = "invalid AccessorDecls"; break; + case 273: s = "invalid EventAccessorDeclaration"; break; + case 274: s = "invalid OverloadableOperator"; break; + case 275: s = "invalid EventMemberSpecifier"; break; + case 276: s = "invalid LambdaExpr"; break; + case 277: s = "invalid AssignmentOperator"; break; + case 278: s = "invalid SimpleExpr"; break; + case 279: s = "invalid SimpleExpr"; break; + case 280: s = "invalid SimpleNonInvocationExpression"; break; + case 281: s = "invalid SimpleNonInvocationExpression"; break; + case 282: s = "invalid SimpleNonInvocationExpression"; break; + case 283: s = "invalid SimpleNonInvocationExpression"; break; + case 284: s = "invalid SimpleNonInvocationExpression"; break; + case 285: s = "invalid SimpleNonInvocationExpression"; break; + case 286: s = "invalid PrimitiveTypeName"; break; + case 287: s = "invalid CastTarget"; break; + case 288: s = "invalid XmlLiteralExpression"; break; + case 289: s = "invalid XmlContentExpression"; break; + case 290: s = "invalid XmlElement"; break; + case 291: s = "invalid XmlElement"; break; + case 292: s = "invalid XmlNestedContent"; break; + case 293: s = "invalid XmlAttribute"; break; + case 294: s = "invalid XmlAttribute"; break; + case 295: s = "invalid ComparisonExpr"; break; + case 296: s = "invalid SubLambdaExpression"; break; + case 297: s = "invalid FunctionLambdaExpression"; break; + case 298: s = "invalid EmbeddedStatement"; break; + case 299: s = "invalid EmbeddedStatement"; break; + case 300: s = "invalid EmbeddedStatement"; break; + case 301: s = "invalid EmbeddedStatement"; break; + case 302: s = "invalid EmbeddedStatement"; break; + case 303: s = "invalid EmbeddedStatement"; break; + case 304: s = "invalid EmbeddedStatement"; break; + case 305: s = "invalid FromOrAggregateQueryOperator"; break; + case 306: s = "invalid QueryOperator"; break; + case 307: s = "invalid PartitionQueryOperator"; break; + case 308: s = "invalid Argument"; break; + case 309: s = "invalid QualIdentAndTypeArguments"; break; + case 310: s = "invalid AttributeArguments"; break; + case 311: s = "invalid AttributeArguments"; break; + case 312: s = "invalid AttributeArguments"; break; + case 313: s = "invalid ParameterModifier"; break; + case 314: s = "invalid Statement"; break; + case 315: s = "invalid LabelName"; break; + case 316: s = "invalid WhileOrUntil"; break; + case 317: s = "invalid SingleLineStatementList"; break; + case 318: s = "invalid SingleLineStatementList"; break; + case 319: s = "invalid OnErrorStatement"; break; + case 320: s = "invalid ResumeStatement"; break; + case 321: s = "invalid CaseClause"; break; + case 322: s = "invalid CaseClause"; break; + + default: s = "error " + errorNumber; break; + } + this.Errors.Error(line, col, s); + } + + private bool StartOf(int s) + { + return set[s, lexer.LookAhead.kind]; + } + + static bool[,] set = { + {T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,T, T,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,T, T,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,T, T,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, x,x,x,x, x,T,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, x,x,x,x, x,T,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, x,T,T,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, x,x,x,x, x,T,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, T,x,T,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, T,x,T,T, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,T, x,x,x,x, x,x,x,x, x,x,T,T, T,x,x,x, T,x,x,T, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,T,x,x, x,x,x,T, x,T,x,T, x,x,T,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,T,T, x,x,x,x, T,T,x,x, T,T,x,x, x,x,x,x, x,T,T,T, T,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, T,x,T,T, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,T, T,x,x,x, T,x,x,T, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,T,x,x, x,x,x,T, x,T,x,T, x,x,T,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,T,T, x,x,x,x, T,x,x,x, T,T,x,x, x,x,x,x, x,T,T,T, T,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,T, T,x,x,x, x,x,x,x, x,x,T,x, x,T,T,T, T,T,x,T, x,x,x,x, x,x,x,T, T,x,x,T, x,T,x,x, x,T,T,T, x,x,x,x, x,T,x,x, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,T, T,T,x,x, x,T,x,x, x,x,T,T, x,x,T,x, T,x,x,x, T,x,T,T, T,T,x,T, T,T,T,T, T,x,T,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,T,T,x, T,T,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,T,x, T,x,T,T, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,T, T,T,x,T, x,T,x,T, T,x,T,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,x}, + {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,T,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, x,x,x,x, x,T,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,T,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,x,x, x,T,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,x,x, x,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,T, T,T,x,T, x,T,T,T, T,x,T,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,T, T,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,T,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,T, T,T,x,T, x,T,T,T, T,x,T,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, T,T,T,T, x,x,x,x, x,x,T,T, T,T,T,T, x,x,T,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,T,x, T,T,T,T, T,x,T,T, x,x,x,x, T,T,T,T, T,T,T,T, x,T,T,T, x,x,T,T, T,T,T,T, T,T,T,T, T,x,x,x, T,x,T,T, x,T,x,x, x,x,x,x, T,x,x,x, x,T,T,x, x,x,T,x, x,T,T,x, x,T,x,T, x,x,x,T, x,T,x,T, x,x,T,T, x,x,x,T, x,T,x,x, x,x,T,T, x,x,T,x, T,T,x,x, T,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,T,T, x,x,x,x, T,x,x,x, T,T,x,x, x,T,x,T, T,T,T,T, T,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,T,T,T, T,T,T,T, T,T,T,x, x,x,x,x, T,T,T,T, x,T,x,x, x,x,T,T, T,T,x,x, x,x,x,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,x, x,x,T,x, T,T,T,T, T,x,T,T, x,T,x,x, T,T,T,T, T,T,T,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x,x, T,T,T,T, T,T,x,x, x,x,x,x, T,T,T,x, T,T,T,x, T,x,T,x, x,T,T,x, T,T,x,T, x,x,x,T, x,T,x,T, x,x,T,T, x,x,x,T, x,T,x,x, x,x,T,T, x,x,T,x, x,T,x,x, T,x,T,T, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,T,x,T, x,T,T,T, T,T,x,x, x,T,T,T, T,x,T,x, T,x,x,T, T,T,x,T, x,T,T,T, T,T,T,T, T,T,T,x, x,x,T,T, x,T,x,x, x,x,x,x}, + {x,T,T,T, T,T,T,T, T,T,T,x, x,T,x,x, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, T,T,T,x, T,T,T,T, T,T,T,T, T,x,T,T, x,T,x,x, T,T,T,T, T,T,T,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x,x, T,T,T,T, T,T,x,T, x,T,x,x, T,T,T,x, T,T,T,x, T,x,T,x, x,T,T,x, T,T,x,T, T,x,x,T, x,T,x,T, T,T,T,T, T,x,T,T, x,T,T,x, x,x,T,T, x,x,T,x, x,T,x,x, T,x,T,T, x,x,x,T, T,T,T,x, x,x,x,x, T,x,x,x, x,T,x,T, x,T,T,T, T,T,x,x, x,T,T,T, T,T,T,x, T,x,x,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x,x,T,T, x,T,x,x, T,x,x,x}, + {x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, T,T,T,T, x,x,x,x, x,x,T,T, T,T,T,T, x,x,T,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,T,x, T,T,T,T, T,x,T,T, x,x,x,x, T,T,T,T, T,T,T,T, x,T,T,T, x,x,T,T, T,T,T,T, T,T,T,T, T,x,x,x, T,x,T,T, x,T,x,x, x,x,x,x, T,x,x,x, x,T,T,x, x,x,T,T, x,T,T,x, x,T,x,T, x,x,x,T, x,T,x,T, x,x,T,T, x,x,x,T, x,T,x,x, x,x,T,T, x,x,T,x, T,T,x,x, T,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,T,T, x,x,x,x, T,x,T,x, T,T,x,x, x,T,x,T, T,T,T,T, T,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,T, T,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,T, T,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,T, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x}, + {x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,T,x, T,T,T,T, T,x,T,T, x,x,x,x, T,T,T,T, T,T,T,T, x,T,T,T, x,x,T,T, T,T,T,T, T,T,T,T, T,x,x,x, T,x,T,T, x,T,x,x, x,x,x,x, T,x,x,x, x,T,T,x, x,x,T,x, x,T,T,x, x,T,x,T, x,x,x,T, x,T,x,T, x,x,T,T, x,x,x,T, x,T,x,x, x,x,T,T, x,x,T,x, x,T,x,x, T,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,T,T, x,x,x,x, T,x,x,x, T,T,x,x, x,T,x,T, T,T,T,T, T,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,T,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, x,x,x,x, x,T,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,T,T,T, T,T,T,T, T,T,T,x, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, T,T,T,T, x,x,x,x, x,x,T,T, T,T,T,T, x,x,T,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,T,x, T,T,T,T, T,x,T,T, x,x,x,x, T,T,T,T, T,T,T,T, x,T,T,T, x,x,T,T, T,T,T,T, T,T,T,T, T,x,x,x, T,x,T,T, x,T,x,x, x,x,x,x, T,x,x,x, x,T,T,x, x,x,T,x, x,T,T,x, x,T,x,T, x,x,x,T, x,T,x,T, x,x,T,T, x,x,x,T, x,T,x,x, x,x,T,T, x,x,T,x, x,T,x,x, T,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,T,T, x,x,x,x, T,x,x,x, T,T,x,x, x,T,x,T, T,T,T,T, T,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, T,T,T,T, x,x,x,x, x,x,T,T, T,T,T,T, x,x,T,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,x, x,x,T,x, T,T,T,T, T,x,T,T, x,T,x,x, T,T,T,T, T,T,T,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x,x, T,T,T,T, T,T,x,x, x,x,x,x, T,T,T,x, T,T,T,x, T,x,T,T, x,T,T,x, T,T,x,T, x,x,x,T, x,T,x,T, x,x,T,T, x,x,x,T, x,T,x,x, x,x,T,T, x,x,T,x, T,T,x,x, T,x,T,T, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,T,x,T, x,T,T,T, T,T,x,x, x,T,T,T, T,x,T,x, T,x,T,T, T,T,x,T, x,T,T,T, T,T,T,T, T,T,T,x, x,x,T,T, x,T,x,x, x,x,x,x}, + {x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, T,T,T,T, x,x,T,x, x,x,T,T, T,T,T,T, x,x,T,T, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,T,x, T,T,T,T, T,x,T,T, x,x,x,x, T,T,T,T, T,T,T,T, x,T,T,T, x,x,T,T, T,T,T,T, T,T,T,T, T,x,x,x, T,x,T,T, x,T,x,x, x,x,x,x, T,x,x,x, x,T,T,x, x,x,T,T, x,T,T,x, x,T,x,T, x,x,x,T, x,T,x,T, x,x,T,T, x,x,x,T, x,T,x,x, x,x,T,T, x,x,T,x, T,T,x,x, T,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,T,T, x,x,x,x, T,x,T,x, T,T,x,x, x,T,x,T, T,T,T,T, T,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, T,T,T,T, x,x,x,x, x,x,T,T, T,T,x,x, x,x,x,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,T,x, T,T,T,T, T,x,T,T, x,x,x,x, T,T,T,T, T,T,T,T, x,T,T,T, x,x,T,T, T,T,T,T, T,T,T,T, T,x,x,x, T,x,T,T, x,T,x,x, x,x,x,x, T,x,x,x, x,T,T,x, x,x,T,x, x,T,T,x, x,T,x,T, x,x,x,T, x,T,x,T, x,x,T,T, x,x,x,T, x,T,x,x, x,x,T,T, x,x,T,x, x,T,x,x, T,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,T,T, x,x,x,x, T,x,x,x, T,T,x,x, x,T,x,T, T,T,T,T, T,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, T,T,T,T, x,x,x,x, x,x,T,T, T,T,x,x, x,x,x,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,x, x,x,T,x, T,T,T,T, T,x,T,T, x,T,x,x, T,T,T,T, T,T,T,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x,x, T,T,T,T, T,T,x,x, x,T,x,x, T,T,T,x, T,T,T,x, T,x,T,x, x,T,T,x, T,T,x,T, x,x,x,T, x,T,x,T, x,x,T,T, x,x,x,T, x,T,x,x, x,x,T,T, x,x,T,x, x,T,x,x, T,x,T,T, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,T,x,T, x,T,T,T, T,T,x,x, x,T,T,T, T,x,T,x, T,x,x,T, T,T,x,T, x,T,T,T, T,T,T,T, T,T,T,x, x,x,T,T, x,T,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, + {x,T,T,T, T,T,T,T, T,T,T,x, x,T,x,x, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, T,T,T,x, T,T,T,x, T,T,T,T, T,x,T,T, x,T,x,x, T,T,T,T, T,T,T,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x,x, T,T,T,T, T,T,x,T, x,T,x,x, T,T,T,x, T,T,T,x, T,x,T,x, x,T,T,x, T,T,x,T, T,x,x,T, x,T,x,T, T,T,T,T, T,x,T,T, x,T,T,x, x,x,T,T, x,x,T,x, x,T,x,x, T,x,T,T, x,x,x,T, T,T,T,x, x,x,x,x, T,x,x,x, x,T,x,T, x,T,T,T, T,T,x,x, x,T,T,T, T,T,T,x, T,x,x,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x,x,T,T, x,T,x,x, T,x,x,x}, + {x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,T,x,T, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, x,x,x,x, x,T,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, T,T,T,T, x,x,x,x, x,x,T,T, T,T,x,x, x,x,x,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,T,T,x, x,x,T,x, T,T,T,T, T,x,T,T, x,T,x,x, T,T,T,T, T,T,T,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x,x, T,T,T,T, T,T,x,x, x,x,x,x, T,T,T,x, T,T,T,x, T,x,T,x, x,T,T,x, T,T,x,T, x,x,x,T, x,T,x,T, x,x,T,T, x,x,x,T, x,T,x,x, x,x,T,T, x,x,T,x, x,T,x,x, T,x,T,T, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,T,x,T, x,T,T,T, T,T,x,x, x,T,T,T, T,x,T,x, T,x,x,T, T,T,x,T, x,T,T,T, T,T,T,T, T,T,T,x, x,x,T,T, x,T,x,x, x,x,x,x}, + {x,x,T,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, T,T,T,T, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,T,x, x,x,x,x, x,T,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, T,x,T,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x} + + }; +} // end Parser + +} \ No newline at end of file diff --git a/Project/Src/Parser/VBNet/VBNET.ATG b/Project/Src/Parser/VBNet/VBNET.ATG new file mode 100644 index 0000000000..ed814fad0b --- /dev/null +++ b/Project/Src/Parser/VBNet/VBNET.ATG @@ -0,0 +1,3752 @@ +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.Text; +using ICSharpCode.NRefactory.Ast; +using ICSharpCode.NRefactory.Parser.VB; +using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute; + +COMPILER VBNET + +/* START AUTOGENERATED TOKENS SECTION */ +TOKENS + /* ----- terminal classes ----- */ + /* EOF is 0 */ + EOL + ident + LiteralString + LiteralCharacter + LiteralInteger + LiteralDouble + LiteralSingle + LiteralDecimal + LiteralDate + XmlOpenTag + XmlCloseTag + XmlStartInlineVB + XmlEndInlineVB + XmlCloseTagEmptyElement + XmlOpenEndTag + XmlContent + XmlComment + XmlCData + XmlProcessingInstruction + + /* ----- special character ----- */ + "=" + ":" + "," + "&" + "/" + "\\" + "." + "..." + ".@" + "!" + "-" + "+" + "^" + "?" + "*" + "{" + "}" + "(" + ")" + ">" + "<" + "<>" + ">=" + "<=" + "<<" + ">>" + "+=" + "^=" + "-=" + "*=" + "/=" + "\\=" + "<<=" + ">>=" + "&=" + ":=" + + /* ----- keywords ----- */ + "AddHandler" + "AddressOf" + "Aggregate" + "Alias" + "And" + "AndAlso" + "Ansi" + "As" + "Ascending" + "Assembly" + "Auto" + "Binary" + "Boolean" + "ByRef" + "By" + "Byte" + "ByVal" + "Call" + "Case" + "Catch" + "CBool" + "CByte" + "CChar" + "CDate" + "CDbl" + "CDec" + "Char" + "CInt" + "Class" + "CLng" + "CObj" + "Compare" + "Const" + "Continue" + "CSByte" + "CShort" + "CSng" + "CStr" + "CType" + "CUInt" + "CULng" + "CUShort" + "Custom" + "Date" + "Decimal" + "Declare" + "Default" + "Delegate" + "Descending" + "Dim" + "DirectCast" + "Distinct" + "Do" + "Double" + "Each" + "Else" + "ElseIf" + "End" + "EndIf" + "Enum" + "Equals" + "Erase" + "Error" + "Event" + "Exit" + "Explicit" + "False" + "Finally" + "For" + "Friend" + "From" + "Function" + "Get" + "GetType" + "Global" + "GoSub" + "GoTo" + "Group" + "Handles" + "If" + "Implements" + "Imports" + "In" + "Infer" + "Inherits" + "Integer" + "Interface" + "Into" + "Is" + "IsNot" + "Join" + "Key" + "Let" + "Lib" + "Like" + "Long" + "Loop" + "Me" + "Mod" + "Module" + "MustInherit" + "MustOverride" + "MyBase" + "MyClass" + "Namespace" + "Narrowing" + "New" + "Next" + "Not" + "Nothing" + "NotInheritable" + "NotOverridable" + "Object" + "Of" + "Off" + "On" + "Operator" + "Option" + "Optional" + "Or" + "Order" + "OrElse" + "Out" + "Overloads" + "Overridable" + "Overrides" + "ParamArray" + "Partial" + "Preserve" + "Private" + "Property" + "Protected" + "Public" + "RaiseEvent" + "ReadOnly" + "ReDim" + "Rem" + "RemoveHandler" + "Resume" + "Return" + "SByte" + "Select" + "Set" + "Shadows" + "Shared" + "Short" + "Single" + "Skip" + "Static" + "Step" + "Stop" + "Strict" + "String" + "Structure" + "Sub" + "SyncLock" + "Take" + "Text" + "Then" + "Throw" + "To" + "True" + "Try" + "TryCast" + "TypeOf" + "UInteger" + "ULong" + "Unicode" + "Until" + "UShort" + "Using" + "Variant" + "Wend" + "When" + "Where" + "While" + "Widening" + "With" + "WithEvents" + "WriteOnly" + "Xor" + "GetXmlNamespace" +/* END AUTOGENERATED TOKENS SECTION */ + +PRODUCTIONS + +VBNET + (. + lexer.NextToken(); // get the first token + compilationUnit = new CompilationUnit(); + BlockStart(compilationUnit); + .) += + { EndOfStmt } + { OptionStmt { EndOfStmt } } + { ImportsStmt { EndOfStmt } } + { IF (IsGlobalAttrTarget()) GlobalAttributeSection { EndOfStmt } } + { NamespaceMemberDecl { EndOfStmt } } + EOF +. + +OptionStmt (. INode node = null; bool val = true; .) = + "Option" (. Location startPos = t.Location; .) + ( + "Explicit" [ OptionValue ] + (. node = new OptionDeclaration(OptionType.Explicit, val); .) + | + "Strict" [ OptionValue ] + (. node = new OptionDeclaration(OptionType.Strict, val); .) + | + "Compare" ( "Binary" (. node = new OptionDeclaration(OptionType.CompareBinary, val); .) + | "Text" (. node = new OptionDeclaration(OptionType.CompareText, val); .) + ) + | + "Infer" [ OptionValue ] + (. node = new OptionDeclaration(OptionType.Infer, val); .) + ) + EndOfStmt + (. + if (node != null) { + node.StartLocation = startPos; + node.EndLocation = t.Location; + AddChild(node); + } + .) + . + +OptionValue = + ( + "On" (. val = true; .) + | + "Off" (. val = false; .) + ) + . + +EndOfStmt = + SYNC ( EOL | ":" ) +. + +ImportsStmt + (.List usings = new List(); + .) = + "Imports" + (. + Location startPos = t.Location; + Using u; + .) + ImportClause (. if (u != null) { usings.Add(u); } .) + { + "," ImportClause (. if (u != null) { usings.Add(u); } .) + } + EndOfStmt + (. + UsingDeclaration usingDeclaration = new UsingDeclaration(usings); + usingDeclaration.StartLocation = startPos; + usingDeclaration.EndLocation = t.Location; + AddChild(usingDeclaration); + .) + . + +ImportClause + (. + string qualident = null; + TypeReference aliasedType = null; + u = null; + .) = + ( + Qualident + [ "=" TypeName ] + (. + if (qualident != null && qualident.Length > 0) { + if (aliasedType != null) { + u = new Using(qualident, aliasedType); + } else { + u = new Using(qualident); + } + } + .) + ) | ( (. string prefix = null; .) + XmlOpenTag Identifier (. prefix = t.val; .) "=" LiteralString (. u = new Using(t.literalValue as string, prefix); .) XmlCloseTag + ) + . + +/* 6.4.2 */ +NamespaceMemberDecl + (. + ModifierList m = new ModifierList(); + AttributeSection section; + List attributes = new List(); + string qualident; + .) = + ("Namespace" + (. + Location startPos = t.Location; + .) + Qualident + (. + INode node = new NamespaceDeclaration(qualident); + node.StartLocation = startPos; + AddChild(node); + BlockStart(node); + .) + EndOfStmt + NamespaceBody + (. + node.EndLocation = t.Location; + BlockEnd(); + .) + ) | ( + { AttributeSection (. attributes.Add(section); .) } + { TypeModifier } NonModuleDeclaration ) + . + +/* 4.9.1 */ +TypeParameterList templates> +(. + TemplateDefinition template; +.) += + [ + IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) + "(" "Of" TypeParameter + (. + if (template != null) templates.Add(template); + .) + { + "," TypeParameter + (. + if (template != null) templates.Add(template); + .) + } + ")" + ] +. + +/* 4.9.1 */ +TypeParameter + (. VarianceModifier modifier = VarianceModifier.Invariant; Location startLocation = la.Location; .) += + ( + [ "In" (. modifier = VarianceModifier.Contravariant; .) | "Out" (. modifier = VarianceModifier.Covariant; .) ] Identifier (. template = new TemplateDefinition(t.val, null) { VarianceModifier = modifier }; .) + [TypeParameterConstraints