Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions c/parser.php.lemon
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@

%right AGAINST .
%left BETWEEN BETWEEN_NOT .
%left EQUALS NOTEQUALS LESS GREATER GREATEREQUAL LESSEQUAL .
%left EQUALS NOTEQUALS LESS GREATER GREATEREQUAL LESSEQUAL OP_MATCHES OP_CONTAINS OP_CONTAINED OP_OVERLAPS .
%left AND OR .
%left LIKE ILIKE .
%left BITWISE_AND BITWISE_OR BITWISE_XOR .
%left DIVIDE TIMES MOD .
%left PLUS MINUS .
%left PLUS MINUS OP_CONCAT .
%left IS .
%right IN .
%right NOT BITWISE_NOT .
%left OP_JSON_GET OP_JSON_GET_TEXT OP_JSON_PATH OP_JSON_PATH_TEXT .
%left COMMA .

%include {
Expand Down Expand Up @@ -701,6 +702,42 @@ expr(R) ::= expr(O1) BITWISE_XOR expr(O2) . {
phql_ret_expr(&R, PHQL_T_BITWISE_XOR, &O1, &O2);
}

expr(R) ::= expr(O1) OP_MATCHES expr(O2) . {
phql_ret_expr(&R, PHQL_T_OP_MATCHES, &O1, &O2);
}

expr(R) ::= expr(O1) OP_CONTAINS expr(O2) . {
phql_ret_expr(&R, PHQL_T_OP_CONTAINS, &O1, &O2);
}

expr(R) ::= expr(O1) OP_CONTAINED expr(O2) . {
phql_ret_expr(&R, PHQL_T_OP_CONTAINED, &O1, &O2);
}

expr(R) ::= expr(O1) OP_OVERLAPS expr(O2) . {
phql_ret_expr(&R, PHQL_T_OP_OVERLAPS, &O1, &O2);
}

expr(R) ::= expr(O1) OP_CONCAT expr(O2) . {
phql_ret_expr(&R, PHQL_T_OP_CONCAT, &O1, &O2);
}

expr(R) ::= expr(O1) OP_JSON_GET expr(O2) . {
phql_ret_expr(&R, PHQL_T_OP_JSON_GET, &O1, &O2);
}

expr(R) ::= expr(O1) OP_JSON_GET_TEXT expr(O2) . {
phql_ret_expr(&R, PHQL_T_OP_JSON_GET_TEXT, &O1, &O2);
}

expr(R) ::= expr(O1) OP_JSON_PATH expr(O2) . {
phql_ret_expr(&R, PHQL_T_OP_JSON_PATH, &O1, &O2);
}

expr(R) ::= expr(O1) OP_JSON_PATH_TEXT expr(O2) . {
phql_ret_expr(&R, PHQL_T_OP_JSON_PATH_TEXT, &O1, &O2);
}

expr(R) ::= expr(O1) EQUALS expr(O2) . {
phql_ret_expr(&R, PHQL_T_EQUALS, &O1, &O2);
}
Expand Down
101 changes: 84 additions & 17 deletions c/scanner.re
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) {
case '"':
$yystate = 8;
break 2;
case '#':
$yystate = 319;
break 2;
case '%':
$yystate = 9;
break 2;
Expand Down Expand Up @@ -270,10 +273,6 @@ int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) {
case 6:
$yych = $yyinput[$yycursor];
switch ($yych) {
case '!':
$yycursor += 1;
$yystate = 65;
break 2;
case '=':
$yycursor += 1;
$yystate = 66;
Expand Down Expand Up @@ -354,10 +353,16 @@ int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) {
return 0;

case 18:

token->opcode = PHQL_T_SUB;
return 0;

$yych = $yyinput[$yycursor];
switch ($yych) {
case '>':
$yycursor += 1;
$yystate = 323;
break 2;
default:
$yystate = 324;
break 2;
}
case 19:
$yych = $yyinput[$yycursor];
switch ($yych) {
Expand Down Expand Up @@ -528,6 +533,10 @@ int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) {
$yycursor += 1;
$yystate = 81;
break 2;
case '@':
$yycursor += 1;
$yystate = 327;
break 2;
default:
$yystate = 27;
break 2;
Expand Down Expand Up @@ -1346,11 +1355,6 @@ int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) {
token->opcode = PHQL_T_BITWISE_NOT;
return 0;

case 65:

token->opcode = PHQL_T_TS_NEGATE;
return 0;

case 66:

token->opcode = PHQL_T_NOTEQUALS;
Expand Down Expand Up @@ -1415,7 +1419,7 @@ int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) {
}
case 72:

token->opcode = PHQL_T_TS_AND;
token->opcode = PHQL_T_OP_OVERLAPS;
return 0;

case 73:
Expand Down Expand Up @@ -1635,12 +1639,12 @@ int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) {

case 85:

token->opcode = PHQL_T_TS_CONTAINS_ANOTHER;
token->opcode = PHQL_T_OP_CONTAINS;
return 0;

case 86:

token->opcode = PHQL_T_TS_MATCHES;
token->opcode = PHQL_T_OP_MATCHES;
return 0;

case 87:
Expand Down Expand Up @@ -2783,7 +2787,7 @@ int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) {
}
case 141:

token->opcode = PHQL_T_TS_OR;
token->opcode = PHQL_T_OP_CONCAT;
return 0;

case 142:
Expand Down Expand Up @@ -7473,6 +7477,69 @@ int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) {
token->opcode = PHQL_T_BETWEEN_NOT;
return 0;

case 319:
$yych = $yyinput[$yycursor];
switch ($yych) {
case '>':
$yycursor += 1;
$yystate = 320;
break 2;
default:
$yystate = 3;
break 2;
}
case 320:
$yych = $yyinput[$yycursor];
switch ($yych) {
case '>':
$yycursor += 1;
$yystate = 321;
break 2;
default:
$yystate = 322;
break 2;
}
case 321:

token->opcode = PHQL_T_OP_JSON_PATH_TEXT;
return 0;

case 322:

token->opcode = PHQL_T_OP_JSON_PATH;
return 0;

case 323:
$yych = $yyinput[$yycursor];
switch ($yych) {
case '>':
$yycursor += 1;
$yystate = 325;
break 2;
default:
$yystate = 326;
break 2;
}
case 324:

token->opcode = PHQL_T_SUB;
return 0;

case 325:

token->opcode = PHQL_T_OP_JSON_GET_TEXT;
return 0;

case 326:

token->opcode = PHQL_T_OP_JSON_GET;
return 0;

case 327:

token->opcode = PHQL_T_OP_CONTAINED;
return 0;

default:
throw new \Exception("internal lexer error");
}
Expand Down
Loading
Loading