Browse Source

merged changes related to lambdas and expression finding from old NRefactory

newNRvisualizers
Siegfried Pammer 15 years ago
parent
commit
605a56a53d
  1. 6
      ICSharpCode.NRefactory.VB.Tests/Lexer/LexerContextTests.cs
  2. 2
      ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj
  3. 36
      ICSharpCode.NRefactory.VB/Lexer/ExpressionFinder.atg
  4. 5329
      ICSharpCode.NRefactory.VB/Lexer/Parser.cs
  5. 6
      ICSharpCode.NRefactory.VB/Parser/Parser.cs
  6. 6
      ICSharpCode.NRefactory.VB/Parser/vb.atg

6
ICSharpCode.NRefactory.VB.Tests/Lexer/LexerContextTests.cs

@ -481,12 +481,14 @@ End Module", @@ -481,12 +481,14 @@ End Module",
enter Expression
enter Expression
enter Expression
enter Expression
exit Expression
exit Expression
exit Expression
exit Expression
enter Expression
enter Expression
enter Expression
enter Expression
exit Expression
exit Expression
exit Expression
exit Expression

2
ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj

@ -126,6 +126,7 @@ @@ -126,6 +126,7 @@
<None Include="Lexer\ExpressionFinder.atg">
<Generator>CocoParserGenerator</Generator>
<CustomToolNamespace>ICSharpCode.NRefactory.VB.Parser</CustomToolNamespace>
<LastGenOutput>Parser.cs</LastGenOutput>
</None>
<None Include="Lexer\KeywordList.txt" />
<None Include="Lexer\PushParser.frame">
@ -137,6 +138,7 @@ @@ -137,6 +138,7 @@
<None Include="Parser\vb.atg">
<CustomToolNamespace>ICSharpCode.NRefactory.VB.Parser</CustomToolNamespace>
<Generator>CocoParserGenerator</Generator>
<LastGenOutput>Parser.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>

36
ICSharpCode.NRefactory.VB/Lexer/ExpressionFinder.atg

