// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#nullable enable
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
///
/// query_expression ::= query_clause+ (C# grammar §12.23.1)
///
[DecompilerAstNode(hasNullNode: true)]
public partial class QueryExpression : Expression
{
public static readonly Role ClauseRole = new Role("Clause", null);
[Slot("ClauseRole")]
public partial AstNodeCollection Clauses { get; }
}
public abstract class QueryClause : AstNode
{
}
///
/// Represents a query continuation, e.g. "(from .. select ..) into Identifier".
/// Note that "join .. into .." is not a query continuation.
/// A continuation is always the first clause of the query expression that contains it.
/// query_continuation ::= query_expression 'into' identifier (C# grammar §12.23.1)
///
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryContinuationClause : QueryClause
{
public static readonly Role PrecedingQueryRole = new Role("PrecedingQuery", null);
public static readonly TokenRole IntoKeywordRole = new TokenRole("into");
[Slot("PrecedingQueryRole")]
public partial QueryExpression PrecedingQuery { get; set; }
[NameSlot("Roles.Identifier")]
public partial string Identifier { get; set; }
}
///
/// from_clause ::= 'from' type? identifier 'in' expression (C# grammar §12.23.1)
///
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryFromClause : QueryClause
{
public static readonly TokenRole FromKeywordRole = new TokenRole("from");
public static readonly TokenRole InKeywordRole = new TokenRole("in");
[Slot("Roles.Type")]
public partial AstType? Type { get; set; }
[NameSlot("Roles.Identifier")]
public partial string Identifier { get; set; }
[Slot("Roles.Expression")]
public partial Expression Expression { get; set; }
}
///
/// let_clause ::= 'let' identifier '=' expression (C# grammar §12.23.1)
///
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryLetClause : QueryClause
{
public readonly static TokenRole LetKeywordRole = new TokenRole("let");
[NameSlot("Roles.Identifier")]
public partial string Identifier { get; set; }
[Slot("Roles.Expression")]
public partial Expression Expression { get; set; }
}
///
/// where_clause ::= 'where' expression (C# grammar §12.23.1)
///
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryWhereClause : QueryClause
{
public readonly static TokenRole WhereKeywordRole = new TokenRole("where");
[Slot("Roles.Condition")]
public partial Expression Condition { get; set; }
}
///
/// Represents a join or group join clause.
///
/// join_clause ::=
/// 'join' type? identifier 'in' expression 'on' expression 'equals' expression
/// | 'join' type? identifier 'in' expression 'on' expression 'equals' expression 'into' identifier
///
/// (C# grammar §12.23.1)
///
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryJoinClause : QueryClause
{
public static readonly TokenRole JoinKeywordRole = new TokenRole("join");
public static readonly Role TypeRole = Roles.Type;
public static readonly Role JoinIdentifierRole = Roles.Identifier;
public static readonly TokenRole InKeywordRole = new TokenRole("in");
public static readonly Role InExpressionRole = Roles.Expression;
public static readonly TokenRole OnKeywordRole = new TokenRole("on");
public static readonly Role OnExpressionRole = new Role("OnExpression", null);
public static readonly TokenRole EqualsKeywordRole = new TokenRole("equals");
public static readonly Role EqualsExpressionRole = new Role("EqualsExpression", null);
public static readonly TokenRole IntoKeywordRole = new TokenRole("into");
public static readonly Role IntoIdentifierRole = new Role("IntoIdentifier", null);
// Derived from IntoIdentifier (which DoMatch already compares); exclude it to avoid a redundant compare.
[ExcludeFromMatch]
public bool IsGroupJoin {
get { return !string.IsNullOrEmpty(this.IntoIdentifier); }
}
[Slot("TypeRole")]
public partial AstType? Type { get; set; }
[NameSlot("JoinIdentifierRole")]
public partial string JoinIdentifier { get; set; }
[Slot("InExpressionRole")]
public partial Expression InExpression { get; set; }
[Slot("OnExpressionRole")]
public partial Expression OnExpression { get; set; }
[Slot("EqualsExpressionRole")]
public partial Expression EqualsExpression { get; set; }
[NameSlot("IntoIdentifierRole", nullOnEmpty: true)]
public partial string IntoIdentifier { get; set; }
}
///
/// orderby_clause ::= 'orderby' ordering ( ',' ordering )* (C# grammar §12.23.1)
///
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryOrderClause : QueryClause
{
public static readonly TokenRole OrderbyKeywordRole = new TokenRole("orderby");
public static readonly Role OrderingRole = new Role("Ordering", null);
[Slot("OrderingRole")]
public partial AstNodeCollection Orderings { get; }
}
///
/// ordering ::= expression ( 'ascending' | 'descending' )? (C# grammar §12.23.1)
///
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryOrdering : AstNode
{
public readonly static TokenRole AscendingKeywordRole = new TokenRole("ascending");
public readonly static TokenRole DescendingKeywordRole = new TokenRole("descending");
[Slot("Roles.Expression")]
public partial Expression Expression { get; set; }
public QueryOrderingDirection Direction {
get;
set;
}
}
public enum QueryOrderingDirection
{
None,
Ascending,
Descending
}
///
/// select_clause ::= 'select' expression (C# grammar §12.23.1)
///
[DecompilerAstNode(hasNullNode: false)]
public partial class QuerySelectClause : QueryClause
{
public readonly static TokenRole SelectKeywordRole = new TokenRole("select");
[Slot("Roles.Expression")]
public partial Expression Expression { get; set; }
}
///
/// group_clause ::= 'group' expression 'by' expression (C# grammar §12.23.1)
///
[DecompilerAstNode(hasNullNode: false)]
public partial class QueryGroupClause : QueryClause
{
public static readonly TokenRole GroupKeywordRole = new TokenRole("group");
public static readonly Role ProjectionRole = new Role("Projection", null);
public static readonly TokenRole ByKeywordRole = new TokenRole("by");
public static readonly Role KeyRole = new Role("Key", null);
[Slot("ProjectionRole")]
public partial Expression Projection { get; set; }
[Slot("KeyRole")]
public partial Expression Key { get; set; }
}
}