Skip to content

Commit b03b627

Browse files
committed
Remove trailing whitespace and normalize line endings
1 parent e273ced commit b03b627

File tree

9 files changed

+181
-187
lines changed

9 files changed

+181
-187
lines changed

src/Ramstack.ExpressionParser/Binder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public abstract class Binder
1818
/// </summary>
1919
/// <param name="name">The <see cref="Identifier"/> representing the name of the requested type.</param>
2020
/// <returns>
21-
/// The <see cref="Type"/> instance corresponding to the specified <paramref name="name"/>
21+
/// The <see cref="Type"/> instance corresponding to the specified <paramref name="name"/>
2222
/// if resolved successfully; otherwise, <see langword="null"/>.
2323
/// </returns>
2424
public abstract Type? BindToType(Identifier name);

src/Ramstack.ExpressionParser/ExpressionBuilder.Helpers.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@ private static List<Expression> CreateInjectingArguments(MethodInfo method, IRea
7171
var paramArrayType = parameter.ParameterType.GetElementType()!;
7272

7373
for (; i < args.Count; i++)
74-
paramArray.Add(Convert(args[i], paramArrayType));
74+
paramArray.Add(
75+
Convert(args[i], paramArrayType));
76+
77+
list.Add(
78+
Expression.NewArrayInit(
79+
paramArrayType,
80+
paramArray));
7581

76-
list.Add(Expression.NewArrayInit(paramArrayType, paramArray));
7782
break;
7883
}
7984