@ -367,13 +367,13 @@ TypeOrMemberModifier = @@ -367,13 +367,13 @@ TypeOrMemberModifier =
InterfaceEvent =
"Event" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .)
[ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | "(" [ ParameterList ] ")" ]
[ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | ParameterListInParenthesis ]
StatementTerminator
.
InterfaceProperty =
"Property" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .)
[ "(" [ ParameterList ] ")" ] [ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } TypeName (. PopContext(); .) ]
[ ParameterListInParenthesis ] [ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } TypeName (. PopContext(); .) ]
StatementTerminator
.
@ -435,7 +435,7 @@ ExternalMemberDeclaration = @@ -435,7 +435,7 @@ ExternalMemberDeclaration =
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .)
"Lib" LiteralString
[ "Alias" LiteralString ]
[ "(" [ ParameterList ] ")" ]
[ ParameterListInParenthesis ]
[ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ]
StatementTerminator
.
@ -443,10 +443,10 @@ ExternalMemberDeclaration = @@ -443,10 +443,10 @@ ExternalMemberDeclaration =
EventMemberDeclaration =
"Event"
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .)
( "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | [ "(" [ ParameterList ] ")" ] )
( "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | [ ParameterListInParenthesis ] )
[ "Implements" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/
{ "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ } ]
/* the TypeName production already allows the "." IdentifierOrKeyword syntax, so to avoid an ambiguous grammer we just leave that out */
/* the TypeName production already allows the "." IdentifierOrKeyword syntax, so to avoid an ambiguous grammar we just leave that out */
StatementTerminator
.
@ -463,8 +463,8 @@ CustomEventMemberDeclaration = @@ -463,8 +463,8 @@ CustomEventMemberDeclaration =
PropertyDeclaration =
"Property"
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .)
[ "(" [ ParameterList ] ")" ]
[ "As" { AttributeBlock } ( NewExpression | (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ) ]
[ ParameterListInParenthesis ]
[ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } ( NewExpression | TypeName ) (. PopContext(); .) ]
[ "Implements" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/
{ "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ } ]
[ "=" Expression ] StatementTerminator
@ -474,10 +474,10 @@ PropertyDeclaration = @@ -474,10 +474,10 @@ PropertyDeclaration =
// so we need to simulate it
(.OnEachPossiblePath: SetIdentifierExpected(la); .) }
[ (. PushContext(Context.Member, la, t); .)
( "Get" | "Set" ) [ "(" [ ParameterList ] ")" ]
( "Get" | "Set" ) [ ParameterListInParenthesis ]
StatementTerminatorAndBlock
"End" ( "Get" | "Set" ) StatementTerminator
[ { AttributeBlock } { AccessModifier } ( "Get" | "Set" ) [ "(" [ ParameterList ] ")" ]
[ { AttributeBlock } { AccessModifier } ( "Get" | "Set" ) [ ParameterListInParenthesis ]
StatementTerminatorAndBlock
"End" ( "Get" | "Set" ) StatementTerminator ]
@ -686,15 +686,19 @@ LambdaExpression = @@ -686,15 +686,19 @@ LambdaExpression =
.
SubLambdaExpression =
"Sub" "(" [ ParameterList ] ")"
"Sub" ParameterListInParenthesis
( GREEDY Statement | StatementTerminatorAndBlock "End" "Sub" )
.
FunctionLambdaExpression =
"Function" "(" [ ParameterList ] ")"
"Function" ParameterListInParenthesis
( GREEDY Expression | [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] StatementTerminatorAndBlock "End" "Function" )
.
ParameterListInParenthesis =
"(" (. PushContext(Context.Default, la, t); .) [ ParameterList ] (. PopContext(); .) ")"
.
QueryExpression
(. PushContext(Context.Query, la, t); .)
=
@ -848,7 +852,7 @@ PrimitiveTypeName = @@ -848,7 +852,7 @@ PrimitiveTypeName =
TypeName = ( "Global" | Identifier | PrimitiveTypeName | "?" /* used for ? = completion */ ) { TypeSuffix } { "." IdentifierOrKeyword { TypeSuffix } } .
TypeSuffix = "(" ( "Of" [ TypeName ] { "," [ TypeName ] } | [ ArgumentList ] ) ")" .
TypeSuffix = "(" (. PushContext(Context.Expression, la, t); .) ( "Of" [ (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] { "," [ (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] } | [ ArgumentList ] ) (. PopContext(); .) ")" .
IdentifierOrKeyword = ident
| "AddHandler"
@ -1076,12 +1080,14 @@ VariableDeclarationStatement = @@ -1076,12 +1080,14 @@ VariableDeclarationStatement =
( "Dim" | "Static" | "Const" )
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .)
Identifier (. PopContext(); .) [ "?" ] { "(" [ Expression ] { "," [ Expression ] } ")" }
[ "As" (. PushContext(Context.Type, la, t); .) ( NewExpression | TypeName ) (. PopContext(); .) ]
[ "=" Expression ]
{ ","
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .)
Identifier (. PopContext(); .) [ "?" ] { "(" [ Expression ] { "," [ Expression ] } ")" }
[ "As" (. PushContext(Context.Type, la, t); .) ( NewExpression | TypeName ) (. PopContext(); .) ]
[ "=" Expression ]
}
[ "As" (. PushContext(Context.Type, la, t); .) ( NewExpression | TypeName ) (. PopContext(); .) ]
[ "=" Expression ]
.
WithOrLockStatement =
@ -1093,7 +1099,7 @@ AddOrRemoveHandlerStatement = @@ -1093,7 +1099,7 @@ AddOrRemoveHandlerStatement =
.
RaiseEventStatement =
"RaiseEvent" IdentifierOrKeyword [ "(" [ ArgumentList ] ")" ]
"RaiseEvent" IdentifierOrKeyword [ "(" (. PushContext(Context.Expression, la, t); .) [ ArgumentList ] (. PopContext(); .) ")" ]
.
IfStatement =

5329
ICSharpCode.NRefactory.VB/Lexer/Parser.cs

File diff suppressed because it is too large Load Diff

6
ICSharpCode.NRefactory.VB/Parser/Parser.cs

@ -3677,6 +3677,7 @@ partial class VBParser @@ -3677,6 +3677,7 @@ partial class VBParser
EmbeddedStatement(out statement);
lambda.StatementBody = statement;
lambda.EndLocation = t.EndLocation;
lambda.ExtendedEndLocation = la.Location;
} else if (la.kind == 1) {
Get();
@ -3685,6 +3686,7 @@ partial class VBParser @@ -3685,6 +3686,7 @@ partial class VBParser
Expect(210);
lambda.StatementBody = statement;
lambda.EndLocation = t.EndLocation;
lambda.ExtendedEndLocation = la.Location;
} else SynErr(293);
}
@ -3710,7 +3712,8 @@ partial class VBParser @@ -3710,7 +3712,8 @@ partial class VBParser
if (StartOf(24)) {
Expr(out inner);
lambda.ExpressionBody = inner;
lambda.EndLocation = t.EndLocation; // la.Location?
lambda.EndLocation = t.EndLocation;
lambda.ExtendedEndLocation = la.Location;
} else if (la.kind == 1) {
Get();
@ -3719,6 +3722,7 @@ partial class VBParser @@ -3719,6 +3722,7 @@ partial class VBParser
Expect(127);
lambda.StatementBody = statement;
lambda.EndLocation = t.EndLocation;
lambda.ExtendedEndLocation = la.Location;
} else SynErr(294);
}

6
ICSharpCode.NRefactory.VB/Parser/vb.atg

@ -2232,6 +2232,7 @@ SubLambdaExpression<out LambdaExpression lambda> @@ -2232,6 +2232,7 @@ SubLambdaExpression<out LambdaExpression lambda>
(.
lambda.StatementBody = statement;
lambda.EndLocation = t.EndLocation;
lambda.ExtendedEndLocation = la.Location;
.)
|
EOL
@ -2240,6 +2241,7 @@ SubLambdaExpression<out LambdaExpression lambda> @@ -2240,6 +2241,7 @@ SubLambdaExpression<out LambdaExpression lambda>
(.
lambda.StatementBody = statement;
lambda.EndLocation = t.EndLocation;
lambda.ExtendedEndLocation = la.Location;
.)
)
.
@ -2259,7 +2261,8 @@ FunctionLambdaExpression<out LambdaExpression lambda> @@ -2259,7 +2261,8 @@ FunctionLambdaExpression<out LambdaExpression lambda>
GREEDY Expr<out inner>
(.
lambda.ExpressionBody = inner;
lambda.EndLocation = t.EndLocation; // la.Location?
lambda.EndLocation = t.EndLocation;
lambda.ExtendedEndLocation = la.Location;
.)
|
EOL
@ -2268,6 +2271,7 @@ FunctionLambdaExpression<out LambdaExpression lambda> @@ -2268,6 +2271,7 @@ FunctionLambdaExpression<out LambdaExpression lambda>
(.
lambda.StatementBody = statement;
lambda.EndLocation = t.EndLocation;
lambda.ExtendedEndLocation = la.Location;
.)
)
.

Loading…
Cancel
Save