Browse Source

vb.atg: added GREEDY in some cases

newNRvisualizers
Siegfried Pammer 16 years ago
parent
commit
eaa53d0ae1
  1. 128
      VB/Project/Parser/Parser.cs
  2. 3259
      VB/Project/Parser/trace.txt
  3. 139
      VB/Project/Parser/vb.atg

128
VB/Project/Parser/Parser.cs

@ -3669,13 +3669,11 @@ partial class VBParser
lambda.StartLocation = la.Location; lambda.StartLocation = la.Location;
Expect(210); Expect(210);
if (la.kind == 37) { Expect(37);
Get(); if (StartOf(7)) {
if (StartOf(7)) { FormalParameterList(lambda.Parameters);
FormalParameterList(lambda.Parameters);
}
Expect(38);
} }
Expect(38);
if (StartOf(42)) { if (StartOf(42)) {
if (StartOf(24)) { if (StartOf(24)) {
Expr(out inner); Expr(out inner);
@ -3707,13 +3705,11 @@ partial class VBParser
lambda.StartLocation = la.Location; lambda.StartLocation = la.Location;
Expect(127); Expect(127);
if (la.kind == 37) { Expect(37);
Get(); if (StartOf(7)) {
if (StartOf(7)) { FormalParameterList(lambda.Parameters);
FormalParameterList(lambda.Parameters);
}
Expect(38);
} }
Expect(38);
if (la.kind == 63) { if (la.kind == 63) {
Get(); Get();
TypeName(out typeRef); TypeName(out typeRef);
@ -3757,17 +3753,9 @@ partial class VBParser
} else if (la.kind == 89) { } else if (la.kind == 89) {
ContinueStatement(out statement); ContinueStatement(out statement);
} else if (la.kind == 215) { } else if (la.kind == 215) {
Get(); ThrowStatement(out statement);
if (StartOf(24)) {
Expr(out expr);
}
statement = new ThrowStatement(expr);
} else if (la.kind == 195) { } else if (la.kind == 195) {
Get(); ReturnStatement(out statement);
if (StartOf(24)) {
Expr(out expr);
}
statement = new ReturnStatement(expr);
} else if (la.kind == 211) { } else if (la.kind == 211) {
Get(); Get();
Expr(out expr); Expr(out expr);
@ -4606,7 +4594,7 @@ partial class VBParser
} }
void LabelName(out string name) { void LabelName(out string name) {
name = String.Empty; name = string.Empty;
if (StartOf(5)) { if (StartOf(5)) {
Identifier(); Identifier();
@ -4704,13 +4692,17 @@ partial class VBParser
} }
void TryStatement(out Statement tryStatement) { void TryStatement(out Statement tryStatement) {
Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null; Statement blockStmt = null;
Statement finallyStmt = null;
CatchClause clause = null;
List<CatchClause> catchClauses = new List<CatchClause>();
Expect(218); Expect(218);
EndOfStmt(); EndOfStmt();
Block(out blockStmt); Block(out blockStmt);
if (la.kind == 75 || la.kind == 113 || la.kind == 123) { while (la.kind == 75) {
CatchClauses(out catchClauses); CatchClause(out clause);
if (clause != null) catchClauses.Add(clause);
} }
if (la.kind == 123) { if (la.kind == 123) {
Get(); Get();
@ -4720,7 +4712,6 @@ partial class VBParser
Expect(113); Expect(113);
Expect(218); Expect(218);
tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
} }
void ContinueStatement(out Statement statement) { void ContinueStatement(out Statement statement) {
@ -4741,6 +4732,24 @@ partial class VBParser
statement = new ContinueStatement(continueType); statement = new ContinueStatement(continueType);
} }
void ThrowStatement(out Statement statement) {
Expression expr = null;
Expect(215);
if (StartOf(24)) {
Expr(out expr);
}
statement = new ThrowStatement(expr);
}
void ReturnStatement(out Statement statement) {
Expression expr = null;
Expect(195);
if (StartOf(24)) {
Expr(out expr);
}
statement = new ReturnStatement(expr);
}
void WithStatement(out Statement withStatement) { void WithStatement(out Statement withStatement) {
Statement blockStmt = null; Statement blockStmt = null;
Expression expr = null; Expression expr = null;
@ -4881,7 +4890,9 @@ partial class VBParser
} }
void GotoStatement(out GotoStatement goToStatement) { void GotoStatement(out GotoStatement goToStatement) {
string label = String.Empty; Location startLocation = la.Location; string label = string.Empty;
Location startLocation = la.Location;
Expect(132); Expect(132);
LabelName(out label); LabelName(out label);
goToStatement = new GotoStatement(label) { goToStatement = new GotoStatement(label) {
@ -4893,19 +4904,18 @@ partial class VBParser
void ResumeStatement(out ResumeStatement resumeStatement) { void ResumeStatement(out ResumeStatement resumeStatement) {
resumeStatement = null; resumeStatement = null;
string label = String.Empty; string label = string.Empty;
if (IsResumeNext()) { Expect(194);
Expect(194); if (StartOf(49)) {
Expect(163); if (la.kind == 163) {
resumeStatement = new ResumeStatement(true); Get();
} else if (la.kind == 194) { resumeStatement = new ResumeStatement(true);
Get(); } else {
if (StartOf(49)) {
LabelName(out label); LabelName(out label);
resumeStatement = new ResumeStatement(label);
} }
resumeStatement = new ResumeStatement(label); }
} else SynErr(317);
} }
void ReDimClauseInternal(ref Expression expr) { void ReDimClauseInternal(ref Expression expr) {
@ -4979,7 +4989,7 @@ partial class VBParser
op = BinaryOperatorType.InEquality; op = BinaryOperatorType.InEquality;
break; break;
} }
default: SynErr(318); break; default: SynErr(317); break;
} }
Expr(out expr); Expr(out expr);
caseClause = new CaseLabel(op, expr); caseClause = new CaseLabel(op, expr);
@ -4992,34 +5002,31 @@ partial class VBParser
} }
caseClause = new CaseLabel(expr, sexpr); caseClause = new CaseLabel(expr, sexpr);
} else SynErr(319); } else SynErr(318);
} }
void CatchClauses(out List<CatchClause> catchClauses) { void CatchClause(out CatchClause catchClause) {
catchClauses = new List<CatchClause>();
TypeReference type = null; TypeReference type = null;
Statement blockStmt = null; Statement blockStmt = null;
Expression expr = null; Expression expr = null;
string name = String.Empty; string name = String.Empty;
while (la.kind == 75) { Expect(75);
Get(); if (StartOf(5)) {
if (StartOf(5)) { Identifier();
Identifier(); name = t.val;
name = t.val; if (la.kind == 63) {
if (la.kind == 63) {
Get();
TypeName(out type);
}
}
if (la.kind == 229) {
Get(); Get();
Expr(out expr); TypeName(out type);
} }
EndOfStmt();
Block(out blockStmt);
catchClauses.Add(new CatchClause(type, name, blockStmt, expr));
} }
if (la.kind == 229) {
Get();
Expr(out expr);
}
EndOfStmt();
Block(out blockStmt);
catchClause = new CatchClause(type, name, blockStmt, expr);
} }
@ -5080,11 +5087,11 @@ partial class VBParser
new BitArray(new int[] {1048576, 8372224, 0, 0, 0, 0, 0, 0}), new BitArray(new int[] {1048576, 8372224, 0, 0, 0, 0, 0, 0}),
new BitArray(new int[] {-55298, 2004877309, -1051937, 1467137823, -958420554, -1593340636, -426434, 4807}), new BitArray(new int[] {-55298, 2004877309, -1051937, 1467137823, -958420554, -1593340636, -426434, 4807}),
new BitArray(new int[] {4, 1140850688, 25165903, 1108347652, 821280, 17105920, -2144331776, 65}), new BitArray(new int[] {4, 1140850688, 25165903, 1108347652, 821280, 17105920, -2144331776, 65}),
new BitArray(new int[] {36, 1140850688, 8388687, 1108347140, 821280, 17105920, -2144335872, 65}), new BitArray(new int[] {36, 1140850688, 8388687, 1108347140, 821280, 17105928, -2144335872, 65}),
new BitArray(new int[] {1048576, 3968, 0, 0, 65536, 0, 0, 0}) new BitArray(new int[] {1048576, 3968, 0, 0, 65536, 0, 0, 0})
}; };
void SynErr(int line, int col, int errorNumber) void SynErr(int line, int col, int errorNumber)
{ {
this.Errors.Error(line, col, GetMessage(errorNumber)); this.Errors.Error(line, col, GetMessage(errorNumber));
@ -5410,9 +5417,8 @@ partial class VBParser
case 314: return "invalid SingleLineStatementList"; case 314: return "invalid SingleLineStatementList";
case 315: return "invalid SingleLineStatementList"; case 315: return "invalid SingleLineStatementList";
case 316: return "invalid OnErrorStatement"; case 316: return "invalid OnErrorStatement";
case 317: return "invalid ResumeStatement"; case 317: return "invalid CaseClause";
case 318: return "invalid CaseClause"; case 318: return "invalid CaseClause";
case 319: return "invalid CaseClause";
default: return "error " + errorNumber; default: return "error " + errorNumber;
} }

3259
VB/Project/Parser/trace.txt

File diff suppressed because it is too large Load Diff

139
VB/Project/Parser/vb.atg

@ -1664,7 +1664,7 @@ Expr<out Expression expr>
= =
( (
IF ( IsQueryExpression() ) IF ( IsQueryExpression() )
QueryExpr<out expr> GREEDY QueryExpr<out expr>
| LambdaExpr<out expr> | LambdaExpr<out expr>
| DisjunctionExpr<out expr> | DisjunctionExpr<out expr>
) )
@ -2225,10 +2225,10 @@ SubLambdaExpression<out LambdaExpression lambda>
lambda.StartLocation = la.Location; lambda.StartLocation = la.Location;
.) .)
= =
"Sub" [ "(" [ FormalParameterList<lambda.Parameters> ] ")" ] "Sub" "(" [ FormalParameterList<lambda.Parameters> ] ")"
( (
( (
Expr<out inner> GREEDY Expr<out inner>
(. (.
lambda.ExpressionBody = inner; lambda.ExpressionBody = inner;
lambda.EndLocation = t.EndLocation; // la.Location? lambda.EndLocation = t.EndLocation; // la.Location?
@ -2260,11 +2260,11 @@ FunctionLambdaExpression<out LambdaExpression lambda>
lambda.StartLocation = la.Location; lambda.StartLocation = la.Location;
.) .)
= =
"Function" [ "(" [ FormalParameterList<lambda.Parameters> ] ")" ] "Function" "(" [ FormalParameterList<lambda.Parameters> ] ")"
[ "As" TypeName<out typeRef> (. lambda.ReturnType = typeRef; .) ] [ "As" TypeName<out typeRef> (. lambda.ReturnType = typeRef; .) ]
( (
( (
Expr<out inner> GREEDY Expr<out inner>
(. (.
lambda.ExpressionBody = inner; lambda.ExpressionBody = inner;
lambda.EndLocation = t.EndLocation; // la.Location? lambda.EndLocation = t.EndLocation; // la.Location?
@ -3073,10 +3073,8 @@ EmbeddedStatement<out Statement statement>
( ExitStatement<out statement> ( ExitStatement<out statement>
| TryStatement<out statement> | TryStatement<out statement>
| ContinueStatement<out statement> | ContinueStatement<out statement>
| /* 10.10.1.3 */ | ThrowStatement<out statement>
"Throw" [ Expr<out expr> ] (. statement = new ThrowStatement(expr); .) | ReturnStatement<out statement>
| /* 10.11 */
"Return" [ Expr<out expr> ] (. statement = 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); .)
@ -3372,6 +3370,18 @@ ContinueStatement<out Statement statement> =
(. statement = new ContinueStatement(continueType); .) (. 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); .)
.
SingleLineStatementList<.List<Statement> list.> SingleLineStatementList<.List<Statement> list.>
(. Statement embeddedStatement = null; .) (. Statement embeddedStatement = null; .)
= =
@ -3452,8 +3462,11 @@ OnErrorStatement<out OnErrorStatement stmt>
/* 10.11 */ /* 10.11 */
GotoStatement<out GotoStatement goToStatement> GotoStatement<out GotoStatement goToStatement>
(. string label = String.Empty; Location startLocation = la.Location; .) (.
= string label = string.Empty;
Location startLocation = la.Location;
.)
=
"GoTo" LabelName<out label> "GoTo" LabelName<out label>
(. (.
goToStatement = new GotoStatement(label) { goToStatement = new GotoStatement(label) {
@ -3466,11 +3479,11 @@ GotoStatement<out GotoStatement goToStatement>
/* 10.1 */ /* 10.1 */
LabelName<out string name> LabelName<out string name>
(. (.
name = String.Empty; name = string.Empty;
.) = .) =
Identifier (. name = t.val; .) Identifier (. name = t.val; .)
| LiteralInteger (. name = t.val; .) | LiteralInteger (. name = t.val; .)
. .
/* 12.12.1 */ /* 12.12.1 */
ReDimClause<out Expression expr> ReDimClause<out Expression expr>
@ -3505,14 +3518,15 @@ ReDimClauseInternal<ref Expression expr>
/* 10.10.2.3 */ /* 10.10.2.3 */
ResumeStatement<out ResumeStatement resumeStatement> ResumeStatement<out ResumeStatement resumeStatement>
(. (.
resumeStatement = null; resumeStatement = null;
string label = String.Empty; string label = string.Empty;
.) = .)
IF(IsResumeNext()) =
"Resume" "Next" (. resumeStatement = new ResumeStatement(true); .) "Resume"
| "Resume" [ LabelName<out label> ] (. resumeStatement = new ResumeStatement(label); .) [ "Next" (. resumeStatement = new ResumeStatement(true); .)
. | LabelName<out label> (. resumeStatement = new ResumeStatement(label); .) ]
.
/* 18.8.2 */ /* 18.8.2 */
CaseClauses<.out List<CaseLabel> caseClauses.> CaseClauses<.out List<CaseLabel> caseClauses.>
@ -3583,37 +3597,37 @@ WithStatement<out Statement withStatement>
/* 10.10.1 */ /* 10.10.1 */
TryStatement<out Statement tryStatement> TryStatement<out Statement tryStatement>
(. (.
Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null; Statement blockStmt = null;
.) = Statement finallyStmt = null;
CatchClause clause = null;
List<CatchClause> catchClauses = new List<CatchClause>();
.)
=
"Try" EndOfStmt "Try" EndOfStmt
Block<out blockStmt> Block<out blockStmt>
[CatchClauses<out catchClauses>] { CatchClause<out clause> (. if (clause != null) catchClauses.Add(clause); .) }
["Finally" EndOfStmt Block<out finallyStmt> ] ["Finally" EndOfStmt Block<out finallyStmt> ]
"End" "Try" "End" "Try"
(. (. tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); .)
tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); .
.)
.
/* 10.10.1.2 */ /* 10.10.1.2 */
CatchClauses<.out List<CatchClause> catchClauses.> CatchClause<out CatchClause catchClause>
(. (.
catchClauses = new List<CatchClause>(); TypeReference type = null;
TypeReference type = null; Statement blockStmt = null;
Statement blockStmt = null; Expression expr = null;
Expression expr = null; string name = String.Empty;
string name = String.Empty; .)
.) = =
{ "Catch"
"Catch" [ Identifier (. name = t.val; .) ["As" TypeName<out type>] ]
[ Identifier (. name = t.val; .) ["As" TypeName<out type>] ] [ "When" Expr<out expr> ]
[ "When" Expr<out expr> ] EndOfStmt
EndOfStmt Block<out blockStmt>
Block<out blockStmt> (. catchClause = new CatchClause(type, name, blockStmt, expr); .)
(. catchClauses.Add(new CatchClause(type, name, blockStmt, expr)); .) .
}
.
/* 4.7 */ /* 4.7 */
Qualident<out string qualident> Qualident<out string qualident>
@ -3667,13 +3681,10 @@ IdentifierForFieldDeclaration =
. .
/* 2.2 */ /* 2.2 */
IdentifierOrKeyword<out string name> =
IdentifierOrKeyword<out string name>
=
ANY (. name = t.val; .) ANY (. name = t.val; .)
. .
/* 7.3 */ /* 7.3 */
PrimitiveTypeName<out string type> PrimitiveTypeName<out string type>
(. type = String.Empty; .) = (. type = String.Empty; .) =
@ -3694,19 +3705,19 @@ PrimitiveTypeName<out string type>
| "SByte" (. type = "System.SByte"; .) | "SByte" (. type = "System.SByte"; .)
. .
ParameterModifier<ParamModifierList m> ParameterModifier<ParamModifierList m> =
= "ByVal" (. m.Add(ParameterModifiers.In); .) "ByVal" (. m.Add(ParameterModifiers.In); .)
| "ByRef" (. m.Add(ParameterModifiers.Ref); .) | "ByRef" (. m.Add(ParameterModifiers.Ref); .)
| "Optional" (. m.Add(ParameterModifiers.Optional); .) | "Optional" (. m.Add(ParameterModifiers.Optional); .)
| "ParamArray" (. m.Add(ParameterModifiers.Params); .) | "ParamArray" (. m.Add(ParameterModifiers.Params); .)
. .
TypeModifier<ModifierList m> TypeModifier<ModifierList m> =
= "Public" (. m.Add(Modifiers.Public, t.Location); .) "Public" (. m.Add(Modifiers.Public, t.Location); .)
| "Protected" (. m.Add(Modifiers.Protected, t.Location); .) | "Protected" (. m.Add(Modifiers.Protected, t.Location); .)
| "Friend" (. m.Add(Modifiers.Internal, t.Location); .) | "Friend" (. m.Add(Modifiers.Internal, t.Location); .)
| "Private" (. m.Add(Modifiers.Private, t.Location); .) | "Private" (. m.Add(Modifiers.Private, t.Location); .)
| "Shared" (. m.Add(Modifiers.Static, t.Location); .) | "Shared" (. m.Add(Modifiers.Static, t.Location); .)
| "Shadows" (. m.Add(Modifiers.New, t.Location); .) | "Shadows" (. m.Add(Modifiers.New, t.Location); .)
| "MustInherit" (. m.Add(Modifiers.Abstract, t.Location); .) | "MustInherit" (. m.Add(Modifiers.Abstract, t.Location); .)
| "NotInheritable" (. m.Add(Modifiers.Sealed, t.Location); .) | "NotInheritable" (. m.Add(Modifiers.Sealed, t.Location); .)
@ -3737,12 +3748,12 @@ MemberModifier<ModifierList m> =
PropertyAccessorAccessModifier<out Modifiers m> = PropertyAccessorAccessModifier<out Modifiers m> =
(. m = Modifiers.None; .) (. m = Modifiers.None; .)
{( {
"Public" (. m |= Modifiers.Public; .) "Public" (. m |= Modifiers.Public; .)
| "Protected" (. m |= Modifiers.Protected; .) | "Protected" (. m |= Modifiers.Protected; .)
| "Friend" (. m |= Modifiers.Internal; .) | "Friend" (. m |= Modifiers.Internal; .)
| "Private" (. m |= Modifiers.Private; .) | "Private" (. m |= Modifiers.Private; .)
)} }
. .
END VB . END VB .
Loading…
Cancel
Save