Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbf90a72

Browse files
committed
finalize grammar rework
1 parentfb39796 commitbf90a72

File tree

2 files changed

+43
-44
lines changed

2 files changed

+43
-44
lines changed

‎expected/jsquery.out

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -410,15 +410,17 @@ select 'in < 1'::jsquery;
410410
(1 row)
411411

412412
select 'not is < 1'::jsquery;
413-
ERROR: bad jsquery representation
414-
LINE 1: select 'not is < 1'::jsquery;
415-
^
416-
DETAIL: syntax error, unexpected '<' at or near "<"
413+
jsquery
414+
----------------
415+
NOT ("is" < 1)
416+
(1 row)
417+
417418
select 'not in < 1'::jsquery;
418-
ERROR: bad jsquery representation
419-
LINE 1: select 'not in < 1'::jsquery;
420-
^
421-
DETAIL: syntax error, unexpected '<', expecting '(' at or near "<"
419+
jsquery
420+
----------------
421+
NOT ("in" < 1)
422+
(1 row)
423+
422424
select 'in in (1,2)'::jsquery;
423425
jsquery
424426
----------------

‎jsquery_gram.y

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,18 @@ makeItemList(List *list) {
216216
%token<str>STRING_PNUMERIC_P
217217

218218
%type<value>resultscalar_value
219-
%type<str>key
220219

221220
%type<elems>pathvalue_list
222221

223-
%type<value>path_elempath_elem_anyright_exprexprarray
222+
%type<value>keykey_anyright_exprexprarray
224223

225224
%token<hint>HINT_P
226225

227-
%type<hint>opt_hint
228-
229226
%leftOR_P
230227
%leftAND_P
231228
%rightNOT_P
232229
%nonassocIN_PIS_P
233-
%nonassocXXX
230+
%nonassoc'('')'
234231

235232
/* Grammar follows*/
236233
%%
@@ -262,11 +259,6 @@ scalar_value:
262259
|NUMERIC_P{$$ = makeItemNumeric(&$1); }
263260
;
264261

265-
opt_hint:
266-
HINT_P{$$ =$1; }
267-
|/* EMPTY*/%precXXX{$$ = jsqIndexDefault; }
268-
;
269-
270262
value_list:
271263
scalar_value {$$ = lappend(NIL,$1); }
272264
|value_list','scalar_value{$$ = lappend($1,$3); }
@@ -292,11 +284,17 @@ right_expr:
292284
;
293285

294286
expr:
295-
pathopt_hintright_expr{$3->hint =$2;$$ = makeItemList(lappend($1,$3)); }
287+
pathright_expr{$$ = makeItemList(lappend($1,$2)); }
288+
|pathHINT_Pright_expr{$3->hint =$2;$$ = makeItemList(lappend($1,$3)); }
289+
|NOT_Pexpr {$$ = makeItemUnary(jqiNot,$2); }
290+
/*
291+
* In next two lines NOT_P is a patch actually, not a an
292+
* logical expression.
293+
*/
294+
|NOT_PHINT_Pright_expr{$3->hint =$2;$$ = makeItemList(lappend(lappend(NIL, makeItemKey(&$1)),$3)); }
295+
|NOT_Pright_expr{$$ = makeItemList(lappend(lappend(NIL, makeItemKey(&$1)),$2)); }
296296
|path'('expr')'{$$ = makeItemList(lappend($1,$3)); }
297297
|'('expr')'{$$ =$2; }
298-
|NOT_Pexpr {$$ = makeItemUnary(jqiNot,$2); }
299-
|NOT_Popt_hintright_expr{$3->hint =$2;$$ = makeItemList(lappend(lappend(NIL, makeItemKey(&$1)),$3)); }
300298
|exprAND_Pexpr{$$ = makeItemBinary(jqiAnd,$1,$3); }
301299
|exprOR_Pexpr{$$ = makeItemBinary(jqiOr,$1,$3); }
302300
;
@@ -305,39 +303,38 @@ expr:
305303
* key is always a string, not a bool or numeric
306304
*/
307305
key:
308-
STRING_P{$$ =$1; }
309-
|IN_P{$$ =$1; }
310-
|IS_P{$$ =$1; }
311-
|OR_P{$$ =$1; }
312-
|AND_P{$$ =$1; }
313-
|NULL_P{$$ =$1; }
314-
|TRUE_P{$$ =$1; }
315-
|ARRAY_T{$$ =$1; }
316-
|FALSE_P{$$ =$1; }
317-
|NUMERIC_T{$$ =$1; }
318-
|OBJECT_T{$$ =$1; }
319-
|STRING_T{$$ =$1; }
320-
|BOOLEAN_T{$$ =$1; }
321-
|NUMERIC_P{$$ =$1; }
322-
;
323-
324-
path_elem:
325306
'*'{$$ = makeItemType(jqiAny); }
326307
|'#'{$$ = makeItemType(jqiAnyArray); }
327308
|'%'{$$ = makeItemType(jqiAnyKey); }
328309
|'$'{$$ = makeItemType(jqiCurrent); }
329-
|key{$$ = makeItemKey(&$1); }
310+
|STRING_P{$$ = makeItemKey(&$1); }
311+
|IN_P{$$ = makeItemKey(&$1); }
312+
|IS_P{$$ = makeItemKey(&$1); }
313+
|OR_P{$$ = makeItemKey(&$1); }
314+
|AND_P{$$ = makeItemKey(&$1); }
315+
|NULL_P{$$ = makeItemKey(&$1); }
316+
|TRUE_P{$$ = makeItemKey(&$1); }
317+
|ARRAY_T{$$ = makeItemKey(&$1); }
318+
|FALSE_P{$$ = makeItemKey(&$1); }
319+
|NUMERIC_T{$$ = makeItemKey(&$1); }
320+
|OBJECT_T{$$ = makeItemKey(&$1); }
321+
|STRING_T{$$ = makeItemKey(&$1); }
322+
|BOOLEAN_T{$$ = makeItemKey(&$1); }
323+
|NUMERIC_P{$$ = makeItemKey(&$1); }
330324
;
331325

332-
path_elem_any:
333-
path_elem{$$ =$$; }
326+
/*
327+
* NOT keyword needs separate processing
328+
*/
329+
key_any:
330+
key{$$ =$$; }
334331
|NOT_P{$$ = makeItemKey(&$1); }
335332
;
336333

337334
path:
338-
path_elem{$$ = lappend(NIL,$1); }
339-
|path'.'path_elem_any{$$ = lappend($1,$3); }
340-
|NOT_P'.'path_elem_any{$$ = lappend(lappend(NIL, makeItemKey(&$1)),$3); }
335+
key{$$ = lappend(NIL,$1); }
336+
|path'.'key_any{$$ = lappend($1,$3); }
337+
|NOT_P'.'key_any{$$ = lappend(lappend(NIL, makeItemKey(&$1)),$3); }
341338
;
342339

343340
%%

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp