Skip to content

Commit 583619d

Browse files
committed
Use customized bison skeleton to change cpp guard
1 parent 6267bde commit 583619d

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

Makefile.frag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ $(srcdir)/jsond_scanner.c: $(srcdir)/jsond_scanner.re
44
$(RE2C) -t $(srcdir)/php_jsond_scanner_defs.h --no-generation-date -bci -o $@ $(srcdir)/jsond_scanner.re
55

66
$(srcdir)/jsond_parser.tab.c: $(srcdir)/jsond_parser.y
7-
$(YACC) --defines -l $(srcdir)/jsond_parser.y -o $@
7+
$(YACC) --defines --skeleton=$(srcdir)/jsond_yacc.c -l $(srcdir)/jsond_parser.y -o $@

jsond_parser.tab.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#define YYBISON_VERSION "3.0.4"
4848

4949
/* Skeleton name. */
50-
#define YYSKELETON_NAME "yacc.c"
50+
#define YYSKELETON_NAME "jsond_yacc.c"
5151

5252
/* Pure parsers. */
5353
#define YYPURE 1
@@ -126,8 +126,8 @@ int json_yydebug = 1;
126126

127127
/* In a future release of Bison, this section will be replaced
128128
by #include "jsond_parser.tab.h". */
129-
#ifndef YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_EXT_JSOND_JSOND_PARSER_TAB_H_INCLUDED
130-
# define YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_EXT_JSOND_JSOND_PARSER_TAB_H_INCLUDED
129+
#ifndef YY_PHP_JSON_YY_PARSER_INCLUDED
130+
# define YY_PHP_JSON_YY_PARSER_INCLUDED
131131
/* Debug traces. */
132132
#ifndef YYDEBUG
133133
# define YYDEBUG 0
@@ -189,7 +189,7 @@ typedef union YYSTYPE YYSTYPE;
189189

190190
int php_json_yyparse (php_json_parser *parser);
191191

192-
#endif /* !YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_EXT_JSOND_JSOND_PARSER_TAB_H_INCLUDED */
192+
#endif /* !YY_PHP_JSON_YY_PARSER_INCLUDED */
193193

194194
/* Copy the second part of user declarations. */
195195

@@ -718,10 +718,6 @@ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvalue
718718
YYUSE (parser);
719719
if (!yyvaluep)
720720
return;
721-
# ifdef YYPRINT
722-
if (yytype < YYNTOKENS)
723-
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
724-
# endif
725721
YYUSE (yytype);
726722
}
727723

jsond_parser.tab.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
This special exception was added by the Free Software Foundation in
3131
version 2.2 of Bison. */
3232

33-
#ifndef YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_EXT_JSOND_JSOND_PARSER_TAB_H_INCLUDED
34-
# define YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_EXT_JSOND_JSOND_PARSER_TAB_H_INCLUDED
33+
#ifndef YY_PHP_JSON_YY_PARSER_INCLUDED
34+
# define YY_PHP_JSON_YY_PARSER_INCLUDED
3535
/* Debug traces. */
3636
#ifndef YYDEBUG
3737
# define YYDEBUG 0
@@ -93,4 +93,4 @@ typedef union YYSTYPE YYSTYPE;
9393

9494
int php_json_yyparse (php_json_parser *parser);
9595

96-
#endif /* !YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_EXT_JSOND_JSOND_PARSER_TAB_H_INCLUDED */
96+
#endif /* !YY_PHP_JSON_YY_PARSER_INCLUDED */

jsond_yacc.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,20 +285,43 @@ m4_define([b4_declare_yyparse],
285285
# Declaration that might either go into the header (if --defines)
286286
# or open coded in the parser body.
287287
m4_define([b4_shared_declarations],
288-
[b4_cpp_guard_open([b4_spec_defines_file])[
288+
[b4_cpp_guard_open([parser])[
289289
]b4_declare_yydebug[
290290
]b4_percent_code_get([[requires]])[
291291
]b4_token_enums_defines[
292292
]b4_declare_yylstype[
293293
]b4_declare_yyparse[
294294
]b4_percent_code_get([[provides]])[
295-
]b4_cpp_guard_close([b4_spec_defines_file])[]dnl
295+
]b4_cpp_guard_close([parser])[]dnl
296296
])
297297

298298
## -------------- ##
299299
## Output files. ##
300300
## -------------- ##
301301

302+
# b4_json_identification
303+
# -----------------
304+
# Customized identification for jsond parser
305+
m4_define([b4_jsond_identification],
306+
[[/* Identify Bison output. */
307+
#define YYBISON 1
308+
309+
/* Bison version. */
310+
#define YYBISON_VERSION "]b4_version["
311+
312+
/* Skeleton name. */
313+
#define YYSKELETON_NAME ]["jsond_yacc.c"][]m4_ifdef([b4_pure_flag], [[
314+
315+
/* Pure parsers. */
316+
#define YYPURE ]b4_pure_flag])[]m4_ifdef([b4_push_flag], [[
317+
318+
/* Push parsers. */
319+
#define YYPUSH ]b4_push_flag])[]m4_ifdef([b4_pull_flag], [[
320+
321+
/* Pull parsers. */
322+
#define YYPULL ]b4_pull_flag])[
323+
]])
324+
302325
b4_output_begin([b4_parser_file_name])
303326
b4_copyright([Bison implementation for Yacc-like parsers in C])[
304327

@@ -312,7 +335,7 @@ b4_copyright([Bison implementation for Yacc-like parsers in C])[
312335
define necessary library symbols; they are noted "INFRINGES ON
313336
USER NAME SPACE" below. */
314337

315-
]b4_identification
338+
]b4_jsond_identification
316339
b4_percent_code_get([[top]])[]dnl
317340
m4_if(b4_api_prefix, [yy], [],
318341
[[/* Substitute the type names. */

0 commit comments

Comments
 (0)