Browse Source

ExpressionFinder:

- handle VB array initializer after New expression correctly
- handle Using variable declarators

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6392 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
babad5da81
  1. 38
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.atg
  2. 5613
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Parser.cs
  3. 9
      src/Libraries/NRefactory/Test/Lexer/VBNet/XmlModeLexerTests.cs
  4. 1
      src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs

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

@ -594,7 +594,6 @@ NewExpression = @@ -594,7 +594,6 @@ NewExpression =
"New" (. PushContext(Context.ObjectCreation, la, t); .)
(
TypeName
[
EXPECTEDCONFLICT("From")
(
@ -613,6 +612,11 @@ NewExpression = @@ -613,6 +612,11 @@ NewExpression =
/* 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
@ -628,11 +632,11 @@ NewExpression = @@ -628,11 +632,11 @@ NewExpression =
.
ObjectInitializer =
"{" [ "Key" ] "." IdentifierOrKeyword "=" Expression { "," [ "Key" ] "." IdentifierOrKeyword "=" Expression } "}"
"{" [ [ "Key" ] "." IdentifierOrKeyword "=" Expression { "," [ "Key" ] "." IdentifierOrKeyword "=" Expression } ] "}"
.
CollectionInitializer =
"{" Expression { "," Expression } "}"
"{" [ Expression { "," Expression } ] "}"
.
ExpressionSuffix =
@ -1212,8 +1216,34 @@ EraseStatement = @@ -1212,8 +1216,34 @@ 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 (. PopContext(); .)
// HACK: needs to be optional because Expression can start with Identifier too
[
"As" (. PushContext(Context.Type, la, t); .) ( NewExpression | 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
.
UsingStatement =
"Using" Expression
"Using" UsingVariable { "," UsingVariable }
StatementTerminatorAndBlock
"End" "Using"
.

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

File diff suppressed because it is too large Load Diff

9
src/Libraries/NRefactory/Test/Lexer/VBNet/XmlModeLexerTests.cs

@ -522,6 +522,15 @@ Next"; @@ -522,6 +522,15 @@ Next";
CheckFoot(lexer);
}
[Test]
public void Bug3()
{
ILexer lexer = GenerateLexerForSnippet(new StringReader("New String() {}"), SnippetType.Expression);
CheckTokens(lexer, Tokens.New, Tokens.String, Tokens.OpenParenthesis,
Tokens.CloseParenthesis, Tokens.OpenCurlyBrace, Tokens.CloseCurlyBrace);
}
[Test]
public void LessThanCheck()
{

1
src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs

@ -119,6 +119,7 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter @@ -119,6 +119,7 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
TestStatement("Dim a As Object() = New Object(10) {}");
TestTypeMember("Private MultiDim As Integer(,) = {{1, 2}, {1, 3}}");
TestExpression("New Integer(, ) {{1, 1}, {1, 1}}");
TestTypeMember("Private _titles As String() = New String() {}");
}
[Test]

Loading…
Cancel
Save