Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Apr 11, 2012
1 parent c0cded9 commit d32227f
Show file tree
Hide file tree
Showing 7 changed files with 3,421 additions and 3,381 deletions.
Expand Up @@ -691,8 +691,9 @@ ConditionalExpression =
.

LambdaExpression =
SubLambdaExpression |
FunctionLambdaExpression
(. lambdaNestingDepth++; .)
( SubLambdaExpression | FunctionLambdaExpression )
(. lambdaNestingDepth--; .)
.

SubLambdaExpression =
Expand Down
Expand Up @@ -40,6 +40,7 @@ public ExpressionFinder(ExpressionFinderState state)
nextTokenIsPotentialStartOfExpression = state.NextTokenIsPotentialStartOfExpression;
nextTokenIsStartOfImportsOrAccessExpression = state.NextTokenIsStartOfImportsOrAccessExpression;
readXmlIdentifier = state.ReadXmlIdentifier;
lambdaNestingDepth = state.LambdaNestingDepth;
identifierExpected = state.IdentifierExpected;
stateStack = new Stack<int>(state.StateStack.Reverse());
stack = new Stack<Block>(state.BlockStack.Select(x => (Block)x.Clone()).Reverse());
Expand All @@ -49,7 +50,7 @@ public ExpressionFinder(ExpressionFinderState state)

void Print(string text)
{
//Console.WriteLine(text);
// Console.WriteLine(text);
output.AppendLine(text);
}

Expand Down Expand Up @@ -107,6 +108,10 @@ public bool InContext(Context expected)
.IsElement(fx => fx.context == expected);
}

public int LambdaNestingDepth {
get { return lambdaNestingDepth; }
}

public bool NextTokenIsPotentialStartOfExpression {
get { return nextTokenIsPotentialStartOfExpression; }
}
Expand Down
Expand Up @@ -15,6 +15,7 @@ public class ExpressionFinderState
public bool ReadXmlIdentifier { get; set; }
public bool IdentifierExpected { get; set; }
public bool NextTokenIsStartOfImportsOrAccessExpression { get; set; }
public int LambdaNestingDepth { get; set; }
public Stack<int> StateStack { get; set; }
public Stack<Block> BlockStack { get; set; }
public int CurrentState { get; set; }
Expand Down
17 changes: 13 additions & 4 deletions src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs
Expand Up @@ -1136,13 +1136,22 @@ char PeekUpperChar()
public override void SkipCurrentBlock(int targetToken)
{
int lastKind = -1;
int kind = base.lastToken.kind;
while (kind != Tokens.EOF &&
!(lastKind == Tokens.End && kind == targetToken))
{
int kind = lastToken.kind;
int lambdaDepth = 0;

while (kind != Tokens.EOF) {
lastKind = kind;
StartPeek();
// lambda nesting depth is not correct at end of lambda,
// so we have to check right before the end
if (Peek().kind == Tokens.End)
lambdaDepth = ef.LambdaNestingDepth;
NextToken();
kind = lastToken.kind;
// special handling for multi line lambdas
// once lambdaDepth <= 0 we've reached the end of the method (after the last End Sub/Function)
if (lastKind == Tokens.End && kind == targetToken && lambdaDepth <= 0)
break;
}
}

Expand Down

0 comments on commit d32227f

Please sign in to comment.