@@ -128,35 +133,35 @@ private static Expression ApplyBinaryExpression(Identifier op, Func<Expression,
128133
{
129134
if (!TypeUtils.IsInteger(lhs.Type) && TypeUtils.IsInteger(rhs.Type))
130135
Error.NonApplicableBinaryOperator(op, lhs.Type, rhs.Type);
131-
136+
132137
if (rhs.Type == typeof(sbyte)
133138
|| rhs.Type == typeof(byte)
134139
|| rhs.Type == typeof(short)
135140
|| rhs.Type == typeof(ushort))
136141
rhs = Expression.Convert(rhs, typeof(int));
137-
142+
138143
if (rhs.Type != typeof(int))
139144
Error.NonApplicableBinaryOperator(op, lhs.Type, rhs.Type);
140-
145+
141146
if (lhs.Type == typeof(sbyte)
142147
|| lhs.Type == typeof(byte)
143148
|| lhs.Type == typeof(short)
144149
|| lhs.Type == typeof(ushort))
145150
lhs = Expression.Convert(lhs, typeof(int));
146-
151+
147152
if (op.Name == ">>>")
148153
{
149154
if (lhs.Type == typeof(int))
150155
return Expression.Convert(
151156
apply(Expression.Convert(lhs, typeof(uint)), rhs),
152157
typeof(int));
153-
158+
154159
if (lhs.Type == typeof(long))
155160
return Expression.Convert(
156161
apply(Expression.Convert(lhs, typeof(ulong)), rhs),
157162
typeof(long));
158163
}
159-
164+
160165
return apply(lhs, rhs);
161166
}
162167

src/Ramstack.ExpressionParser/Expressions/Expr.Unary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace Ramstack.Parsing.Expressions;
33
partial class Expr
44
{
55
/// <summary>
6-
/// Represents an unary operation expression in an expression tree, consisting of an operator and a single operand.
6+
/// Represents a unary operation expression in an expression tree, consisting of an operator and a single operand.
77
/// </summary>
88
/// <param name="operator">The <see cref="Identifier"/> representing the unary operator, e.g., <c>"-"</c> or <c>"int"</c>.</param>
99
/// <param name="unaryType">The <see cref="UnaryType"/> specifying the kind of unary operation (e.g., arithmetic or conversion).</param>
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
namespace Ramstack.Parsing.Expressions;
2-
3-
/// <summary>
4-
/// Represents a node in an expression tree, serving as the base class for all expression types.
5-
/// </summary>
6-
public abstract partial class Expr(ExprKind kind)
7-
{
8-
/// <summary>
9-
/// Gets the kind of this expression node.
10-
/// </summary>
11-
/// <value>
12-
/// An <see cref="ExprKind"/> value indicating the type of expression, such as a literal, binary operation, or reference.
13-
/// </value>
14-
public ExprKind Kind { get; init; } = kind;
15-
16-
/// <summary>
17-
/// Deconstructs the expression into its kind.
18-
/// </summary>
19-
/// <param name="kind">The <see cref="ExprKind"/> of this expression node, output as an enumeration value.</param>
20-
public void Deconstruct(out ExprKind kind) =>
21-
kind = Kind;
22-
23-
/// <summary>
24-
/// Accepts a visitor to process this expression node and return a result of type <typeparamref name="T"/>.
25-
/// </summary>
26-
/// <typeparam name="T">The type of the result produced by the visitor.</typeparam>
27-
/// <param name="visitor">The <see cref="ExprVisitor{T}"/> instance that processes this expression.</param>
28-
/// <returns>
29-
/// A result of type <typeparamref name="T"/> as determined by the visitor's implementation.
30-
/// </returns>
31-
public abstract T Accept<T>(ExprVisitor<T> visitor);
32-
}
1+
namespace Ramstack.Parsing.Expressions;
2+
3+
/// <summary>
4+
/// Represents a node in an expression tree, serving as the base class for all expression types.
5+
/// </summary>
6+
public abstract partial class Expr(ExprKind kind)
7+
{
8+
/// <summary>
9+
/// Gets the kind of this expression node.
10+
/// </summary>
11+
/// <value>
12+
/// An <see cref="ExprKind"/> value indicating the type of expression, such as a literal, binary operation, or reference.
13+
/// </value>
14+
public ExprKind Kind { get; init; } = kind;
15+
16+
/// <summary>
17+
/// Deconstructs the expression into its kind.
18+
/// </summary>
19+
/// <param name="kind">The <see cref="ExprKind"/> of this expression node, output as an enumeration value.</param>
20+
public void Deconstruct(out ExprKind kind) =>
21+
kind = Kind;
22+
23+
/// <summary>
24+
/// Accepts a visitor to process this expression node and return a result of type <typeparamref name="T"/>.
25+
/// </summary>
26+
/// <typeparam name="T">The type of the result produced by the visitor.</typeparam>
27+
/// <param name="visitor">The <see cref="ExprVisitor{T}"/> instance that processes this expression.</param>
28+
/// <returns>
29+
/// A result of type <typeparamref name="T"/> as determined by the visitor's implementation.
30+
/// </returns>
31+
public abstract T Accept<T>(ExprVisitor<T> visitor);
32+
}
Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,79 @@
1-
namespace Ramstack.Parsing.Expressions;
2-
3-
/// <summary>
4-
/// Defines the possible types of nodes in an expression tree used by the expression parser.
5-
/// </summary>
6-
public enum ExprKind
7-
{
8-
/// <summary>
9-
/// Represents a reference to a variable, parameter, or member in the expression.
10-
/// </summary>
11-
/// <example>
12-
/// In the expression <c>x</c>, this would indicate a reference to the variable "x".
13-
/// </example>
14-
Reference,
15-
16-
/// <summary>
17-
/// Represents a constant value, such as a number or string literal.
18-
/// </summary>
19-
/// <example>
20-
/// In the expression <c>42</c> or <c>"hello"</c>, this denotes a literal value.
21-
/// </example>
22-
Literal,
23-
24-
/// <summary>
25-
/// Represents a binary operation, such as addition or subtraction, involving two operands.
26-
/// </summary>
27-
/// <example>
28-
/// In the expression <c>a + b</c>, this indicates the addition operation.
29-
/// </example>
30-
Binary,
31-
32-
/// <summary>
33-
/// Represents a method invocation within the expression.
34-
/// </summary>
35-
/// <example>
36-
/// In the expression <c>Math.Abs(-5)</c>, this denotes the method call to "Abs".
37-
/// </example>
38-
Call,
39-
40-
/// <summary>
41-
/// Represents an indexing operation or access to a parameterized property.
42-
/// </summary>
43-
/// <example>
44-
/// In the expression <c>array[0]</c>, this indicates an index operation.
45-
/// </example>
46-
Index,
47-
48-
/// <summary>
49-
/// Represents a read operation on a field or property of an object.
50-
/// </summary>
51-
/// <example>
52-
/// In the expression <c>obj.Property</c>, this denotes accessing the "Property" member.
53-
/// </example>
54-
MemberAccess,
55-
56-
/// <summary>
57-
/// Represents a unary operation, such as negation or logical NOT, involving a single operand.
58-
/// </summary>
59-
/// <example>
60-
/// In the expression <c>-x</c>, this indicates the negation operation.
61-
/// </example>
62-
Unary,
63-
64-
/// <summary>
65-
/// Represents a conditional (ternary) operation with a condition, true branch, and false branch.
66-
/// </summary>
67-
/// <example>
68-
/// In the expression <c>a > b ? a : b</c>, this denotes a conditional operation.
69-
/// </example>
70-
Conditional,
71-
72-
/// <summary>
73-
/// Represents an expression enclosed in parentheses to enforce precedence or grouping.
74-
/// </summary>
75-
/// <example>
76-
/// In the expression <c>(a + b)</c>, this indicates a parenthesized sub-expression.
77-
/// </example>
78-
Parenthesized
79-
}
1+
namespace Ramstack.Parsing.Expressions;
2+
3+
/// <summary>
4+
/// Defines the possible types of nodes in an expression tree used by the expression parser.
5+
/// </summary>
6+
public enum ExprKind
7+
{
8+
/// <summary>
9+
/// Represents a reference to a variable, parameter, or member in the expression.
10+
/// </summary>
11+
/// <example>
12+
/// In the expression <c>x</c>, this would indicate a reference to the variable "x".
13+
/// </example>
14+
Reference,
15+
16+
/// <summary>
17+
/// Represents a constant value, such as a number or string literal.
18+
/// </summary>
19+
/// <example>
20+
/// In the expression <c>42</c> or <c>"hello"</c>, this denotes a literal value.
21+
/// </example>
22+
Literal,
23+
24+
/// <summary>
25+
/// Represents a binary operation, such as addition or subtraction, involving two operands.
26+
/// </summary>
27+
/// <example>
28+
/// In the expression <c>a + b</c>, this indicates the addition operation.
29+
/// </example>
30+
Binary,
31+
32+
/// <summary>
33+
/// Represents a method invocation within the expression.
34+
/// </summary>
35+
/// <example>
36+
/// In the expression <c>Math.Abs(-5)</c>, this denotes the method call to "Abs".
37+
/// </example>
38+
Call,
39+
40+
/// <summary>
41+
/// Represents an indexing operation or access to a parameterized property.
42+
/// </summary>
43+
/// <example>
44+
/// In the expression <c>array[0]</c>, this indicates an index operation.
45+
/// </example>
46+
Index,
47+
48+
/// <summary>
49+
/// Represents a read operation on a field or property of an object.
50+
/// </summary>
51+
/// <example>
52+
/// In the expression <c>obj.Property</c>, this denotes accessing the "Property" member.
53+
/// </example>
54+
MemberAccess,
55+
56+
/// <summary>
57+
/// Represents a unary operation, such as negation or logical NOT, involving a single operand.
58+
/// </summary>
59+
/// <example>
60+
/// In the expression <c>-x</c>, this indicates the negation operation.
61+
/// </example>
62+
Unary,
63+
64+
/// <summary>
65+
/// Represents a conditional (ternary) operation with a condition, true branch, and false branch.
66+
/// </summary>
67+
/// <example>
68+
/// In the expression <c>a > b ? a : b</c>, this denotes a conditional operation.
69+
/// </example>
70+
Conditional,
71+
72+
/// <summary>
73+
/// Represents an expression enclosed in parentheses to enforce precedence or grouping.
74+
/// </summary>
75+
/// <example>
76+
/// In the expression <c>(a + b)</c>, this indicates a parenthesized sub-expression.
77+
/// </example>
78+
Parenthesized
79+
}

src/Ramstack.ExpressionParser/Expressions/ExprVisitor.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,8 @@ public abstract class ExprVisitor<T>
1414
/// <returns>
1515
/// A result of type <typeparamref name="T"/> produced by the corresponding visit method.
1616
/// </returns>
17-
public virtual T Visit(Expr expr) => expr.Kind switch
18-
{
19-
ExprKind.Reference => VisitReference((Expr.Reference)expr),
20-
ExprKind.Literal => VisitLiteral((Expr.Literal)expr),
21-
ExprKind.Binary => VisitBinary((Expr.Binary)expr),
22-
ExprKind.Call => VisitCall((Expr.Call)expr),
23-
ExprKind.Index => VisitIndex((Expr.Indexer)expr),
24-
ExprKind.MemberAccess => VisitMemberAccess((Expr.MemberAccess)expr),
25-
ExprKind.Unary => VisitUnary((Expr.Unary)expr),
26-
ExprKind.Conditional => VisitConditional((Expr.Conditional)expr),
27-
ExprKind.Parenthesized => VisitParenthesized((Expr.Parenthesized)expr),
28-
_ => throw new ArgumentOutOfRangeException(nameof(expr))
29-
};
17+
public virtual T Visit(Expr expr) =>
18+
expr.Accept(this);
3019

3120
/// <summary>
3221
/// Visits a list of expressions and returns a collection of results.

0 commit comments

Comments
 (0)