using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; 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 /* ----- 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" "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" "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" /* END AUTOGENERATED TOKENS SECTION */ PRODUCTIONS VBNET (. lexer.NextToken(); // get the first token compilationUnit = new 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; compilationUnit.AddChild(node); } .) . OptionValue = ( "On" (. val = true; .) | "Off" (. val = false; .) ) . EndOfStmt = 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; compilationUnit.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); } } .) . /* 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; compilationUnit.AddChild(node); compilationUnit.BlockStart(node); .) EndOfStmt NamespaceBody (. node.EndLocation = t.Location; compilationUnit.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 = Identifier (. template = new TemplateDefinition(t.val, null); .) [TypeParameterConstraints