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 =
StatementTerminatorAndBlock = StatementTerminatorAndBlock =
(. PushContext(Context.Body, t); .) (. PushContext(Context.Body, t); .)
StatementTerminator 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(); .) (. PopContext(); .)
. .
Expression = Expression =
(
SimpleExpressionWithSuffix { BinaryOperator SimpleExpressionWithSuffix } SimpleExpressionWithSuffix { BinaryOperator SimpleExpressionWithSuffix }
| ConditionalExpression
| LambdaExpression
// | QueryExpression
)
. .
BinaryOperator = BinaryOperator =
@ -408,7 +420,9 @@ SimpleExpression =
| "GetType" "(" TypeName ")" | "GetType" "(" TypeName ")"
| "GetXmlNamespace" "(" (. readXmlIdentifier = true; .) Identifier ")" | "GetXmlNamespace" "(" (. readXmlIdentifier = true; .) Identifier ")"
| XmlLiteral | XmlLiteral
| LambdaExpression
| CastExpression | CastExpression
| ConditionalExpression
) )
. .
@ -471,12 +485,12 @@ SubLambdaExpression =
FunctionLambdaExpression = FunctionLambdaExpression =
"Function" "(" [ ParameterList ] ")" "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 XmlLiteral
(. nextTokenIsPotentialStartOfXmlMode = true; .) (.OnEachPossiblePath: nextTokenIsPotentialStartOfXmlMode = true; .)
= =
(. PushContext(Context.Xml, t); .) (. PushContext(Context.Xml, t); .)
{ XmlComment } XmlElement { XmlComment } { XmlComment } XmlElement { XmlComment }
@ -672,7 +686,7 @@ BranchStatement =
| "Exit" ( "Do" | "For" | "While" | "Select" | "Sub" | "Function" | "Property" | "Try" ) | "Exit" ( "Do" | "For" | "While" | "Select" | "Sub" | "Function" | "Property" | "Try" )
| "Continue" ( "Do" | "For" | "While" ) | "Continue" ( "Do" | "For" | "While" )
| "Stop" | "Stop"
/*| "End" HACK End-Statements are not passed to EF-Parser from Lexer */ /*| "End" HACK End-Statements has special handling in Block */
| "Return" [ Expression ] | "Return" [ Expression ]
. .

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

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

Loading…
Cancel
Save