Browse Source

implemented QueryExpressions in ExpressionFinder

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@5991 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 15 years ago
parent
commit
21b78ced7f
  1. 144
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.atg
  2. 3361
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Parser.cs
  3. 2
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/ParserTests.cs

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

@ -415,19 +415,46 @@ SimpleExpressionWithSuffix = @@ -415,19 +415,46 @@ SimpleExpressionWithSuffix =
SimpleExpression =
( Literal
| ( "(" Expression ")" )
| Identifier
| IdentifierForExpressionStart
| ( "." | "!" ) IdentifierOrKeyword
| "GetType" "(" TypeName ")"
| "GetXmlNamespace" "(" (. readXmlIdentifier = true; .) Identifier ")"
| XmlLiteral
| LambdaExpression
| GREEDY QueryExpression
| CastExpression
| ConditionalExpression
)
.
NewExpression =
"New" [ TypeName [ "From" CollectionInitializer ] ] [ "With" ObjectInitializer ]
"New"
(
TypeName
[
EXPECTEDCONFLICT("From")
(
"From"
(
CollectionInitializer /* From + CollectionInitializer is a NewExpression */
|
(.
currentState = endOfStatementTerminatorAndBlock; /* leave this block */
InformToken(t); /* process From 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 */
)
|
"With" ObjectInitializer
)
]
|
"With" ObjectInitializer
)
.
ObjectInitializer =
@ -488,6 +515,107 @@ FunctionLambdaExpression = @@ -488,6 +515,107 @@ FunctionLambdaExpression =
( GREEDY Expression | [ "As" TypeName ] StatementTerminatorAndBlock "End" "Function" )
.
QueryExpression =
( FromQueryOperator | AggregateQueryOperator )
{ QueryOperator }
.
QueryOperator =
FromQueryOperator
| AggregateQueryOperator
| SelectQueryOperator
| DistinctQueryOperator
| WhereQueryOperator
| OrderByQueryOperator
| PartitionQueryOperator
| LetQueryOperator
| GroupByOrGroupJoinQueryOperator
| JoinQueryOperator
.
FromQueryOperator =
"From" CollectionRangeVariable { "," CollectionRangeVariable }
.
AggregateQueryOperator =
"Aggregate" CollectionRangeVariable { QueryOperator } "Into" ExpressionRangeVariable { "," ExpressionRangeVariable }
.
SelectQueryOperator =
"Select" ExpressionRangeVariable { "," ExpressionRangeVariable }
.
DistinctQueryOperator =
"Distinct"
.
WhereQueryOperator =
"Where" Expression
.
OrderByQueryOperator =
"Order" "By" Expression ( "Ascending" | "Descending" ) { "," Expression ( "Ascending" | "Descending" ) }
.
PartitionQueryOperator =
( "Take" | "Skip" ) [ "While" ] Expression
.
LetQueryOperator =
"Let" ExpressionRangeVariable { "," ExpressionRangeVariable }
.
GroupByOrGroupJoinQueryOperator =
"Group"
(
EXPECTEDCONFLICT("Join")
JoinQueryOperator { ( "Group" JoinQueryOperator GroupJoinSuffix | JoinQueryOperator ) }
GroupJoinSuffix
|
( EXPECTEDCONFLICT("By") () | ExpressionRangeVariable { "," ExpressionRangeVariable } )
"By" ExpressionRangeVariable { "," ExpressionRangeVariable }
"Into" ExpressionRangeVariable { "," ExpressionRangeVariable }
)
.
JoinQueryOperator =
"Join" CollectionRangeVariable
"On" Expression "Equals" Expression { "," Expression "Equals" Expression }
.
GroupJoinSuffix =
"Into" ExpressionRangeVariable { "," ExpressionRangeVariable }
.
ExpressionRangeVariable =
[
EXPECTEDCONFLICT("Where", "Until", "Unicode", "Text", "Take", "Skip", "Preserve",
"Order", "Off", "Key", "Join", "Into", "Infer", "Group", "From",
"Explicit", "Equals", "Distinct", "Descending", "Compare", "By",
"Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident)
(
Identifier
(
"As" TypeName "="
| "="
| (.
currentState = endOfStatementTerminatorAndBlock; /* leave this block */
InformToken(t); /* process Identifier 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 */
)
)
]
Expression
.
CollectionRangeVariable =
Identifier [ "As" TypeName ] "In" Expression
.
/* semantic action will be inserted on all paths that possibly lead to XmlLiteral */
XmlLiteral
(.OnEachPossiblePath: nextTokenIsPotentialStartOfXmlMode = true; .)
@ -717,18 +845,21 @@ ArgumentList = @@ -717,18 +845,21 @@ ArgumentList =
/* This production handles pseudo keywords that are needed in the grammar */
Identifier =
(. PushContext(Context.IdentifierExpected, t); .)
(
IdentifierForFieldDeclaration
|
"Custom"
)
(. PopContext(); .)
.
IdentifierForFieldDeclaration =
ident
IdentifierForFieldDeclaration =
IdentifierForExpressionStart
| "Aggregate"
| "From"
.
IdentifierForExpressionStart =
ident
| "Ansi"
| "Ascending"
| "Assembly"
@ -740,7 +871,6 @@ IdentifierForFieldDeclaration = @@ -740,7 +871,6 @@ IdentifierForFieldDeclaration =
| "Distinct"
| "Equals"
| "Explicit"
| "From"
| "Group"
| "Infer"
| "Into"

3361
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Parser.cs

File diff suppressed because it is too large Load Diff

2
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/ParserTests.cs

@ -222,6 +222,8 @@ exit Global @@ -222,6 +222,8 @@ exit Global
p.InformToken(t);
} while (t.Kind != VB.Tokens.EOF);
Console.WriteLine(p.Output);
Assert.AreEqual(expectedOutput, p.Output);
}
}

Loading…
Cancel
Save