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

Appearance settings

Commit cb3bf77

Browse filesBrowse files
committed
implement C-like comments
1 parent 4700382 commit cb3bf77
Copy full SHA for cb3bf77

File tree

3 files changed

+34
-10
lines changed
Filter options

3 files changed

+34
-10
lines changed

‎expected/jsquery.out

Copy file name to clipboardExpand all lines: expected/jsquery.out
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ select 'asd(zzz < 13 & x.zxc = "true")'::jsquery;
3838
"asd"("zzz" < 13 & "x"."zxc" = "true")
3939
(1 row)
4040

41-
select 'asd(zzz < 13 | #.zxc = "true")'::jsquery;
41+
select 'asd(zzz < 13 | #.zxc = "true" /* test */)'::jsquery;
4242
jsquery
4343
--------------------------------------
4444
"asd"("zzz" < 13 | #."zxc" = "true")
4545
(1 row)
4646

47-
select 'asd(* < 13 & #.zxc = "true")'::jsquery;
47+
select 'asd(* < 13 & /* ttt */ #.zxc = "true")'::jsquery;
4848
jsquery
4949
----------------------------------
5050
"asd"(* < 13 & #."zxc" = "true")
@@ -56,12 +56,17 @@ select '(* < 13 & #.zxc = "true")'::jsquery;
5656
(* < 13 & #."zxc" = "true")
5757
(1 row)
5858

59-
select '* < 13 & #.zxc = "true"'::jsquery;
59+
select '* < 13 & #.zxc/* t2 */ = "true"'::jsquery;
6060
jsquery
6161
-----------------------------
6262
(* < 13 & #."zxc" = "true")
6363
(1 row)
6464

65+
select '* < 13 & #.zxc"x" = "true"'::jsquery;
66+
ERROR: bad jsquery representation
67+
LINE 1: select '* < 13 & #.zxc"x" = "true"'::jsquery;
68+
^
69+
DETAIL: syntax error, unexpected STRING_P at or near """
6570
select 'a < 1'::jsquery;
6671
jsquery
6772
---------

‎jsquery_scan.l

Copy file name to clipboardExpand all lines: jsquery_scan.l
+22-4Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ static void parseUnicode(char *s, int l);
4545

4646
%x xQUOTED
4747
%x xNONQUOTED
48+
%x xCOMMENT
4849

4950
special [\%\$\.\[\]\(\)\|\&\!\=\<\>\@\#\,\*]
50-
any [^\%\$\.\[\]\(\)\|\&\!\=\<\>\@\#\,\* \t\n\r\f\\\"]
51+
any [^\%\$\.\[\]\(\)\|\&\!\=\<\>\@\#\,\* \t\n\r\f\\\"\/]
5152
blank [ \t\n\r\f]
5253
unicode \\u[0-9A-Fa-f]{4}
5354
@@ -57,6 +58,8 @@ unicode \\u[0-9A-Fa-f]{4}
5758
5859
<INITIAL>{blank}+ { /* ignore */ }
5960
61+
<INITIAL>\/\* { BEGIN xCOMMENT; }
62+
6063
<INITIAL>[+-]?[0-9]+(\.[0-9]+)?[eE][+-]?[0-9]+ /* float */ {
6164
addstring(true, yytext, yyleng);
6265
addchar(false, '\0');
@@ -113,6 +116,15 @@ unicode \\u[0-9A-Fa-f]{4}
113116
}
114117
115118
119+
<xNONQUOTED>\/\* {
120+
yylval->str = scanstring;
121+
BEGIN xCOMMENT;
122+
return checkSpecialVal();
123+
}
124+
125+
126+
<xNONQUOTED,INITIAL>\/ { addchar(false, '/'); }
127+
116128
<xNONQUOTED>({special}|\") {
117129
yylval->str = scanstring;
118130
yyless(0);
@@ -126,9 +138,7 @@ unicode \\u[0-9A-Fa-f]{4}
126138
return checkSpecialVal();
127139
}
128140
129-
<xNONQUOTED,xQUOTED>\\[\"\\] {
130-
addchar(false, yytext[1]);
131-
}
141+
<xNONQUOTED,xQUOTED>\\[\"\\] { addchar(false, yytext[1]); }
132142
133143
<xNONQUOTED,xQUOTED>\\b { addchar(false, '\b'); }
134144
@@ -160,6 +170,14 @@ unicode \\u[0-9A-Fa-f]{4}
160170
161171
<INITIAL><<EOF>> { yyterminate(); }
162172
173+
<xCOMMENT>\*\/ { BEGIN INITIAL; }
174+
175+
<xCOMMENT>[^\*]+ { /* ignore */ }
176+
177+
<xCOMMENT>\* { /* ignore */ }
178+
179+
<xCOMMENT><<EOF>> { yyerror("Unexpected end of comment"); }
180+
163181
%%
164182
165183
void

‎sql/jsquery.sql

Copy file name to clipboardExpand all lines: sql/jsquery.sql
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ select 'asd(zzz < 13)'::jsquery;
1212
select 'asd(zzz < 13 & x = true)'::jsquery;
1313
select 'asd(zzz < 13 & x = "true")'::jsquery;
1414
select 'asd(zzz < 13 & x.zxc = "true")'::jsquery;
15-
select 'asd(zzz < 13 | #.zxc = "true")'::jsquery;
16-
select 'asd(* < 13 & #.zxc = "true")'::jsquery;
15+
select 'asd(zzz < 13 | #.zxc = "true" /* test */)'::jsquery;
16+
select 'asd(* < 13 & /* ttt */ #.zxc = "true")'::jsquery;
1717
select '(* < 13 & #.zxc = "true")'::jsquery;
18-
select '* < 13 & #.zxc = "true"'::jsquery;
18+
select '* < 13 & #.zxc/* t2 */ = "true"'::jsquery;
19+
select '* < 13 & #.zxc"x" = "true"'::jsquery;
1920

2021
select 'a < 1'::jsquery;
2122
select 'a < -1'::jsquery;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.