Browse Source

NRefactory.VB: splitted EmbeddedStatement into multiple productions

newNRvisualizers
Siegfried Pammer 15 years ago
parent
commit
2e87b46d7d
  1. 3
      .gitignore
  2. 3
      VB/Project/ICSharpCode.NRefactory.VB.csproj
  3. 940
      VB/Project/Parser/Parser.cs
  4. 5018
      VB/Project/Parser/trace.txt
  5. 314
      VB/Project/Parser/vb.atg

3
.gitignore vendored

@ -6,4 +6,5 @@ @@ -6,4 +6,5 @@
/VB/Project/bin/*
/VB/Project/obj/*
/VB/Test/bin/*
/VB/Test/obj/*
/VB/Test/obj/*
/VB/Project/Parser/trace.txt

3
VB/Project/ICSharpCode.NRefactory.VB.csproj

@ -91,9 +91,6 @@ @@ -91,9 +91,6 @@
<Compile Include="Parser\Parser.cs">
<DependentUpon>vb.atg</DependentUpon>
</Compile>
<None Include="Parser\trace.txt">
<DependentUpon>vb.atg</DependentUpon>
</None>
<Compile Include="Parser\VBParser.cs" />
<Compile Include="PrettyPrinter\AbstractOutputFormatter.cs" />
<Compile Include="PrettyPrinter\AbstractPrettyPrintOptions.cs" />

940
VB/Project/Parser/Parser.cs

File diff suppressed because it is too large Load Diff

5018
VB/Project/Parser/trace.txt

File diff suppressed because it is too large Load Diff

314
VB/Project/Parser/vb.atg

@ -9,7 +9,6 @@ using ICSharpCode.NRefactory.VB.Parser; @@ -9,7 +9,6 @@ using ICSharpCode.NRefactory.VB.Parser;
using ASTAttribute = ICSharpCode.NRefactory.VB.Dom.Attribute;
COMPILER VB
$trace=FG
/* START AUTOGENERATED TOKENS SECTION */
TOKENS
@ -413,7 +412,10 @@ TypeParameter<out TemplateDefinition template> @@ -413,7 +412,10 @@ TypeParameter<out TemplateDefinition template>
(. VarianceModifier modifier = VarianceModifier.Invariant; Location startLocation = la.Location; .)
=
(
[ "In" (. modifier = VarianceModifier.Contravariant; .) | "Out" (. modifier = VarianceModifier.Covariant; .) ] Identifier (. template = new TemplateDefinition(t.val, null) { VarianceModifier = modifier }; .)
[ "In" (. modifier = VarianceModifier.Contravariant; .)
| IF (la.kind == Tokens.Out && IsIdentifierToken(Peek(1))) "Out" (. modifier = VarianceModifier.Covariant; .)
]
Identifier (. template = new TemplateDefinition(t.val, null) { VarianceModifier = modifier }; .)
[TypeParameterConstraints<template>]
)
(.
@ -1777,7 +1779,7 @@ SimpleNonInvocationExpression<out Expression pexpr> @@ -1777,7 +1779,7 @@ SimpleNonInvocationExpression<out Expression pexpr>
"(" Expr<out expr> "," TypeName<out type> ")"
(. pexpr = new CastExpression(type, expr, castType); .)
| /* 11.11 */ CastTarget<out type> "(" Expr<out expr> ")" (. pexpr = new CastExpression(type, expr, CastType.PrimitiveConversion); .)
| /* 11.4.5 */ "AddressOf" Expr<out expr> (. pexpr = new AddressOfExpression(expr); .)
| /* 11.4.5 */ "AddressOf" SimpleExpr<out expr> (. pexpr = new AddressOfExpression(expr); .)
| /* 11.5.1 */ "GetType" "(" GetTypeTypeName<out type> ")" (. pexpr = new TypeOfExpression(type); .)
| /* 11.5.2 */ "TypeOf" SimpleExpr<out expr> "Is" TypeName<out type> (. pexpr = new TypeOfIsExpression(expr, type); .)
| /* 11.22 */ ConditionalExpression<out pexpr>
@ -2220,26 +2222,17 @@ SubLambdaExpression<out LambdaExpression lambda> @@ -2220,26 +2222,17 @@ SubLambdaExpression<out LambdaExpression lambda>
(.
lambda = new LambdaExpression();
lambda.ReturnType = new TypeReference("System.Void", true);
Expression inner = null;
Statement statement = null;
lambda.StartLocation = la.Location;
.)
=
"Sub" "(" [ FormalParameterList<lambda.Parameters> ] ")"
(
(
GREEDY Expr<out inner>
(.
lambda.ExpressionBody = inner;
lambda.EndLocation = t.EndLocation; // la.Location?
.)
|
EmbeddedStatement<out statement>
(.
lambda.StatementBody = statement;
lambda.EndLocation = t.EndLocation;
.)
)
GREEDY EmbeddedStatement<out statement>
(.
lambda.StatementBody = statement;
lambda.EndLocation = t.EndLocation;
.)
|
EOL
Block<out statement>
@ -2263,19 +2256,11 @@ FunctionLambdaExpression<out LambdaExpression lambda> @@ -2263,19 +2256,11 @@ FunctionLambdaExpression<out LambdaExpression lambda>
"Function" "(" [ FormalParameterList<lambda.Parameters> ] ")"
[ "As" TypeName<out typeRef> (. lambda.ReturnType = typeRef; .) ]
(
(
GREEDY Expr<out inner>
(.
lambda.ExpressionBody = inner;
lambda.EndLocation = t.EndLocation; // la.Location?
.)
|
EmbeddedStatement<out statement>
(.
lambda.StatementBody = statement;
lambda.EndLocation = t.EndLocation;
.)
)
GREEDY Expr<out inner>
(.
lambda.ExpressionBody = inner;
lambda.EndLocation = t.EndLocation; // la.Location?
.)
|
EOL
Block<out statement>
@ -3063,11 +3048,8 @@ LocalDeclarationStatement<out Statement statement> @@ -3063,11 +3048,8 @@ LocalDeclarationStatement<out Statement statement>
EmbeddedStatement<out Statement statement>
(.
Statement embeddedStatement = null;
statement = null;
Expression expr = null;
string name = String.Empty;
List<Expression> p = null;
Location startLocation = la.Location;
.) =
( ExitStatement<out statement>
@ -3075,40 +3057,118 @@ EmbeddedStatement<out Statement statement> @@ -3075,40 +3057,118 @@ EmbeddedStatement<out Statement statement>
| ContinueStatement<out statement>
| ThrowStatement<out statement>
| ReturnStatement<out statement>
| /* 10.4 */
"SyncLock" Expr<out expr> EndOfStmt Block<out embeddedStatement>
"End" "SyncLock" (. statement = new LockStatement(expr, embeddedStatement); .)
| /* 10.5.1 */
"RaiseEvent" Identifier (. name = t.val; .)
[ "(" [ ArgumentList<out p> ] ")" ]
(.
statement = new RaiseEventStatement(name, p);
.)
| /* 10.3 */
WithStatement<out statement>
| /* 10.5.2 */
| SyncLockStatement<out statement>
| RaiseEventStatement<out statement>
| WithStatement<out statement>
| AddHandlerStatement<out statement>
| RemoveHandlerStatement<out statement>
| WhileStatement<out statement>
| DoLoopStatement<out statement>
| ForStatement<out statement>
| ErrorStatement<out statement>
| ReDimStatement<out statement>
| EraseStatement<out statement>
| StopStatement<out statement>
| IfStatement<out statement>
| SelectStatement<out statement>
| (. OnErrorStatement onErrorStatement = null; .)
OnErrorStatement<out onErrorStatement> (. statement = onErrorStatement; .)
| (. GotoStatement goToStatement = null; .)
GotoStatement<out goToStatement> (. statement = goToStatement; .)
| ResumeStatement<out statement>
| ExpressionStatement<out statement>
| InvocationStatement<out statement>
| UsingStatement<out statement>
| LocalDeclarationStatement<out statement>
)
(.
if (statement != null) {
statement.StartLocation = startLocation;
statement.EndLocation = t.EndLocation;
}
.)
.
ExitStatement<out Statement statement> =
"Exit" (. ExitType exitType = ExitType.None; .)
( "Sub" (. exitType = ExitType.Sub; .)
| "Function" (. exitType = ExitType.Function; .)
| "Property" (. exitType = ExitType.Property; .)
| "Do" (. exitType = ExitType.Do; .)
| "For" (. exitType = ExitType.For; .)
| "Try" (. exitType = ExitType.Try; .)
| "While" (. exitType = ExitType.While; .)
| "Select" (. exitType = ExitType.Select; .) )
(. statement = new ExitStatement(exitType); .)
.
ContinueStatement<out Statement statement> =
"Continue" (. ContinueType continueType = ContinueType.None; .)
[ "Do" (. continueType = ContinueType.Do; .)
| "For" (. continueType = ContinueType.For; .)
| "While" (. continueType = ContinueType.While; .) ]
(. statement = new ContinueStatement(continueType); .)
.
ThrowStatement<out Statement statement>
(. Expression expr = null; .)
=
"Throw" [ Expr<out expr> ] (. statement = new ThrowStatement(expr); .)
.
ReturnStatement<out Statement statement>
(. Expression expr = null; .)
=
"Return" [ Expr<out expr> ] (. statement = new ReturnStatement(expr); .)
.
SyncLockStatement<out Statement statement>
(. Expression expr; Statement embeddedStatement; .)
=
"SyncLock" Expr<out expr> EndOfStmt
Block<out embeddedStatement>
"End" "SyncLock"
(. statement = new LockStatement(expr, embeddedStatement); .)
.
RaiseEventStatement<out Statement statement>
(. List<Expression> arguments = null; .)
=
"RaiseEvent" Identifier (. string name = t.val; .)
[ "(" [ ArgumentList<out arguments> ] ")" ]
(. statement = new RaiseEventStatement(name, arguments); .)
.
AddHandlerStatement<out Statement statement>
(. Expression expr = null; .)
=
/* 10.5.2 */
"AddHandler" (. Expression handlerExpr = null; .)
Expr<out expr> "," Expr<out handlerExpr>
(.
statement = new AddHandlerStatement(expr, handlerExpr);
.)
| /* 10.5.2 */
(. statement = new AddHandlerStatement(expr, handlerExpr); .)
.
RemoveHandlerStatement<out Statement statement>
(. Expression expr = null; .)
=
"RemoveHandler" (. Expression handlerExpr = null; .)
Expr<out expr> "," Expr<out handlerExpr>
(.
statement = new RemoveHandlerStatement(expr, handlerExpr);
.)
| /* 10.9.1 */
(. statement = new RemoveHandlerStatement(expr, handlerExpr); .)
.
WhileStatement<out Statement statement>
(. Expression expr = null; Statement embeddedStatement; .)
=
"While" Expr<out expr> EndOfStmt
Block<out embeddedStatement> "End" "While"
(.
statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);
.)
| /* 10.9.1 */
(. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); .)
.
DoLoopStatement<out Statement statement>
(. Expression expr = null; Statement embeddedStatement; statement = null; .)
=
"Do"
(.
ConditionType conditionType = ConditionType.None;
.)
(. ConditionType conditionType = ConditionType.None; .)
(
WhileOrUntil<out conditionType> Expr<out expr> EndOfStmt
Block<out embeddedStatement>
@ -3123,11 +3183,14 @@ EmbeddedStatement<out Statement statement> @@ -3123,11 +3183,14 @@ EmbeddedStatement<out Statement statement>
EndOfStmt
Block<out embeddedStatement>
"Loop" [WhileOrUntil<out conditionType> Expr<out expr>]
(.
statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End);
.)
(. statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End); .)
)
| "For"
.
ForStatement<out Statement statement>
(. Expression expr = null; Statement embeddedStatement; statement = null; Location startLocation = la.Location; .)
=
"For"
(.
Expression group = null;
TypeReference typeReference;
@ -3188,10 +3251,20 @@ EmbeddedStatement<out Statement statement> @@ -3188,10 +3251,20 @@ EmbeddedStatement<out Statement statement>
};
.)
)
| /* 10.10.2.1 */
"Error" Expr<out expr> (. statement = new ErrorStatement(expr); .)
| /* 10.12.1 */
"ReDim" (. bool isPreserve = false; .) [ "Preserve" (. isPreserve = true; .) ]
.
ErrorStatement<out Statement statement>
(. Expression expr = null; .)
=
"Error" Expr<out expr>
(. statement = new ErrorStatement(expr); .)
.
ReDimStatement<out Statement statement>
(. Expression expr = null; .)
=
"ReDim" (. bool isPreserve = false; .)
[ EXPECTEDCONFLICT("Preserve") "Preserve" (. isPreserve = true; .) ]
ReDimClause<out expr>
(.
ReDimStatement reDimStatement = new ReDimStatement(isPreserve);
@ -3201,7 +3274,11 @@ EmbeddedStatement<out Statement statement> @@ -3201,7 +3274,11 @@ EmbeddedStatement<out Statement statement>
{ "," ReDimClause<out expr>
(. SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression); .)
}
| /* 10.12.2 */
.
EraseStatement<out Statement statement>
(. Expression expr = null; .)
=
"Erase"
Expr<out expr>
(.
@ -3210,9 +3287,15 @@ EmbeddedStatement<out Statement statement> @@ -3210,9 +3287,15 @@ EmbeddedStatement<out Statement statement>
.)
{ "," Expr<out expr> (. if (expr != null) { SafeAdd(eraseStatement, eraseStatement.Expressions, expr); }.) }
(. statement = eraseStatement; .)
| /* 10.11 */
.
StopStatement<out Statement statement> =
"Stop" (. statement = new StopStatement(); .)
| /* 10.8.1 */
.
IfStatement<out Statement statement>
(. Expression expr = null; Statement embeddedStatement; statement = null; .)
=
IF (la.kind == Tokens.If)
"If" (. Location ifStartLocation = t.Location; .) Expr<out expr> [ "Then" ]
(
@ -3262,7 +3345,11 @@ EmbeddedStatement<out Statement statement> @@ -3262,7 +3345,11 @@ EmbeddedStatement<out Statement statement>
]
(. ifStatement.EndLocation = t.Location; statement = ifStatement; .)
)
| /* 10.8.2 */
.
SelectStatement<out Statement statement>
(. Expression expr = null; .)
=
"Select" [ "Case" ] Expr<out expr> EndOfStmt
(.List<SwitchSection> selectSections = new List<SwitchSection>();
Statement block = null;
@ -3285,13 +3372,11 @@ EmbeddedStatement<out Statement statement> @@ -3285,13 +3372,11 @@ EmbeddedStatement<out Statement statement>
statement = new SwitchStatement(expr, selectSections);
.)
"End" "Select"
| (. OnErrorStatement onErrorStatement = null; .)
OnErrorStatement<out onErrorStatement> (. statement = onErrorStatement; .)
| (. GotoStatement goToStatement = null; .)
GotoStatement<out goToStatement> (. statement = goToStatement; .)
| (. ResumeStatement resumeStatement = null; .)
ResumeStatement<out resumeStatement> (. statement = resumeStatement; .)
|/* Statement expression (invocation and assignment) 10.6.1, 10.6.2, 10.6.3 */
.
ExpressionStatement<out Statement statement>
(. Expression expr = null; .)
= /* Statement expression (invocation and assignment) 10.6.1, 10.6.2, 10.6.3 */
(.
Expression val = null;
AssignmentOperatorType op;
@ -3321,65 +3406,30 @@ EmbeddedStatement<out Statement statement> @@ -3321,65 +3406,30 @@ EmbeddedStatement<out Statement statement>
}
statement = new ExpressionStatement(expr);
.)
| "Call" SimpleExpr<out expr> (. statement = new ExpressionStatement(expr); .)
| "Using"
(. Statement block; .)
( IF (Peek(1).kind == Tokens.As)
(. LocalVariableDeclaration resourceAquisition = new LocalVariableDeclaration(Modifiers.None); .)
VariableDeclarator<resourceAquisition.Variables>
{ ","
VariableDeclarator<resourceAquisition.Variables>
}
Block<out block>
(.
statement = new UsingStatement(resourceAquisition, block);
.)
| Expr<out expr>
Block<out block>
(. statement = new UsingStatement(new ExpressionStatement(expr), block); .)
)
"End" "Using"
| LocalDeclarationStatement<out statement>
)
(.
if (statement != null) {
statement.StartLocation = startLocation;
statement.EndLocation = t.EndLocation;
}
.)
.
ExitStatement<out Statement statement> =
"Exit" (. ExitType exitType = ExitType.None; .)
( "Sub" (. exitType = ExitType.Sub; .)
| "Function" (. exitType = ExitType.Function; .)
| "Property" (. exitType = ExitType.Property; .)
| "Do" (. exitType = ExitType.Do; .)
| "For" (. exitType = ExitType.For; .)
| "Try" (. exitType = ExitType.Try; .)
| "While" (. exitType = ExitType.While; .)
| "Select" (. exitType = ExitType.Select; .) )
(. statement = new ExitStatement(exitType); .)
.
ContinueStatement<out Statement statement> =
"Continue" (. ContinueType continueType = ContinueType.None; .)
[ "Do" (. continueType = ContinueType.Do; .)
| "For" (. continueType = ContinueType.For; .)
| "While" (. continueType = ContinueType.While; .) ]
(. statement = new ContinueStatement(continueType); .)
.
ThrowStatement<out Statement statement>
InvocationStatement<out Statement statement>
(. Expression expr = null; .)
=
"Throw" [ Expr<out expr> ] (. statement = new ThrowStatement(expr); .)
"Call" SimpleExpr<out expr> (. statement = new ExpressionStatement(expr); .)
.
ReturnStatement<out Statement statement>
(. Expression expr = null; .)
UsingStatement<out Statement statement>
(. Expression expr = null; Statement block; statement = null; .)
=
"Return" [ Expr<out expr> ] (. statement = new ReturnStatement(expr); .)
"Using"
( IF (Peek(1).kind == Tokens.As)
(. LocalVariableDeclaration resourceAquisition =
new LocalVariableDeclaration(Modifiers.None); .)
VariableDeclarator<resourceAquisition.Variables>
{ "," VariableDeclarator<resourceAquisition.Variables> }
Block<out block>
(. statement = new UsingStatement(resourceAquisition, block); .)
| Expr<out expr>
Block<out block>
(. statement = new UsingStatement(new ExpressionStatement(expr), block); .)
)
"End" "Using"
.
SingleLineStatementList<.List<Statement> list.>
@ -3517,7 +3567,7 @@ ReDimClauseInternal<ref Expression expr> @@ -3517,7 +3567,7 @@ ReDimClauseInternal<ref Expression expr>
.
/* 10.10.2.3 */
ResumeStatement<out ResumeStatement resumeStatement>
ResumeStatement<out Statement resumeStatement>
(.
resumeStatement = null;
string label = string.Empty;

Loading…
Cancel
Save