Browse Source

VB.NET: grammar (no AST generation yet!) for query expressions

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3386 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Markus Palme 17 years ago
parent
commit
082b2f4bd4
  1. 1799
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  2. 156
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  3. 15
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs

1799
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

156
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -1609,8 +1609,10 @@ EventMemberSpecifier<out string name> @@ -1609,8 +1609,10 @@ EventMemberSpecifier<out string name>
Expr<out Expression expr>
(. expr = null; .) =
DisjunctionExpr<out expr>
| LambdaExpr<out expr>
IF ( IsQueryExpression() )
QueryExpr<out expr>
| LambdaExpr<out expr>
| DisjunctionExpr<out expr>
.
AssignmentOperator<out AssignmentOperatorType op>
@ -2014,6 +2016,156 @@ LambdaExpr<out Expression expr> @@ -2014,6 +2016,156 @@ LambdaExpr<out Expression expr>
.)
.
QueryExpr<out Expression expr>
(.
QueryExpression qexpr = new QueryExpression();
expr = qexpr;
.) =
FromOrAggregateQueryOperator
{ QueryOperator }
.
FromOrAggregateQueryOperator
(. .) =
FromQueryOperator
| AggregateQueryOperator
.
QueryOperator
(. .) =
FromQueryOperator
| AggregateQueryOperator
| SelectQueryOperator
| DistinctQueryOperator
| WhereQueryOperator
| OrderByQueryOperator
| PartitionQueryOperator
| LetQueryOperator
| JoinQueryOperator
| IF(la.kind == Tokens.Group && Peek(1).kind == Tokens.Join) GroupJoinQueryOperator
| GroupByQueryOperator
.
OrderByQueryOperator
(. .) =
"Order" "By" OrderExpressionList
.
OrderExpressionList
(. .) =
OrderExpression
{
"," OrderExpression
}
.
OrderExpression
(. Expression orderExpr = null; .) =
Expr<out orderExpr>
[
"Ascending"
| "Descending"
]
.
GroupByQueryOperator
(. .) =
"Group" ExpressionRangeVariableDeclarationList "By" ExpressionRangeVariableDeclarationList
"Into" ExpressionRangeVariableDeclarationList
.
GroupJoinQueryOperator
(. .) =
"Group" JoinQueryOperator
"Into" ExpressionRangeVariableDeclarationList
.
FromQueryOperator
(. .) =
"From" CollectionRangeVariableDeclarationList
.
SelectQueryOperator
(. .) =
"Select" ExpressionRangeVariableDeclarationList
.
DistinctQueryOperator
(. .) =
"Distinct"
.
WhereQueryOperator
(. Expression operand = null; .) =
"Where" Expr<out operand>
.
PartitionQueryOperator
(. Expression expr = null; .) =
"Take" [ "While" ] Expr<out expr>
| "Skip" [ "While" ] Expr<out expr>
.
AggregateQueryOperator
(. .) =
"Aggregate" CollectionRangeVariableDeclaration { QueryOperator }
"Into" ExpressionRangeVariableDeclarationList
.
LetQueryOperator
(. .) =
"Let" ExpressionRangeVariableDeclarationList
.
ExpressionRangeVariableDeclarationList
(. .) =
ExpressionRangeVariableDeclaration
{ "," ExpressionRangeVariableDeclaration }
.
ExpressionRangeVariableDeclaration
(.
Expression rhs = null;
TypeReference typeName = null;
.) =
[ IF(IsIdentifiedExpressionRange()) Identifier [ "As" TypeName<out typeName> ] "="
]
Expr<out rhs>
.
JoinQueryOperator
(. .) =
"Join" CollectionRangeVariableDeclaration [ JoinQueryOperator ] "On"
JoinCondition
{
"And" JoinCondition
}
.
CollectionRangeVariableDeclarationList
(. .) =
CollectionRangeVariableDeclaration
{ "," CollectionRangeVariableDeclaration }
.
CollectionRangeVariableDeclaration
(.
TypeReference typeName = null;
Expression inExpr = null;
.) =
Identifier
[ "As" TypeName<out typeName> ] "In" Expr<out inExpr>
.
JoinCondition
(.
Expression lhs = null;
Expression rhs = null;
.) =
Expr<out lhs> "Equals" Expr<out rhs>
.
MemberInitializer<out NamedArgumentExpression memberInitializer>
(.
memberInitializer = new NamedArgumentExpression();

15
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs

@ -105,6 +105,21 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -105,6 +105,21 @@ namespace ICSharpCode.NRefactory.Parser.VB
return la.kind == Tokens.Dot && (peek == Tokens.Identifier || peek >= Tokens.AddHandler);
}
static bool IsIdentifierToken(Token tk)
{
return Tokens.IdentifierTokens[tk.kind] || tk.kind == Tokens.Identifier;
}
bool IsIdentifiedExpressionRange()
{
return la.kind == Tokens.As || la.kind == Tokens.Assign;
}
bool IsQueryExpression()
{
return (la.kind == Tokens.From || la.kind == Tokens.Aggregate) && IsIdentifierToken(Peek(1));
}
bool IsEndStmtAhead()
{
int peek = Peek(1).kind;

Loading…
Cancel
Save