Skip to content

Commit 292f0bc

Browse files
authored
fix: allow unquoted terms with numbers (e.g. foo123) (#36)
1 parent d70ec84 commit 292f0bc

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

src/grammar.ne

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,4 @@ regex_flags ->
292292
[gmiyusd]:+ {% d => d[0].join('') %}
293293

294294
unquoted_value ->
295-
[a-zA-Z_*?@#$] [a-zA-Z\.\-_*?@#$]:* {% d => d[0] + d[1].join('') %}
295+
[a-zA-Z_*?@#$] [a-zA-Z0-9\.\-_*?@#$]:* {% d => d[0] + d[1].join('') %}

src/grammar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ const grammar: Grammar = {
299299
{"name": "regex_flags$ebnf$1", "symbols": ["regex_flags$ebnf$1", /[gmiyusd]/], "postprocess": (d) => d[0].concat([d[1]])},
300300
{"name": "regex_flags", "symbols": ["regex_flags$ebnf$1"], "postprocess": d => d[0].join('')},
301301
{"name": "unquoted_value$ebnf$1", "symbols": []},
302-
{"name": "unquoted_value$ebnf$1", "symbols": ["unquoted_value$ebnf$1", /[a-zA-Z\.\-_*?@#$]/], "postprocess": (d) => d[0].concat([d[1]])},
302+
{"name": "unquoted_value$ebnf$1", "symbols": ["unquoted_value$ebnf$1", /[a-zA-Z0-9\.\-_*?@#$]/], "postprocess": (d) => d[0].concat([d[1]])},
303303
{"name": "unquoted_value", "symbols": [/[a-zA-Z_*?@#$]/, "unquoted_value$ebnf$1"], "postprocess": d => d[0] + d[1].join('')}
304304
],
305305
ParserStart: "main",

test/liqe/parse.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,26 @@ test('foo', testQuery, {
128128
type: 'Tag',
129129
});
130130

131+
test('foo123', testQuery, {
132+
expression: {
133+
location: {
134+
end: 6,
135+
start: 0,
136+
},
137+
quoted: false,
138+
type: 'LiteralExpression',
139+
value: 'foo123',
140+
},
141+
field: {
142+
type: 'ImplicitField',
143+
},
144+
location: {
145+
end: 6,
146+
start: 0,
147+
},
148+
type: 'Tag',
149+
});
150+
131151
test('foo with whitespace at the start', (t) => {
132152
t.deepEqual(parse(' foo'), {
133153
expression: {
@@ -492,6 +512,41 @@ test('foo:bar@baz.com', testQuery, {
492512
type: 'Tag',
493513
});
494514

515+
test('foo:bar123', testQuery, {
516+
expression: {
517+
location: {
518+
end: 10,
519+
start: 4,
520+
},
521+
quoted: false,
522+
type: 'LiteralExpression',
523+
value: 'bar123',
524+
},
525+
field: {
526+
location: {
527+
end: 3,
528+
start: 0,
529+
},
530+
name: 'foo',
531+
path: ['foo'],
532+
quoted: false,
533+
type: 'Field',
534+
},
535+
location: {
536+
end: 10,
537+
start: 0,
538+
},
539+
operator: {
540+
location: {
541+
end: 4,
542+
start: 3,
543+
},
544+
operator: ':',
545+
type: 'ComparisonOperator',
546+
},
547+
type: 'Tag',
548+
});
549+
495550
// https://github.com/gajus/liqe/issues/18
496551
// https://github.com/gajus/liqe/issues/19
497552
test.skip('foo: bar', testQuery, {

0 commit comments

Comments
 (0)