Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Ramstack.ExpressionParser/ExpressionParser.Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static Parser<Expr> CreateParser()
var expression_list =
expression
.Separated(
Seq(L(','), S)).As("expression_list");
Seq(L(','), S));

// Member access, calls, and indexers share one precedence level, so each of them
// is parsed as a postfix operator that wraps the expression to its left.
Expand All @@ -146,7 +146,7 @@ private static Parser<Expr> CreateParser()
expression
.Separated(
Seq(L(','), S),
min: 1).As("expression")
min: 1)
.Between(
Seq(L('['), S),
Seq(L(']'), S))
Expand Down
31 changes: 26 additions & 5 deletions tests/Ramstack.ExpressionParser.Tests/Data/Errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Non-invocable member 'maxvalue' cannot be used like a method.
(1:11) Expected '(', '[', '.', ':>', [%*/], [+-], '<<', '>>', '>>>', '<', '>', '<=', '>=', '==', '!=', '&', '^', '|', '&&', '||', '??', '?', or ')'

1 + 2 * 3(
(1:11) Expected ')'
(1:11) Expected [!+\-~], double-quoted string, quoted-character, 'true', 'false', 'null', identifier, '(', or ')'

1 + 2 * 3(2)
Method name expected (expression: 3).
Expand All @@ -68,7 +68,7 @@ Method name expected (expression: 3).
Cannot apply indexing with [] to an expression of type 'System.Int32'.

1 + 2 * 3[
(1:11) Expected expression
(1:11) Expected [!+\-~], double-quoted string, quoted-character, 'true', 'false', 'null', identifier, or '('

1 + 2 * 3]
(1:10) Expected '(', '[', '.', ':>', [%*/], [+-], '<<', '>>', '>>>', '<', '>', '<=', '>=', '==', '!=', '&', '^', '|', '&&', '||', '??', '?', or end of input
Expand Down Expand Up @@ -101,17 +101,38 @@ Cannot apply indexing with [] to an expression of type 'System.Int32'.
(1:2) Expected '(', '[', '.', ':>', [%*/], [+-], '<<', '>>', '>>>', '<', '>', '<=', '>=', '==', '!=', '&', '^', '|', '&&', '||', '??', '?', or end of input

"test"[]
(1:8) Expected expression
(1:8) Expected [!+\-~], double-quoted string, quoted-character, 'true', 'false', 'null', identifier, or '('

"test"[ ]
(1:9) Expected expression
(1:9) Expected [!+\-~], double-quoted string, quoted-character, 'true', 'false', 'null', identifier, or '('

"test".Split(',')[]
(1:19) Expected expression
(1:19) Expected [!+\-~], double-quoted string, quoted-character, 'true', 'false', 'null', identifier, or '('

"test"["a"]
Ambiguous match found:\n Char Chars [Int32] (in System.String)

"test".ToString(1,)
(1:19) Expected [!+\-~], double-quoted string, quoted-character, 'true', 'false', 'null', identifier, or '('

Math.Max(1, (2 + ))
(1:18) Expected [!+\-~], double-quoted string, quoted-character, 'true', 'false', 'null', identifier, or '('

"test"[0,]
(1:10) Expected [!+\-~], double-quoted string, quoted-character, 'true', 'false', 'null', identifier, or '('

"test"[(]
(1:9) Expected [!+\-~], double-quoted string, quoted-character, 'true', 'false', 'null', identifier, or '('

"test"[1 +]
(1:11) Expected [!+\-~], double-quoted string, quoted-character, 'true', 'false', 'null', identifier, or '('

"test"[0
(1:9) Expected '(', '[', '.', ':>', [%*/], [+-], '<<', '>>', '>>>', '<', '>', '<=', '>=', '==', '!=', '&', '^', '|', '&&', '||', '??', '?', ',', or ']'

Math.Max(1, 2
(1:14) Expected '(', '[', '.', ':>', [%*/], [+-], '<<', '>>', '>>>', '<', '>', '<=', '>=', '==', '!=', '&', '^', '|', '&&', '||', '??', '?', ',', or ')'

StringSplitOptions.None | StringComparison.Ordinal
Operator '|' cannot be applied to operands of type 'System.StringSplitOptions' and 'System.StringComparison'.

Expand Down