Browse Source

- fix bug in VB Parser with Handles and Implements on class members

- implement VB 11 Async and Iterator features in parser
pull/30/head
Siegfried Pammer 14 years ago
parent
commit
002cd2be53
  1. 2
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
  2. 1
      src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs
  3. 1
      src/Libraries/NRefactory/Project/Src/Ast/Enums.cs
  4. 15
      src/Libraries/NRefactory/Project/Src/Ast/Generated.cs
  5. 2
      src/Libraries/NRefactory/Project/Src/IAstVisitor.cs
  6. 57
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.atg
  7. 6
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/KeywordList.txt
  8. 4
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Keywords.cs
  9. 7160
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Parser.cs
  10. 358
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs
  11. 4507
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  12. 17
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  13. 2
      src/Libraries/NRefactory/Project/Src/Visitors/AbstractASTVisitor.cs
  14. 2
      src/Libraries/NRefactory/Project/Src/Visitors/AbstractAstTransformer.cs
  15. 2
      src/Libraries/NRefactory/Project/Src/Visitors/NodeTrackingAstVisitor.cs
  16. 2
      src/Libraries/NRefactory/Project/Src/Visitors/NotImplementedAstVisitor.cs
  17. 28
      src/Libraries/NRefactory/Test/Lexer/VBNet/LexerTests.cs

2
src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs

