From 5bb19a8355890d6334d8fa4456da0a7ec455e0e1 Mon Sep 17 00:00:00 2001 From: Gajus Kuizinas Date: Sat, 1 Oct 2022 19:56:51 -0500 Subject: [PATCH] fix: support single character --- src/grammar.ne | 2 +- src/grammar.ts | 2 +- test/liqe/parse.ts | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/grammar.ne b/src/grammar.ne index d78a0cf..4a2efad 100644 --- a/src/grammar.ne +++ b/src/grammar.ne @@ -292,4 +292,4 @@ regex_flags -> [gmiyusd]:+ {% d => d[0].join('') %} unquoted_value -> - [a-zA-Z_*@#$] [a-zA-Z\.\-_*@#$]:+ {% d => d[0] + d[1].join('') %} \ No newline at end of file + [a-zA-Z_*@#$] [a-zA-Z\.\-_*@#$]:* {% d => d[0] + d[1].join('') %} \ No newline at end of file diff --git a/src/grammar.ts b/src/grammar.ts index d6508eb..e86d7ac 100644 --- a/src/grammar.ts +++ b/src/grammar.ts @@ -298,7 +298,7 @@ const grammar: Grammar = { {"name": "regex_flags$ebnf$1", "symbols": [/[gmiyusd]/]}, {"name": "regex_flags$ebnf$1", "symbols": ["regex_flags$ebnf$1", /[gmiyusd]/], "postprocess": (d) => d[0].concat([d[1]])}, {"name": "regex_flags", "symbols": ["regex_flags$ebnf$1"], "postprocess": d => d[0].join('')}, - {"name": "unquoted_value$ebnf$1", "symbols": [/[a-zA-Z\.\-_*@#$]/]}, + {"name": "unquoted_value$ebnf$1", "symbols": []}, {"name": "unquoted_value$ebnf$1", "symbols": ["unquoted_value$ebnf$1", /[a-zA-Z\.\-_*@#$]/], "postprocess": (d) => d[0].concat([d[1]])}, {"name": "unquoted_value", "symbols": [/[a-zA-Z_*@#$]/, "unquoted_value$ebnf$1"], "postprocess": d => d[0] + d[1].join('')} ], diff --git a/test/liqe/parse.ts b/test/liqe/parse.ts index 1c5092b..5e64e0e 100644 --- a/test/liqe/parse.ts +++ b/test/liqe/parse.ts @@ -378,6 +378,41 @@ test('foo:bar', testQuery, { type: 'Tag', }); +test('foo:b', testQuery, { + expression: { + location: { + end: 5, + start: 4, + }, + quoted: false, + type: 'LiteralExpression', + value: 'b', + }, + field: { + location: { + end: 3, + start: 0, + }, + name: 'foo', + path: ['foo'], + quoted: false, + type: 'Field', + }, + location: { + end: 5, + start: 0, + }, + operator: { + location: { + end: 4, + start: 3, + }, + operator: ':', + type: 'ComparisonOperator', + }, + type: 'Tag', +}); + test('foo:bar@baz.com', testQuery, { expression: { location: {