using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using ICSharpCode.NRefactory.Parser.AST; using ICSharpCode.NRefactory.Parser.VB; using ASTAttribute = ICSharpCode.NRefactory.Parser.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" "Alias" "And" "AndAlso" "Ansi" "As" "Assembly" "Auto" "Binary" "Boolean" "ByRef" "Byte" "ByVal" "Call" "Case" "Catch" "CBool" "CByte" "CChar" "CDate" "CDbl" "CDec" "Char" "CInt" "Class" "CLng" "CObj" "Compare" "Const" "CShort" "CSng" "CStr" "CType" "Date" "Decimal" "Declare" "Default" "Delegate" "Dim" "DirectCast" "Do" "Double" "Each" "Else" "ElseIf" "End" "EndIf" "Enum" "Erase" "Error" "Event" "Exit" "Explicit" "False" "Finally" "For" "Friend" "Function" "Get" "GetType" "GoSub" "GoTo" "Handles" "If" "Implements" "Imports" "In" "Inherits" "Integer" "Interface" "Is" "Let" "Lib" "Like" "Long" "Loop" "Me" "Mod" "Module" "MustInherit" "MustOverride" "MyBase" "MyClass" "Namespace" "New" "Next" "Not" "Nothing" "NotInheritable" "NotOverridable" "Object" "Off" "On" "Option" "Optional" "Or" "OrElse" "Overloads" "Overridable" "Overrides" "ParamArray" "Preserve" "Private" "Property" "Protected" "Public" "RaiseEvent" "ReadOnly" "ReDim" "RemoveHandler" "Resume" "Return" "Select" "Set" "Shadows" "Shared" "Short" "Single" "Static" "Step" "Stop" "Strict" "String" "Structure" "Sub" "SyncLock" "Text" "Then" "Throw" "To" "True" "Try" "TypeOf" "Unicode" "Until" "Variant" "Wend" "When" "While" "With" "WithEvents" "WriteOnly" "Xor" "Continue" "Operator" "Using" "IsNot" "SByte" "UInteger" "ULong" "UShort" "CSByte" "CUShort" "CUInt" "CULng" "Global" "TryCast" "Of" "Narrowing" "Widening" "Partial" "Custom" /* END AUTOGENERATED TOKENS SECTION */ PRODUCTIONS VBNET (. lexer.NextToken(); // get the first token compilationUnit = new CompilationUnit(); .) = { EOL } { OptionStmt } { ImportsStmt} { IF (IsGlobalAttrTarget()) GlobalAttributeSection } { NamespaceMemberDecl } 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); .) ) ) EndOfStmt (. if (node != null) { node.StartLocation = startPos; node.EndLocation = t.Location; compilationUnit.AddChild(node); } .) . OptionValue = ( "On" (. val = true; .) | "Off" (. val = false; .) ) . EndOfStmt = EOL | ":" [ 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 (. Modifiers m = new Modifiers(); 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); .) EOL 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