summaryrefslogtreecommitdiff
path: root/ext/json/json_parser.y
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-09-19 18:29:13 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-09-19 21:00:22 +0200
commit3fd68fd827b4e6043db188387f13e2e3c47c3158 (patch)
treea9183da2b9c7796edc5830f906390881dbe1e368 /ext/json/json_parser.y
parent5bee9c9062642cb34cc1c94bda5980960fad6006 (diff)
downloadphp-git-3fd68fd827b4e6043db188387f13e2e3c47c3158.tar.gz
Clean up JSON parser
Don't use <value> type for JSON tokens that don't have a value and remove the errlex productions -- we're going to get an unexpected token error anyway, there's no need to handle these explicitly. This also removes the awkward workarounds for the unused value warnings.
Diffstat (limited to 'ext/json/json_parser.y')
-rw-r--r--ext/json/json_parser.y37
1 files changed, 4 insertions, 33 deletions
diff --git a/ext/json/json_parser.y b/ext/json/json_parser.y
index ff9e50362a..ba7311c963 100644
--- a/ext/json/json_parser.y
+++ b/ext/json/json_parser.y
@@ -32,10 +32,6 @@ int json_yydebug = 1;
#define YYFREE free
#endif
-#define PHP_JSON_USE(uv) ((void) (uv))
-#define PHP_JSON_USE_1(uvr, uv1) PHP_JSON_USE(uvr); PHP_JSON_USE(uv1)
-#define PHP_JSON_USE_2(uvr, uv1, uv2) PHP_JSON_USE(uvr); PHP_JSON_USE(uv1); PHP_JSON_USE(uv2)
-
#define PHP_JSON_DEPTH_DEC --parser->depth
#define PHP_JSON_DEPTH_INC \
if (parser->max_depth && parser->depth >= parser->max_depth) { \
@@ -67,10 +63,10 @@ int json_yydebug = 1;
%token <value> PHP_JSON_T_DOUBLE
%token <value> PHP_JSON_T_STRING
%token <value> PHP_JSON_T_ESTRING
-%token <value> PHP_JSON_T_EOI
-%token <value> PHP_JSON_T_ERROR
+%token PHP_JSON_T_EOI
+%token PHP_JSON_T_ERROR
-%type <value> start object key value array errlex
+%type <value> start object key value array
%type <value> members member elements element
%type <pair> pair
@@ -90,11 +86,7 @@ start:
{
ZVAL_COPY_VALUE(&$$, &$1);
ZVAL_COPY_VALUE(parser->return_value, &$1);
- PHP_JSON_USE($2); YYACCEPT;
- }
- | value errlex
- {
- PHP_JSON_USE_2($$, $1, $2);
+ YYACCEPT;
}
;
@@ -148,10 +140,6 @@ member:
}
ZVAL_COPY_VALUE(&$$, &$1);
}
- | member errlex
- {
- PHP_JSON_USE_2($$, $1, $2);
- }
;
pair:
@@ -160,10 +148,6 @@ pair:
$$.key = Z_STR($1);
ZVAL_COPY_VALUE(&$$.val, &$3);
}
- | key errlex
- {
- PHP_JSON_USE_2($$, $1, $2);
- }
;
array:
@@ -212,10 +196,6 @@ element:
parser->methods.array_append(parser, &$1, &$3);
ZVAL_COPY_VALUE(&$$, &$1);
}
- | element errlex
- {
- PHP_JSON_USE_2($$, $1, $2);
- }
;
key:
@@ -233,15 +213,6 @@ value:
| PHP_JSON_T_NUL
| PHP_JSON_T_TRUE
| PHP_JSON_T_FALSE
- | errlex
-;
-
-errlex:
- PHP_JSON_T_ERROR
- {
- PHP_JSON_USE_1($$, $1);
- YYERROR;
- }
;
%% /* Functions */