2020
2121#include < util/unicode.h>
2222
23- int yyjsonlex ();
24- extern char *yyjsontext;
25- extern int yyjsonleng; // really an int, not a size_t
23+ int yyjsonlex (void *);
24+ char *yyjsonget_text (void *);
25+ #define yyjsontext yyjsonget_text (scanner)
26+ int yyjsonget_leng(void *); // really an int, not a size_t
27+ #define yyjsonleng yyjsonget_leng (scanner)
2628
27- static std::string convert_TOK_STRING ()
29+ static std::string convert_TOK_STRING(void *scanner )
2830{
2931 PRECONDITION (yyjsontext[0 ]==' "' );
3032 std::size_t len=yyjsonleng;
@@ -70,19 +72,23 @@ static std::string convert_TOK_STRING()
7072 return result;
7173}
7274
73- static std::string convert_TOK_NUMBER ()
75+ static std::string convert_TOK_NUMBER (void *scanner )
7476{
7577 return yyjsontext;
7678}
7779
78- int yyjsonerror (const std::string &error)
80+ int yyjsonerror (json_parsert &json_parser, void *scanner, const std::string &error)
7981{
8082 json_parser.parse_error (error, yyjsontext);
8183 return 0 ;
8284}
8385
8486%}
8587
88+ %parse-param {json_parsert &json_parser}
89+ %parse-param {void *scanner}
90+ %lex-param {void *scanner}
91+
8692%token TOK_STRING
8793%token TOK_NUMBER
8894%token TOK_TRUE
@@ -109,7 +115,7 @@ key_value_pair:
109115 TOK_STRING
110116 {
111117 // we abuse the 'value' to temporarily store the key
112- json_parser.top().value=convert_TOK_STRING();
118+ json_parser.top().value=convert_TOK_STRING(scanner );
113119 }
114120 ' :' value
115121 {
@@ -139,9 +145,9 @@ array_value:
139145 ;
140146
141147value : TOK_STRING
142- { json_parser.push(json_stringt(convert_TOK_STRING())); }
148+ { json_parser.push(json_stringt(convert_TOK_STRING(scanner ))); }
143149 | TOK_NUMBER
144- { json_parser.push(json_numbert(convert_TOK_NUMBER())); }
150+ { json_parser.push(json_numbert(convert_TOK_NUMBER(scanner ))); }
145151 | object
146152 | array
147153 | TOK_TRUE
0 commit comments