Browse Source

Implemented IfStatement and ConditionalStatement

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@5968 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
3a0d6c2ddb
  1. 45
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.atg
  2. 1639
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Parser.cs
  3. 5
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/XmlModeLexerTests.cs

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

@ -318,7 +318,7 @@ SubOrFunctionDeclaration = @@ -318,7 +318,7 @@ SubOrFunctionDeclaration =
("Sub" | "Function")
(. PushContext(Context.IdentifierExpected, t); .) ANY (. PopContext(); .)
[ "(" [ ParameterList ] ")" ] [ "As" TypeName ]
Block
StatementTerminatorAndBlock
"End" ("Sub" | "Function") StatementTerminator
.
@ -337,16 +337,16 @@ EventMemberDeclaration = @@ -337,16 +337,16 @@ EventMemberDeclaration =
CustomEventMemberDeclaration =
"Custom" EventMemberDeclaration
{
{ AttributeBlock } ( "AddHandler" | "RemoveHandler" | "RaiseEvent" ) "(" ParameterList ")" EOL
Block
{ AttributeBlock } ( "AddHandler" | "RemoveHandler" | "RaiseEvent" ) "(" ParameterList ")"
StatementTerminatorAndBlock
"End" ( "AddHandler" | "RemoveHandler" | "RaiseEvent" ) StatementTerminator
}
"End" "Event" StatementTerminator
.
OperatorDeclaration =
"Operator" ANY "(" ParameterList ")" [ "As" { AttributeBlock } TypeName ] EOL
Block
"Operator" ANY "(" ParameterList ")" [ "As" { AttributeBlock } TypeName ]
StatementTerminatorAndBlock
"End" "Operator" StatementTerminator
.
@ -362,7 +362,7 @@ Parameter = @@ -362,7 +362,7 @@ Parameter =
{ AttributeBlock } { ParameterModifier } Identifier [ "As" TypeName ] [ "=" Expression ]
.
Block =
StatementTerminatorAndBlock =
(. PushContext(Context.Body, t); .)
StatementTerminator
{ [ Statement] StatementTerminator }
@ -373,8 +373,7 @@ Expression = @@ -373,8 +373,7 @@ Expression =
(. nextTokenIsPotentialStartOfXmlMode = true; .)
(
SimpleExpressionWithSuffix { BinaryOperator SimpleExpressionWithSuffix }
| NewExpression
//| ConditionalExpression
| ConditionalExpression
)
.
@ -396,7 +395,7 @@ SimpleExpressionWithSuffix = @@ -396,7 +395,7 @@ SimpleExpressionWithSuffix =
(
SimpleExpression { ExpressionSuffix }
| "TypeOf" SimpleExpressionWithSuffix "Is" TypeName
| CastExpression
| NewExpression
).
SimpleExpression =
@ -408,6 +407,7 @@ SimpleExpression = @@ -408,6 +407,7 @@ SimpleExpression =
| "GetType" "(" TypeName ")"
| "GetXmlNamespace" "(" (. readXmlIdentifier = true; .) Identifier ")"
| XmlLiteral
| CastExpression
)
.
@ -454,10 +454,9 @@ SimpleCastExpression = @@ -454,10 +454,9 @@ SimpleCastExpression =
"(" Expression ")"
.
/*
ConditionalExpression =
"If" "(" Expression "," Expression [ "," Expression ] ")"
.*/
.
XmlLiteral =
(. PushContext(Context.Xml, t); .)
@ -516,6 +515,7 @@ Statement = @@ -516,6 +515,7 @@ Statement =
| WithOrLockStatement
| AddOrRemoveHandlerStatement
| RaiseEventStatement
| IfStatement
| InvocationStatement
.
@ -524,7 +524,7 @@ VariableDeclarationStatement = @@ -524,7 +524,7 @@ VariableDeclarationStatement =
.
WithOrLockStatement =
( "With" | "SyncLock" ) Expression StatementTerminator Block "End" ( "With" | "SyncLock" )
( "With" | "SyncLock" ) Expression StatementTerminatorAndBlock "End" ( "With" | "SyncLock" )
.
AddOrRemoveHandlerStatement =
@ -535,6 +535,27 @@ RaiseEventStatement = @@ -535,6 +535,27 @@ RaiseEventStatement =
"RaiseEvent" IdentifierOrKeyword [ "(" [ ArgumentList ] ")" ]
.
IfStatement =
"If" Expression
( "Then"
( Statement { ":" Statement } [ "Else" Statement { ":" Statement } ] EOL
| MultilineIfRest
)
| MultilineIfRest
)
.
MultilineIfRest =
StatementTerminatorAndBlock
{
("Else" [ "If" Expression [ "Then" ] ]
| "ElseIf" Expression [ "Then" ]
)
StatementTerminatorAndBlock
}
"End" "If"
.
InvocationStatement =
[ "Call" ] Expression
.

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

File diff suppressed because it is too large Load Diff

5
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/XmlModeLexerTests.cs

@ -354,7 +354,7 @@ namespace DefaultNamespace @@ -354,7 +354,7 @@ namespace DefaultNamespace
CheckFoot(lexer);
}
[Test, Ignore]
[Test]
public void IfExpressionTest()
{
ILexer lexer = GenerateLexer(new StringReader(TestStatement("Dim name = If(a <> 2, 4, 8)")));
@ -365,11 +365,10 @@ namespace DefaultNamespace @@ -365,11 +365,10 @@ namespace DefaultNamespace
Tokens.If, Tokens.OpenParenthesis, Tokens.Identifier, Tokens.NotEqual, Tokens.LiteralInteger,
Tokens.Comma, Tokens.LiteralInteger, Tokens.Comma, Tokens.LiteralInteger, Tokens.CloseParenthesis);
CheckFoot(lexer);
}
[Test, Ignore]
[Test]
public void IfStatementTest()
{
ILexer lexer = GenerateLexer(new StringReader(TestStatement("If a <> 2 Then Return")));

Loading…
Cancel
Save