@ -631,6 +631,8 @@ namespace ICSharpCode.VBNetBinding
if (isMultiLineLambda && (currentToken.Kind == Tokens.Function || currentToken.Kind == Tokens.Sub)) { if (isMultiLineLambda && (currentToken.Kind == Tokens.Function || currentToken.Kind == Tokens.Sub)) {
lambdaNesting++; lambdaNesting++;
int endColumn = currentToken.Location.Column; int endColumn = currentToken.Location.Column;
if (prevToken.Kind == Tokens.Iterator || prevToken.Kind == Tokens.Async)
endColumn = prevToken.Location.Column;
int startColumn = DocumentUtilitites.GetWhitespaceAfter(editor.Document, editor.Document.GetLine(lastVisualLine).Offset).Length; int startColumn = DocumentUtilitites.GetWhitespaceAfter(editor.Document, editor.Document.GetLine(lastVisualLine).Offset).Length;
if (startColumn < endColumn) if (startColumn < endColumn)
Indent(editor, indentation, new string(' ', endColumn - startColumn - 1)); Indent(editor, indentation, new string(' ', endColumn - startColumn - 1));

1
src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs

@ -185,6 +185,7 @@ namespace NRefactoryASTGenerator.Ast
Expression expressionBody; Expression expressionBody;
TypeReference returnType; TypeReference returnType;
bool isAsync; bool isAsync;
bool isIterator;
} }
class CheckedExpression : Expression { class CheckedExpression : Expression {

1
src/Libraries/NRefactory/Project/Src/Ast/Enums.cs

@ -48,6 +48,7 @@ namespace ICSharpCode.NRefactory.Ast
WriteOnly = 0x400000, // VB specific WriteOnly = 0x400000, // VB specific
Async = 0x800000, Async = 0x800000,
Iterator = 0x1000000,
Visibility = Private | Public | Protected | Internal, Visibility = Private | Public | Protected | Internal,
Classes = New | Visibility | Abstract | Sealed | Partial | Static, Classes = New | Visibility | Abstract | Sealed | Partial | Static,

15
src/Libraries/NRefactory/Project/Src/Ast/Generated.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.235 // Runtime Version:4.0.30319.17929
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@ -2631,6 +2631,8 @@ namespace ICSharpCode.NRefactory.Ast {
bool isAsync; bool isAsync;
bool isIterator;
public List<ParameterDeclarationExpression> Parameters { public List<ParameterDeclarationExpression> Parameters {
get { get {
return parameters; return parameters;
@ -2679,6 +2681,15 @@ namespace ICSharpCode.NRefactory.Ast {
} }
} }
public bool IsIterator {
get {
return isIterator;
}
set {
isIterator = value;
}
}
public LambdaExpression() { public LambdaExpression() {
parameters = new List<ParameterDeclarationExpression>(); parameters = new List<ParameterDeclarationExpression>();
statementBody = Statement.Null; statementBody = Statement.Null;
@ -2694,7 +2705,7 @@ public Location ExtendedEndLocation { get; set; }
public override string ToString() { public override string ToString() {
return string.Format("[LambdaExpression Parameters={0} StatementBody={1} ExpressionBody={2} ReturnType=" + return string.Format("[LambdaExpression Parameters={0} StatementBody={1} ExpressionBody={2} ReturnType=" +
"{3} IsAsync={4}]", GetCollectionString(Parameters), StatementBody, ExpressionBody, ReturnType, IsAsync); "{3} IsAsync={4} IsIterator={5}]", GetCollectionString(Parameters), StatementBody, ExpressionBody, ReturnType, IsAsync, IsIterator);
} }
} }

2
src/Libraries/NRefactory/Project/Src/IAstVisitor.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.235 // Runtime Version:4.0.30319.17929
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

57
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.atg

@ -77,7 +77,9 @@ TOKENS
"As" "As"
"Ascending" "Ascending"
"Assembly" "Assembly"
"Async"
"Auto" "Auto"
"Await"
"Binary" "Binary"
"Boolean" "Boolean"
"ByRef" "ByRef"
@ -157,6 +159,7 @@ TOKENS
"Into" "Into"
"Is" "Is"
"IsNot" "IsNot"
"Iterator"
"Join" "Join"
"Key" "Key"
"Let" "Let"
@ -248,6 +251,7 @@ TOKENS
"WithEvents" "WithEvents"
"WriteOnly" "WriteOnly"
"Xor" "Xor"
"Yield"
"GetXmlNamespace" "GetXmlNamespace"
/* END AUTOGENERATED TOKENS SECTION */ /* END AUTOGENERATED TOKENS SECTION */
@ -432,7 +436,7 @@ SubOrFunctionDeclaration =
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .)
{ "(" [ ( "Of" GenericTypeParameterDeclaration | ParameterList ) ] ")" } { "(" [ ( "Of" GenericTypeParameterDeclaration | ParameterList ) ] ")" }
[ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ]
[ ( "Implements" | "Handles" ) [ ( "Me" | "MyClass" | "MyBase" ) "." ] TypeName ] [ ImplementsList | HandlesList ]
StatementTerminatorAndBlock StatementTerminatorAndBlock
"End" ("Sub" | "Function") StatementTerminator "End" ("Sub" | "Function") StatementTerminator
. .
@ -451,9 +455,7 @@ EventMemberDeclaration =
"Event" "Event"
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .)
( "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | [ ParameterListInParenthesis ] ) ( "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | [ ParameterListInParenthesis ] )
[ "Implements" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ [ ImplementsList ]
{ "," (. 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 StatementTerminator
. .
@ -472,8 +474,7 @@ PropertyDeclaration =
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .)
[ ParameterListInParenthesis ] [ ParameterListInParenthesis ]
[ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } ( NewExpression | TypeName ) (. PopContext(); .) ] [ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } ( NewExpression | TypeName ) (. PopContext(); .) ]
[ "Implements" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ [ ImplementsList ]
{ "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ } ]
[ "=" Expression ] StatementTerminator [ "=" Expression ] StatementTerminator
(. PopContext(); .) { EXPECTEDCONFLICT("<") AttributeBlock } (. PopContext(); .) { EXPECTEDCONFLICT("<") AttributeBlock }
{ EXPECTEDCONFLICT("Public", "Protected", "Private", "Friend") AccessModifier { EXPECTEDCONFLICT("Public", "Protected", "Private", "Friend") AccessModifier
@ -525,6 +526,16 @@ Parameter =
(. PopContext(); .) (. PopContext(); .)
. .
/* the TypeName production already allows the "." IdentifierOrKeyword syntax
so to avoid an ambiguous grammar we just leave that out */
ImplementsList = "Implements" TypeName { "," TypeName } .
HandlesList = "Handles" HandlesEntry { "," HandlesEntry } .
HandlesEntry =
( "Me" | "MyClass" | "MyBase" | Identifier ) "." Identifier
.
StatementTerminatorAndBlock StatementTerminatorAndBlock
(.NamedState:startOfBlock.) (.NamedState:startOfBlock.)
= =
@ -568,7 +579,7 @@ BinaryOperator =
. .
UnaryOperator = UnaryOperator =
"+" | "-" | "Not" | "AddressOf" "+" | "-" | "Not" | "AddressOf" | "Await"
. .
SimpleExpressionWithSuffix = SimpleExpressionWithSuffix =
@ -692,6 +703,7 @@ ConditionalExpression =
LambdaExpression = LambdaExpression =
(. lambdaNestingDepth++; .) (. lambdaNestingDepth++; .)
{ "Iterator" | "Async" }
( SubLambdaExpression | FunctionLambdaExpression ) ( SubLambdaExpression | FunctionLambdaExpression )
(. lambdaNestingDepth--; .) (. lambdaNestingDepth--; .)
. .
@ -787,10 +799,10 @@ GroupJoinSuffix =
ExpressionRangeVariable = ExpressionRangeVariable =
[ [
EXPECTEDCONFLICT("Where", "Until", "Unicode", "Text", "Take", "Skip", "Preserve", EXPECTEDCONFLICT("Where", "Until", "Unicode", "Text", "Take", "Skip", "Preserve", "Out",
"Order", "Off", "Out", "Key", "Join", "Into", "Infer", "Group", "From", "Order", "Off", "Key", "Join", "Iterator", "Into", "Infer", "Group", "From", "Explicit",
"Explicit", "Equals", "Distinct", "Descending", "Compare", "By", "Equals", "Distinct", "Descending", "Compare", "By", "Binary", "Await", "Auto", "Async",
"Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident) "Assembly", "Ascending", "Ansi", "Aggregate", ident)
( (
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier
// HACK: needs to be optional because Expression can start with Identifier too // HACK: needs to be optional because Expression can start with Identifier too
@ -866,6 +878,10 @@ TypeName = ( "Global" | Identifier | PrimitiveTypeName | "?" /* used for ? = com
TypeSuffix = "?" | "(" (. PushContext(Context.Expression, la, t); .) ( "Of" [ (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] { "," [ (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] } | [ ArgumentList ] ) (. PopContext(); .) ")" . 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 IdentifierOrKeyword = ident
| "Async"
| "Await"
| "Iterator"
| "Yield"
| "AddHandler" | "AddHandler"
| "AddressOf" | "AddressOf"
| "Aggregate" | "Aggregate"
@ -1235,6 +1251,7 @@ BranchStatement =
| "Stop" | "Stop"
/*| "End" HACK End-Statements has special handling in Block */ /*| "End" HACK End-Statements has special handling in Block */
| "Return" (. PushContext(Context.Expression, la, t); .) [ Expression ] (. PopContext(); .) | "Return" (. PushContext(Context.Expression, la, t); .) [ Expression ] (. PopContext(); .)
| "Yield" (. PushContext(Context.Expression, la, t); .) Expression (. PopContext(); .)
. .
ReDimStatement = ReDimStatement =
@ -1249,19 +1266,19 @@ EraseStatement =
UsingVariable = UsingVariable =
[ [
EXPECTEDCONFLICT("Where", "Until", "Unicode", "Text", "Take", "Skip", "Preserve", EXPECTEDCONFLICT("Where", "Until", "Unicode", "Text", "Take", "Skip", "Preserve", "Out",
"Order", "Off", "Out", "Key", "Join", "Into", "Infer", "Group", "From", "Order", "Off", "Key", "Join", "Iterator", "Into", "Infer", "Group", "From", "Explicit",
"Explicit", "Equals", "Distinct", "Descending", "Compare", "By", "Equals", "Distinct", "Descending", "Compare", "By", "Binary", "Await", "Auto", "Async",
"Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident) "Assembly", "Ascending", "Ansi", "Aggregate", ident)
( (
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier
// HACK: needs to be optional because Expression can start with Identifier too // HACK: needs to be optional because Expression can start with Identifier too
[ (. PopContext(); isAlreadyInExpr = true; .) [ (. PopContext(); isAlreadyInExpr = true; .)
( "As" [ EXPECTEDCONFLICT("Where", "UShort", "Until", "Unicode", "ULong", "UInteger", "Text", "Take", ( "As" [ EXPECTEDCONFLICT("Where", "UShort", "Until", "Unicode", "ULong", "UInteger", "Text", "Take",
"String", "Skip", "Single", "Short", "SByte", "Preserve", "Out", "Order", "String", "Skip", "Single", "Short", "SByte", "Preserve", "Out", "Order",
"Off", "Object", "Long", "Key", "Join", "Into", "Integer", "Infer", "Group", "Off", "Object", "Long", "Key", "Join", "Iterator", "Into", "Integer", "Infer", "Group",
"From", "Explicit", "Equals", "Double", "Distinct", "Descending", "Decimal", "From", "Explicit", "Equals", "Double", "Distinct", "Descending", "Decimal",
"Date", "Compare", "Char", "Byte", "By", "Boolean", "Binary", "Binary", "Auto", "Date", "Compare", "Char", "Byte", "By", "Boolean", "Binary", "Await", "Auto", "Async",
"Assembly", "Ascending", "Ansi", "Aggregate", ident) "Assembly", "Ascending", "Ansi", "Aggregate", ident)
(. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) "=" ] (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) "=" ]
| "=" | "="
@ -1300,12 +1317,16 @@ ArgumentList =
Identifier = Identifier =
IdentifierForFieldDeclaration IdentifierForFieldDeclaration
| "Custom" | "Custom"
| "Async"
| "Iterator"
. .
IdentifierForFieldDeclaration = IdentifierForFieldDeclaration =
IdentifierForExpressionStart IdentifierForExpressionStart
| "Aggregate" | "Aggregate"
| "From" | "From"
| "Await"
| "Yield"
. .
IdentifierForExpressionStart = IdentifierForExpressionStart =
@ -1359,6 +1380,8 @@ TypeModifier =
MemberModifier = MemberModifier =
AccessModifier | AccessModifier |
"Async" |
"Iterator" |
"Shadows" | "Shadows" |
"Shared" | "Shared" |
"Overridable" | "Overridable" |

6
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/KeywordList.txt

@ -89,7 +89,9 @@ ColonAssign = ":="
"As" "As"
"Ascending" "Ascending"
"Assembly" "Assembly"
"Async"
"Auto" "Auto"
"Await"
"Binary" "Binary"
"Boolean" "Boolean"
"ByRef" "ByRef"
@ -169,6 +171,7 @@ ColonAssign = ":="
"Into" "Into"
"Is" "Is"
"IsNot" "IsNot"
"Iterator"
# Note: IsTrue and IsFalse are 'NOT' keywords they're only valid in Operator declarations (like get/set/value are no C# 'keywords') # Note: IsTrue and IsFalse are 'NOT' keywords they're only valid in Operator declarations (like get/set/value are no C# 'keywords')
"Join" "Join"
"Key" "Key"
@ -262,6 +265,7 @@ ColonAssign = ":="
"WithEvents" "WithEvents"
"WriteOnly" "WriteOnly"
"Xor" "Xor"
"Yield"
#XML specific keywords #XML specific keywords
"GetXmlNamespace" "GetXmlNamespace"
@ -273,7 +277,7 @@ GlobalLevel("Namespace", "Module", "Class", "Structure", "Imports", "Option")
TypeLevel("Sub", "Function", "Property") TypeLevel("Sub", "Function", "Property")
# List of keywords that are valid identifiers, must be the same as the "Identifier" production in VBNET.ATG # 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") 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", "Async", "Await", "Iterator", "Yield")
ExpressionStart("Me", "MyBase", "MyClass", @BooleanExpressions, @OperatorsAtStart, "New", @Null, "AddressOf", "GetType", "TypeOf", "GetXmlNamespace", "Global", @TypeKW, @LambdaStart, @CastExpressions) 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") StatementStart(@Null, @ExpressionStart, "Dim", "Const", "Static", "For", "While", "Do", "Select")
SimpleTypeName(@TypeKW, @IdentifierTokens) SimpleTypeName(@TypeKW, @IdentifierTokens)

4
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Keywords.cs

@ -16,7 +16,9 @@ namespace ICSharpCode.NRefactory.Parser.VB
"AS", "AS",
"ASCENDING", "ASCENDING",
"ASSEMBLY", "ASSEMBLY",
"ASYNC",
"AUTO", "AUTO",
"AWAIT",
"BINARY", "BINARY",
"BOOLEAN", "BOOLEAN",
"BYREF", "BYREF",
@ -96,6 +98,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"INTO", "INTO",
"IS", "IS",
"ISNOT", "ISNOT",
"ITERATOR",
"JOIN", "JOIN",
"KEY", "KEY",
"LET", "LET",
@ -187,6 +190,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"WITHEVENTS", "WITHEVENTS",
"WRITEONLY", "WRITEONLY",
"XOR", "XOR",
"YIELD",
"GETXMLNAMESPACE" "GETXMLNAMESPACE"
}; };

7160
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

358
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs

@ -77,180 +77,184 @@ namespace ICSharpCode.NRefactory.Parser.VB
public const int As = 63; public const int As = 63;
public const int Ascending = 64; public const int Ascending = 64;
public const int Assembly = 65; public const int Assembly = 65;
public const int Auto = 66; public const int Async = 66;
public const int Binary = 67; public const int Auto = 67;
public const int Boolean = 68; public const int Await = 68;
public const int ByRef = 69; public const int Binary = 69;
public const int By = 70; public const int Boolean = 70;
public const int Byte = 71; public const int ByRef = 71;
public const int ByVal = 72; public const int By = 72;
public const int Call = 73; public const int Byte = 73;
public const int Case = 74; public const int ByVal = 74;
public const int Catch = 75; public const int Call = 75;
public const int CBool = 76; public const int Case = 76;
public const int CByte = 77; public const int Catch = 77;
public const int CChar = 78; public const int CBool = 78;
public const int CDate = 79; public const int CByte = 79;
public const int CDbl = 80; public const int CChar = 80;
public const int CDec = 81; public const int CDate = 81;
public const int Char = 82; public const int CDbl = 82;
public const int CInt = 83; public const int CDec = 83;
public const int Class = 84; public const int Char = 84;
public const int CLng = 85; public const int CInt = 85;
public const int CObj = 86; public const int Class = 86;
public const int Compare = 87; public const int CLng = 87;
public const int Const = 88; public const int CObj = 88;
public const int Continue = 89; public const int Compare = 89;
public const int CSByte = 90; public const int Const = 90;
public const int CShort = 91; public const int Continue = 91;
public const int CSng = 92; public const int CSByte = 92;
public const int CStr = 93; public const int CShort = 93;
public const int CType = 94; public const int CSng = 94;
public const int CUInt = 95; public const int CStr = 95;
public const int CULng = 96; public const int CType = 96;
public const int CUShort = 97; public const int CUInt = 97;
public const int Custom = 98; public const int CULng = 98;
public const int Date = 99; public const int CUShort = 99;
public const int Decimal = 100; public const int Custom = 100;
public const int Declare = 101; public const int Date = 101;
public const int Default = 102; public const int Decimal = 102;
public const int Delegate = 103; public const int Declare = 103;
public const int Descending = 104; public const int Default = 104;
public const int Dim = 105; public const int Delegate = 105;
public const int DirectCast = 106; public const int Descending = 106;
public const int Distinct = 107; public const int Dim = 107;
public const int Do = 108; public const int DirectCast = 108;
public const int Double = 109; public const int Distinct = 109;
public const int Each = 110; public const int Do = 110;
public const int Else = 111; public const int Double = 111;
public const int ElseIf = 112; public const int Each = 112;
public const int End = 113; public const int Else = 113;
public const int EndIf = 114; public const int ElseIf = 114;
public const int Enum = 115; public const int End = 115;
new public const int Equals = 116; public const int EndIf = 116;
public const int Erase = 117; public const int Enum = 117;
public const int Error = 118; new public const int Equals = 118;
public const int Event = 119; public const int Erase = 119;
public const int Exit = 120; public const int Error = 120;
public const int Explicit = 121; public const int Event = 121;
public const int False = 122; public const int Exit = 122;
public const int Finally = 123; public const int Explicit = 123;
public const int For = 124; public const int False = 124;
public const int Friend = 125; public const int Finally = 125;
public const int From = 126; public const int For = 126;
public const int Function = 127; public const int Friend = 127;
public const int Get = 128; public const int From = 128;
new public const int GetType = 129; public const int Function = 129;
public const int Global = 130; public const int Get = 130;
public const int GoSub = 131; new public const int GetType = 131;
public const int GoTo = 132; public const int Global = 132;
public const int Group = 133; public const int GoSub = 133;
public const int Handles = 134; public const int GoTo = 134;
public const int If = 135; public const int Group = 135;
public const int Implements = 136; public const int Handles = 136;
public const int Imports = 137; public const int If = 137;
public const int In = 138; public const int Implements = 138;
public const int Infer = 139; public const int Imports = 139;
public const int Inherits = 140; public const int In = 140;
public const int Integer = 141; public const int Infer = 141;
public const int Interface = 142; public const int Inherits = 142;
public const int Into = 143; public const int Integer = 143;
public const int Is = 144; public const int Interface = 144;
public const int IsNot = 145; public const int Into = 145;
public const int Join = 146; public const int Is = 146;
public const int Key = 147; public const int IsNot = 147;
public const int Let = 148; public const int Iterator = 148;
public const int Lib = 149; public const int Join = 149;
public const int Like = 150; public const int Key = 150;
public const int Long = 151; public const int Let = 151;
public const int Loop = 152; public const int Lib = 152;
public const int Me = 153; public const int Like = 153;
public const int Mod = 154; public const int Long = 154;
public const int Module = 155; public const int Loop = 155;
public const int MustInherit = 156; public const int Me = 156;
public const int MustOverride = 157; public const int Mod = 157;
public const int MyBase = 158; public const int Module = 158;
public const int MyClass = 159; public const int MustInherit = 159;
public const int Namespace = 160; public const int MustOverride = 160;
public const int Narrowing = 161; public const int MyBase = 161;
public const int New = 162; public const int MyClass = 162;
public const int Next = 163; public const int Namespace = 163;
public const int Not = 164; public const int Narrowing = 164;
public const int Nothing = 165; public const int New = 165;
public const int NotInheritable = 166; public const int Next = 166;
public const int NotOverridable = 167; public const int Not = 167;
public const int Object = 168; public const int Nothing = 168;
public const int Of = 169; public const int NotInheritable = 169;
public const int Off = 170; public const int NotOverridable = 170;
public const int On = 171; public const int Object = 171;
public const int Operator = 172; public const int Of = 172;
public const int Option = 173; public const int Off = 173;
public const int Optional = 174; public const int On = 174;
public const int Or = 175; public const int Operator = 175;
public const int Order = 176; public const int Option = 176;
public const int OrElse = 177; public const int Optional = 177;
public const int Out = 178; public const int Or = 178;
public const int Overloads = 179; public const int Order = 179;
public const int Overridable = 180; public const int OrElse = 180;
public const int Overrides = 181; public const int Out = 181;
public const int ParamArray = 182; public const int Overloads = 182;
public const int Partial = 183; public const int Overridable = 183;
public const int Preserve = 184; public const int Overrides = 184;
public const int Private = 185; public const int ParamArray = 185;
public const int Property = 186; public const int Partial = 186;
public const int Protected = 187; public const int Preserve = 187;
public const int Public = 188; public const int Private = 188;
public const int RaiseEvent = 189; public const int Property = 189;
public const int ReadOnly = 190; public const int Protected = 190;
public const int ReDim = 191; public const int Public = 191;
public const int Rem = 192; public const int RaiseEvent = 192;
public const int RemoveHandler = 193; public const int ReadOnly = 193;
public const int Resume = 194; public const int ReDim = 194;
public const int Return = 195; public const int Rem = 195;
public const int SByte = 196; public const int RemoveHandler = 196;
public const int Select = 197; public const int Resume = 197;
public const int Set = 198; public const int Return = 198;
public const int Shadows = 199; public const int SByte = 199;
public const int Shared = 200; public const int Select = 200;
public const int Short = 201; public const int Set = 201;
public const int Single = 202; public const int Shadows = 202;
public const int Skip = 203; public const int Shared = 203;
public const int Static = 204; public const int Short = 204;
public const int Step = 205; public const int Single = 205;
public const int Stop = 206; public const int Skip = 206;
public const int Strict = 207; public const int Static = 207;
public const int String = 208; public const int Step = 208;
public const int Structure = 209; public const int Stop = 209;
public const int Sub = 210; public const int Strict = 210;
public const int SyncLock = 211; public const int String = 211;
public const int Take = 212; public const int Structure = 212;
public const int Text = 213; public const int Sub = 213;
public const int Then = 214; public const int SyncLock = 214;
public const int Throw = 215; public const int Take = 215;
public const int To = 216; public const int Text = 216;
public const int True = 217; public const int Then = 217;
public const int Try = 218; public const int Throw = 218;
public const int TryCast = 219; public const int To = 219;
public const int TypeOf = 220; public const int True = 220;
public const int UInteger = 221; public const int Try = 221;
public const int ULong = 222; public const int TryCast = 222;
public const int Unicode = 223; public const int TypeOf = 223;
public const int Until = 224; public const int UInteger = 224;
public const int UShort = 225; public const int ULong = 225;
public const int Using = 226; public const int Unicode = 226;
public const int Variant = 227; public const int Until = 227;
public const int Wend = 228; public const int UShort = 228;
public const int When = 229; public const int Using = 229;
public const int Where = 230; public const int Variant = 230;
public const int While = 231; public const int Wend = 231;
public const int Widening = 232; public const int When = 232;
public const int With = 233; public const int Where = 233;
public const int WithEvents = 234; public const int While = 234;
public const int WriteOnly = 235; public const int Widening = 235;
public const int Xor = 236; public const int With = 236;
public const int GetXmlNamespace = 237; public const int WithEvents = 237;
public const int WriteOnly = 238;
public const int Xor = 239;
public const int Yield = 240;
public const int GetXmlNamespace = 241;
public const int MaxToken = 238; public const int MaxToken = 242;
static BitArray NewSet(params int[] values) static BitArray NewSet(params int[] values)
{ {
BitArray bitArray = new BitArray(MaxToken); BitArray bitArray = new BitArray(MaxToken);
@ -263,10 +267,10 @@ namespace ICSharpCode.NRefactory.Parser.VB
public static BitArray BlockSucc = NewSet(Case, Catch, Else, ElseIf, End, Finally, Loop, Next); 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 GlobalLevel = NewSet(Namespace, Module, Class, Structure, Imports, Option);
public static BitArray TypeLevel = NewSet(Sub, Function, Property); 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 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, Async, Await, Iterator, Yield);
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 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 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 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, Async, Await, Iterator, Yield);
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 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 BooleanExpressions = NewSet(True, False);
public static BitArray LambdaStart = NewSet(Sub, Function); public static BitArray LambdaStart = NewSet(Sub, Function);
@ -343,7 +347,9 @@ namespace ICSharpCode.NRefactory.Parser.VB
"As", "As",
"Ascending", "Ascending",
"Assembly", "Assembly",
"Async",
"Auto", "Auto",
"Await",
"Binary", "Binary",
"Boolean", "Boolean",
"ByRef", "ByRef",
@ -423,6 +429,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"Into", "Into",
"Is", "Is",
"IsNot", "IsNot",
"Iterator",
"Join", "Join",
"Key", "Key",
"Let", "Let",
@ -514,6 +521,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"WithEvents", "WithEvents",
"WriteOnly", "WriteOnly",
"Xor", "Xor",
"Yield",
"GetXmlNamespace", "GetXmlNamespace",
}; };
public static string GetTokenString(int token) public static string GetTokenString(int token)

4507
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

17
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -82,7 +82,9 @@ TOKENS
"As" "As"
"Ascending" "Ascending"
"Assembly" "Assembly"
"Async"
"Auto" "Auto"
"Await"
"Binary" "Binary"
"Boolean" "Boolean"
"ByRef" "ByRef"
@ -162,6 +164,7 @@ TOKENS
"Into" "Into"
"Is" "Is"
"IsNot" "IsNot"
"Iterator"
"Join" "Join"
"Key" "Key"
"Let" "Let"
@ -253,6 +256,7 @@ TOKENS
"WithEvents" "WithEvents"
"WriteOnly" "WriteOnly"
"Xor" "Xor"
"Yield"
"GetXmlNamespace" "GetXmlNamespace"
/* END AUTOGENERATED TOKENS SECTION */ /* END AUTOGENERATED TOKENS SECTION */
@ -2228,7 +2232,7 @@ SubLambdaExpression<out LambdaExpression lambda>
lambda.StartLocation = la.Location; lambda.StartLocation = la.Location;
.) .)
= =
"Sub" [ "(" [ FormalParameterList<lambda.Parameters> ] ")" ] { "Async" (. lambda.IsAsync = true; .) | "Iterator" (. lambda.IsIterator = true; .) } "Sub" [ "(" [ FormalParameterList<lambda.Parameters> ] ")" ]
( (
( (
Expr<out inner> Expr<out inner>
@ -2266,7 +2270,7 @@ FunctionLambdaExpression<out LambdaExpression lambda>
lambda.StartLocation = la.Location; lambda.StartLocation = la.Location;
.) .)
= =
"Function" [ "(" [ FormalParameterList<lambda.Parameters> ] ")" ] { "Async" (. lambda.IsAsync = true; .) | "Iterator" (. lambda.IsIterator = true; .) } "Function" [ "(" [ FormalParameterList<lambda.Parameters> ] ")" ]
[ "As" TypeName<out typeRef> (. lambda.ReturnType = typeRef; .) ] [ "As" TypeName<out typeRef> (. lambda.ReturnType = typeRef; .) ]
( (
( (
@ -3105,6 +3109,7 @@ EmbeddedStatement<out Statement statement>
"Throw" [ Expr<out expr> ] (. statement = new ThrowStatement(expr); .) "Throw" [ Expr<out expr> ] (. statement = new ThrowStatement(expr); .)
| /* 10.11 */ | /* 10.11 */
"Return" [ Expr<out expr> ] (. statement = new ReturnStatement(expr); .) "Return" [ Expr<out expr> ] (. statement = new ReturnStatement(expr); .)
| "Yield" [ Expr<out expr> ] (. statement = new YieldStatement(new ReturnStatement(expr)); .)
| /* 10.4 */ | /* 10.4 */
"SyncLock" Expr<out expr> EndOfStmt Block<out embeddedStatement> "SyncLock" Expr<out expr> EndOfStmt Block<out embeddedStatement>
"End" "SyncLock" (. statement = new LockStatement(expr, embeddedStatement); .) "End" "SyncLock" (. statement = new LockStatement(expr, embeddedStatement); .)
@ -3638,11 +3643,14 @@ Qualident<out string qualident>
/* This production handles pseudo keywords that are needed in the grammar */ /* This production handles pseudo keywords that are needed in the grammar */
Identifier = Identifier =
IdentifierForFieldDeclaration IdentifierForFieldDeclaration
| "Custom" | "Custom"
| "Async"
| "Iterator"
. .
IdentifierForFieldDeclaration = IdentifierForFieldDeclaration =
ident ident
| "Await"
| "Aggregate" | "Aggregate"
| "Ansi" | "Ansi"
| "Ascending" | "Ascending"
@ -3671,6 +3679,7 @@ IdentifierForFieldDeclaration =
| "Unicode" | "Unicode"
| "Until" | "Until"
| "Where" | "Where"
| "Yield"
. .
/* 2.2 */ /* 2.2 */
@ -3740,6 +3749,8 @@ MemberModifier<ModifierList m> =
| "WithEvents" (.m.Add(Modifiers.WithEvents, t.Location);.) | "WithEvents" (.m.Add(Modifiers.WithEvents, t.Location);.)
| "Dim" (.m.Add(Modifiers.Dim, t.Location);.) | "Dim" (.m.Add(Modifiers.Dim, t.Location);.)
| "Partial" (.m.Add(Modifiers.Partial, t.Location);.) | "Partial" (.m.Add(Modifiers.Partial, t.Location);.)
| "Async" (.m.Add(Modifiers.Async, t.Location);.)
| "Iterator" (.m.Add(Modifiers.Iterator, t.Location);.)
. .
PropertyAccessorAccessModifier<out Modifiers m> = PropertyAccessorAccessModifier<out Modifiers m> =

2
src/Libraries/NRefactory/Project/Src/Visitors/AbstractASTVisitor.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.235 // Runtime Version:4.0.30319.17929
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

2
src/Libraries/NRefactory/Project/Src/Visitors/AbstractAstTransformer.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.235 // Runtime Version:4.0.30319.17929
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

2
src/Libraries/NRefactory/Project/Src/Visitors/NodeTrackingAstVisitor.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.235 // Runtime Version:4.0.30319.17929
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

2
src/Libraries/NRefactory/Project/Src/Visitors/NotImplementedAstVisitor.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.235 // Runtime Version:4.0.30319.17929
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

28
src/Libraries/NRefactory/Test/Lexer/VBNet/LexerTests.cs

@ -338,6 +338,13 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.Assembly, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Assembly, lexer.NextToken().Kind);
} }
[Test]
public void TestAsync()
{
ILexer lexer = GenerateLexer(new StringReader("Async"));
Assert.AreEqual(Tokens.Async, lexer.NextToken().Kind);
}
[Test] [Test]
public void TestAuto() public void TestAuto()
{ {
@ -345,6 +352,13 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.Auto, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Auto, lexer.NextToken().Kind);
} }
[Test]
public void TestAwait()
{
ILexer lexer = GenerateLexer(new StringReader("Await"));
Assert.AreEqual(Tokens.Await, lexer.NextToken().Kind);
}
[Test] [Test]
public void TestBinary() public void TestBinary()
{ {
@ -898,6 +912,13 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.IsNot, lexer.NextToken().Kind); Assert.AreEqual(Tokens.IsNot, lexer.NextToken().Kind);
} }
[Test]
public void TestIterator()
{
ILexer lexer = GenerateLexer(new StringReader("Iterator"));
Assert.AreEqual(Tokens.Iterator, lexer.NextToken().Kind);
}
[Test] [Test]
public void TestJoin() public void TestJoin()
{ {
@ -1528,6 +1549,13 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.Xor, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Xor, lexer.NextToken().Kind);
} }
[Test]
public void TestYield()
{
ILexer lexer = GenerateLexer(new StringReader("Yield"));
Assert.AreEqual(Tokens.Yield, lexer.NextToken().Kind);
}
[Test] [Test]
public void TestGetXmlNamespace() public void TestGetXmlNamespace()
{ {

Loading…
Cancel
Save