Browse Source

- corrected context detection of IdentifierExpected

- fixed parse error in ForLoopVariable (As TypeName was not recognised)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@5994 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
6e071a75b2
  1. 29
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.atg
  2. 2735
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Parser.cs
  3. 2
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/PushParser.frame
  4. 62
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/ParserTests.cs

29
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.atg

@ -295,7 +295,7 @@ NamespaceDeclaration =
TypeDeclaration = TypeDeclaration =
{ AttributeBlock } { AttributeBlock }
{ TypeModifier } { TypeModifier }
( "Module" | "Class" ) { ANY } StatementTerminator ( "Module" | "Class" ) (. PushContext(Context.IdentifierExpected, t); .) ANY (. PopContext(); .) { ANY } StatementTerminator
(. PushContext(Context.Type, t); .) (. PushContext(Context.Type, t); .)
{ MemberDeclaration } { MemberDeclaration }
"End" ( "Module" | "Class" ) StatementTerminator "End" ( "Module" | "Class" ) StatementTerminator
@ -325,12 +325,12 @@ SubOrFunctionDeclaration =
. .
ExternalMemberDeclaration = ExternalMemberDeclaration =
"Declare" [ "Ansi" | "Unicode" | "Auto" ] ( "Sub" | "Function" ) Identifier "Declare" [ "Ansi" | "Unicode" | "Auto" ] ( "Sub" | "Function" ) (. PushContext(Context.IdentifierExpected, t); .) Identifier (. PopContext(); .)
"Lib" LiteralString [ "Alias" LiteralString ] [ "(" [ ParameterList ] ")" ] StatementTerminator "Lib" LiteralString [ "Alias" LiteralString ] [ "(" [ ParameterList ] ")" ] StatementTerminator
. .
EventMemberDeclaration = EventMemberDeclaration =
"Event" Identifier ( "As" TypeName | [ "(" [ ParameterList ] ")" ] ) "Event" (. PushContext(Context.IdentifierExpected, t); .) Identifier (. PopContext(); .) ( "As" TypeName | [ "(" [ ParameterList ] ")" ] )
[ "Implements" TypeName /*"." IdentifierOrKeyword*/ { "," TypeName /*"." IdentifierOrKeyword*/ } ] [ "Implements" TypeName /*"." IdentifierOrKeyword*/ { "," TypeName /*"." IdentifierOrKeyword*/ } ]
/* the TypeName production already allows the "." IdentifierOrKeyword syntax, so to avoid an ambiguous grammer we just leave that out */ /* the TypeName production already allows the "." IdentifierOrKeyword syntax, so to avoid an ambiguous grammer we just leave that out */
StatementTerminator StatementTerminator
@ -347,13 +347,13 @@ CustomEventMemberDeclaration =
. .
OperatorDeclaration = OperatorDeclaration =
"Operator" ANY "(" ParameterList ")" [ "As" { AttributeBlock } TypeName ] "Operator" (. PushContext(Context.IdentifierExpected, t); .) ANY (. PopContext(); .) "(" ParameterList ")" [ "As" { AttributeBlock } TypeName ]
StatementTerminatorAndBlock StatementTerminatorAndBlock
"End" "Operator" StatementTerminator "End" "Operator" StatementTerminator
. .
MemberVariableOrConstantDeclaration = MemberVariableOrConstantDeclaration =
[ "Const" ] IdentifierForFieldDeclaration [ "As" TypeName ] [ "=" Expression ] StatementTerminator [ "Const" ] (. PushContext(Context.IdentifierExpected, t); .) IdentifierForFieldDeclaration (. PopContext(); .) [ "As" TypeName ] [ "=" Expression ] StatementTerminator
. .
ParameterList = ParameterList =
@ -361,7 +361,7 @@ ParameterList =
. .
Parameter = Parameter =
{ AttributeBlock } { ParameterModifier } Identifier [ "As" TypeName ] [ "=" Expression ] { AttributeBlock } { ParameterModifier } (. PushContext(Context.IdentifierExpected, t); .) Identifier (. PopContext(); .) [ "As" TypeName ] [ "=" Expression ]
. .
StatementTerminatorAndBlock = StatementTerminatorAndBlock =
@ -594,7 +594,7 @@ ExpressionRangeVariable =
"Explicit", "Equals", "Distinct", "Descending", "Compare", "By", "Explicit", "Equals", "Distinct", "Descending", "Compare", "By",
"Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident) "Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident)
( (
Identifier (. PushContext(Context.IdentifierExpected, t); .) Identifier (. PopContext(); .)
( (
"As" TypeName "=" "As" TypeName "="
| "=" | "="
@ -613,7 +613,7 @@ ExpressionRangeVariable =
. .
CollectionRangeVariable = CollectionRangeVariable =
Identifier [ "As" TypeName ] "In" Expression (. PushContext(Context.IdentifierExpected, t); .) Identifier (. PopContext(); .) [ "As" TypeName ] "In" Expression
. .
/* semantic action will be inserted on all paths that possibly lead to XmlLiteral */ /* semantic action will be inserted on all paths that possibly lead to XmlLiteral */
@ -692,7 +692,7 @@ Statement =
. .
VariableDeclarationStatement = VariableDeclarationStatement =
( "Dim" | "Static" | "Const" ) Identifier [ "?" ] [ ( "(" { "," } ")" ) ] { "," Identifier [ "?" ] [ ( "(" { "," } ")" ) ] } [ "As" [ "New" ] TypeName ] [ "=" Expression ] ( "Dim" | "Static" | "Const" ) (. PushContext(Context.IdentifierExpected, t); .) Identifier (. PopContext(); .) [ "?" ] [ ( "(" { "," } ")" ) ] { "," (. PushContext(Context.IdentifierExpected, t); .) Identifier (. PopContext(); .) [ "?" ] [ ( "(" { "," } ")" ) ] } [ "As" [ "New" ] TypeName ] [ "=" Expression ]
. .
WithOrLockStatement = WithOrLockStatement =
@ -781,7 +781,7 @@ ForEachLoopStatement =
. .
ForLoopVariable = ForLoopVariable =
SimpleExpression [ "?" ] { ExpressionSuffix } (. PushContext(Context.IdentifierExpected, t); .) SimpleExpression (. PopContext(); .) [ "?" ] { ExpressionSuffix } [ "As" TypeName ]
. .
ErrorHandlingStatement = ErrorHandlingStatement =
@ -798,7 +798,7 @@ TryStatement =
StatementTerminatorAndBlock StatementTerminatorAndBlock
{ {
"Catch" "Catch"
[ Identifier [ "As" TypeName ] ] [ (. PushContext(Context.IdentifierExpected, t); .) Identifier (. PopContext(); .) [ "As" TypeName ] ]
[ "When" Expression ] [ "When" Expression ]
StatementTerminatorAndBlock StatementTerminatorAndBlock
} }
@ -845,11 +845,8 @@ ArgumentList =
/* 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"
)
. .
IdentifierForFieldDeclaration = IdentifierForFieldDeclaration =

2735
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Parser.cs

File diff suppressed because it is too large Load Diff

2
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/PushParser.frame

@ -50,6 +50,8 @@ partial class ExpressionFinder {
void Error(Token la) void Error(Token la)
{ {
output.AppendLine("not expected: " + la);
Console.WriteLine("not expected: " + la);
} }
Token t; Token t;

62
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/ParserTests.cs

@ -41,6 +41,8 @@ exit Global
End Class End Class
", ",
@"enter Global @"enter Global
enter IdentifierExpected
exit IdentifierExpected
enter Type enter Type
enter Member enter Member
enter IdentifierExpected enter IdentifierExpected
@ -71,6 +73,8 @@ exit Global
End Class End Class
", ",
@"enter Global @"enter Global
enter IdentifierExpected
exit IdentifierExpected
enter Type enter Type
enter Member enter Member
enter IdentifierExpected enter IdentifierExpected
@ -108,6 +112,8 @@ End Class
@"enter Global @"enter Global
enter Attribute enter Attribute
exit Attribute exit Attribute
enter IdentifierExpected
exit IdentifierExpected
enter Type enter Type
enter Member enter Member
enter IdentifierExpected enter IdentifierExpected
@ -137,6 +143,8 @@ End Class
@"enter Global @"enter Global
enter Attribute enter Attribute
exit Attribute exit Attribute
enter IdentifierExpected
exit IdentifierExpected
enter Type enter Type
enter Member enter Member
enter IdentifierExpected enter IdentifierExpected
@ -164,6 +172,8 @@ exit Global
End Class End Class
", ",
@"enter Global @"enter Global
enter IdentifierExpected
exit IdentifierExpected
enter Type enter Type
enter Member enter Member
enter Attribute enter Attribute
@ -194,11 +204,63 @@ exit Global
End Class End Class
", ",
@"enter Global @"enter Global
enter IdentifierExpected
exit IdentifierExpected
enter Type enter Type
enter Member enter Member
enter IdentifierExpected enter IdentifierExpected
exit IdentifierExpected exit IdentifierExpected
enter Body enter Body
enter Body
exit Body
exit Body
exit Member
exit Type
exit Global
"
);
}
[Test]
public void StatementsTest()
{
RunTest(
@"Class Test
Public Sub New()
For i As Integer = 0 To 10
Next
For Each x As Integer In list
Next
Try
Catch e As Exception
End Try
End Sub
End Class
",
@"enter Global
enter IdentifierExpected
exit IdentifierExpected
enter Type
enter Member
enter IdentifierExpected
exit IdentifierExpected
enter Body
enter IdentifierExpected
exit IdentifierExpected
enter Body
exit Body
enter IdentifierExpected
exit IdentifierExpected
enter Body
exit Body
enter Body
exit Body
enter IdentifierExpected enter IdentifierExpected
exit IdentifierExpected exit IdentifierExpected
enter Body enter Body

Loading…
Cancel
Save