Skip to content

Commit 00deae8

Browse files
committed
fix: support non-English characters (fixes #34)
1 parent fe42d04 commit 00deae8

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

Diff for: src/grammar.ne

+1-1
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-Z0-9\.\-_*?@#$]:* {% d => d[0] + d[1].join('') %}
295+
[a-zA-Z_*?@#$\u0080-\uFFFF] [a-zA-Z0-9\.\-_*?@#$\u0080-\uFFFF]:* {% d => d[0] + d[1].join('') %}

Diff for: src/grammar.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -771,12 +771,12 @@ const grammar: Grammar = {
771771
{
772772
name: 'unquoted_value$ebnf$1',
773773
postprocess: (d) => d[0].concat([d[1]]),
774-
symbols: ['unquoted_value$ebnf$1', /[\w#$*.?@\-]/],
774+
symbols: ['unquoted_value$ebnf$1', /[\w#$*.?@\u0080-\uFFFF\-]/],
775775
},
776776
{
777777
name: 'unquoted_value',
778778
postprocess: (d) => d[0] + d[1].join(''),
779-
symbols: [/[#$*?@A-Z_a-z]/, 'unquoted_value$ebnf$1'],
779+
symbols: [/[#$*?@A-Z_a-z\u0080-\uFFFF]/, 'unquoted_value$ebnf$1'],
780780
},
781781
],
782782
ParserStart: 'main',

Diff for: test/liqe/parse.ts

+55
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,26 @@ test('foo123', testQuery, {
144144
type: 'Tag',
145145
});
146146

147+
test('测试', testQuery, {
148+
expression: {
149+
location: {
150+
end: 2,
151+
start: 0,
152+
},
153+
quoted: false,
154+
type: 'LiteralExpression',
155+
value: '测试',
156+
},
157+
field: {
158+
type: 'ImplicitField',
159+
},
160+
location: {
161+
end: 2,
162+
start: 0,
163+
},
164+
type: 'Tag',
165+
});
166+
147167
test('foo with whitespace at the start', (t) => {
148168
t.deepEqual(parse(' foo'), {
149169
expression: {
@@ -547,6 +567,41 @@ test('foo:bar123', testQuery, {
547567
type: 'Tag',
548568
});
549569

570+
test('foo:测试', testQuery, {
571+
expression: {
572+
location: {
573+
end: 6,
574+
start: 4,
575+
},
576+
quoted: false,
577+
type: 'LiteralExpression',
578+
value: '测试',
579+
},
580+
field: {
581+
location: {
582+
end: 3,
583+
start: 0,
584+
},
585+
name: 'foo',
586+
path: ['foo'],
587+
quoted: false,
588+
type: 'Field',
589+
},
590+
location: {
591+
end: 6,
592+
start: 0,
593+
},
594+
operator: {
595+
location: {
596+
end: 4,
597+
start: 3,
598+
},
599+
operator: ':',
600+
type: 'ComparisonOperator',
601+
},
602+
type: 'Tag',
603+
});
604+
550605
// https://github.com/gajus/liqe/issues/18
551606
// https://github.com/gajus/liqe/issues/19
552607
test.skip('foo: bar', testQuery, {

0 commit comments

Comments
 (0)