Skip to content

Commit a14e8c3

Browse files
committed
fix: handle whitespace at the end of the query
1 parent 32620de commit a14e8c3

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/grammar.ne

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@preprocessor typescript
22

3-
main -> _ logical_expression {% (data) => data[1] %}
3+
main -> _ logical_expression _ {% (data) => data[1] %}
44

55
# Whitespace: `_` is optional, `__` is mandatory.
66
_ -> whitespace_character:* {% (data) => data[0].length %}

src/grammar.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ interface Grammar {
3434
const grammar: Grammar = {
3535
Lexer: undefined,
3636
ParserRules: [
37-
{"name": "main", "symbols": ["_", "logical_expression"], "postprocess": (data) => data[1]},
37+
{"name": "main", "symbols": ["_", "logical_expression", "_"], "postprocess": (data) => data[1]},
3838
{"name": "_$ebnf$1", "symbols": []},
3939
{"name": "_$ebnf$1", "symbols": ["_$ebnf$1", "whitespace_character"], "postprocess": (d) => d[0].concat([d[1]])},
4040
{"name": "_", "symbols": ["_$ebnf$1"], "postprocess": (data) => data[0].length},

test/liqe/parse.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ test('foo with whitespace at the start', (t) => {
151151
});
152152

153153
test('foo with whitespace at the end', (t) => {
154-
t.deepEqual(parse('foo'), {
154+
t.deepEqual(parse('foo '), {
155155
expression: {
156156
location: {
157157
end: 3,

0 commit comments

Comments
 (0)