Browse Source

Handle End-Statement inside the ExpressionFinder grammar

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@5988 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
0aecab6461
  1. 34
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.atg
  2. 34
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/PushParser.frame

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

@ -367,17 +367,29 @@ Parameter = @@ -367,17 +367,29 @@ Parameter =
StatementTerminatorAndBlock =
(. PushContext(Context.Body, t); .)
StatementTerminator
{ [ Statement] StatementTerminator }
{ EXPECTEDCONFLICT("End")
(
[ Statement] StatementTerminator
| "End"
( StatementTerminator /* End+StatementTerminator is end statement */
| /* End+anything else is the end of this block. */
(.
currentState = endOfStatementTerminatorAndBlock; /* leave this block */
InformToken(t); /* process End 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 */
)
)
}
(.NamedState:endOfStatementTerminatorAndBlock.)
(. PopContext(); .)
.
Expression =
(
SimpleExpressionWithSuffix { BinaryOperator SimpleExpressionWithSuffix }
| ConditionalExpression
| LambdaExpression
// | QueryExpression
)
.
BinaryOperator =
@ -408,7 +420,9 @@ SimpleExpression = @@ -408,7 +420,9 @@ SimpleExpression =
| "GetType" "(" TypeName ")"
| "GetXmlNamespace" "(" (. readXmlIdentifier = true; .) Identifier ")"
| XmlLiteral
| LambdaExpression
| CastExpression
| ConditionalExpression
)
.
@ -471,12 +485,12 @@ SubLambdaExpression = @@ -471,12 +485,12 @@ SubLambdaExpression =
FunctionLambdaExpression =
"Function" "(" [ ParameterList ] ")"
( Expression | [ "As" TypeName ] StatementTerminatorAndBlock "End" "Function" )
( GREEDY Expression | [ "As" TypeName ] StatementTerminatorAndBlock "End" "Function" )
.
/* semantic action in front of = will be inserted on all paths that possibly lead to XmlLiteral */
/* semantic action will be inserted on all paths that possibly lead to XmlLiteral */
XmlLiteral
(. nextTokenIsPotentialStartOfXmlMode = true; .)
(.OnEachPossiblePath: nextTokenIsPotentialStartOfXmlMode = true; .)
=
(. PushContext(Context.Xml, t); .)
{ XmlComment } XmlElement { XmlComment }
@ -672,7 +686,7 @@ BranchStatement = @@ -672,7 +686,7 @@ BranchStatement =
| "Exit" ( "Do" | "For" | "While" | "Select" | "Sub" | "Function" | "Property" | "Try" )
| "Continue" ( "Do" | "For" | "While" )
| "Stop"
/*| "End" HACK End-Statements are not passed to EF-Parser from Lexer */
/*| "End" HACK End-Statements has special handling in Block */
| "Return" [ Expression ]
.

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

@ -42,46 +42,30 @@ partial class ExpressionFinder { @@ -42,46 +42,30 @@ partial class ExpressionFinder {
stateStack.Push(-1); // required so that we don't crash when leaving the root production
}
void Expect(int expectedKind, Token t)
void Expect(int expectedKind, Token la)
{
if (t.kind != expectedKind)
Error(t);
if (la.kind != expectedKind)
Error(la);
}
void Error(Token t)
void Error(Token la)
{
}
Token consumedEndToken;
Token t;
public void InformToken(Token t)
{
if (consumedEndToken != null) {
if (t.kind == Tokens.EOL || t.kind == Tokens.Colon) {
consumedEndToken = null;
return; // ignore End statement
}
InformTokenInternal(consumedEndToken);
consumedEndToken = null;
}
if (t.kind == Tokens.End) {
consumedEndToken = t;
} else {
InformTokenInternal(t);
}
}
void InformTokenInternal(Token t)
public void InformToken(Token la)
{
nextTokenIsPotentialStartOfXmlMode = false;
ApplyToken(t);
-->informToken
ApplyToken(la);
if (la != null) t = la;
}
public void Advance()
{
Console.WriteLine("Advance");
InformTokenInternal(null);
InformToken(null);
}
static readonly bool[,] set = {

Loading…
Cancel
Save