Merge remote-tracking branch 'origin/maint'

* origin/maint:
  maint: formatting changes.
  tests: support api.prefix.
  tests: pacify font-lock-mode.
  tests: remove test covered elsewhere.
  tests: factor the declaration/definition of yyerror and yylex.
  regen.
  tests: portability issues.
  tests: call the parser from another compilation unit.
  glr.c, yacc.c: declare yydebug in the header.
  skeletons: use header guards.
  tests: improve AT_FULL_COMPILE.
  tests: reorder.
  tests: strengthen the test on generated headers inclusion
  yacc.c: instead of duplicating y.tab.h inside y.tac.c, include it.
  yacc.c: factor.

Conflicts:
	NEWS
	data/glr.c
	data/yacc.c
	src/parse-gram.c
	src/parse-gram.h
	tests/conflicts.at
	tests/regression.at
This commit is contained in:
Akim Demaille
2012-06-19 17:35:53 +02:00
17 changed files with 685 additions and 843 deletions

View File

@@ -226,6 +226,62 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
yytype_int16 *yyes;
YYSIZE_T yyes_capacity;]])])
# b4_declare_yyparse_push_
# ------------------------
m4_define([b4_declare_yyparse_push_],
[[typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
enum { YYPUSH_MORE = 4 };
]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
[[b4_prefix[pstate *yyps]], [[yyps]]]b4_pure_if([,
[[[int yypushed_char]], [[yypushed_char]]],
[[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
[[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
b4_parse_param]))
b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
[[b4_prefix[pstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
b4_parse_param]))])
b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
[[[void]], []])
b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
[[b4_prefix[pstate *yyps]], [[yyps]]])dnl
])
# b4_declare_yyparse_
# -------------------
# When not the push parser.
m4_define([b4_declare_yyparse_],
[[#ifdef YYPARSE_PARAM
]b4_c_function_decl(b4_prefix[parse], [int],
[[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
#else /* ! YYPARSE_PARAM */
]b4_c_function_decl(b4_prefix[parse], [int], b4_parse_param)[
#endif /* ! YYPARSE_PARAM */]dnl
])
# b4_declare_yyparse
# ------------------
m4_define([b4_declare_yyparse],
[b4_push_if([b4_declare_yyparse_push_],
[b4_declare_yyparse_])[]dnl
])
# b4_shared_declarations
# ----------------------
# Declaration that might either go into the header (if --defines)
# or open coded in the parser body.
m4_define([b4_shared_declarations],
[b4_declare_yydebug[
]b4_percent_code_get([[requires]])[
]b4_token_enums_defines(b4_tokens)[
]b4_declare_yylstype[
]b4_declare_yyparse[
]b4_percent_code_get([[provides]])[]dnl
])
## -------------- ##
## Output files. ##
## -------------- ##
@@ -269,11 +325,6 @@ m4_if(b4_prefix, [yy], [],
]b4_null_define[
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG ]b4_parse_trace_if([1], [0])[
#endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
@@ -287,34 +338,10 @@ m4_if(b4_prefix, [yy], [],
# define YYTOKEN_TABLE ]b4_token_table[
#endif
]b4_percent_code_get([[requires]])[
]b4_token_enums_defines(b4_tokens)[
]b4_declare_yylstype[
]b4_push_if([[
#ifndef YYPUSH_DECLS
# define YYPUSH_DECLS
struct yypstate;
typedef struct yypstate yypstate;
enum { YYPUSH_MORE = 4 };
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
[b4_shared_declarations])[
]b4_pull_if([b4_c_function_decl([[yyparse]], [[int]], b4_parse_param)
])b4_c_function_decl([[yypush_parse]], [[int]],
[[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
[[[int yypushed_char]], [[yypushed_char]]],
[[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
[[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
b4_parse_param]))
b4_pull_if([b4_c_function_decl([[yypull_parse]], [[int]],
[[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
b4_parse_param]))])
b4_c_function_decl([[yypstate_new]], [[yypstate *]], [[[void]], []])
b4_c_function_decl([[yypstate_delete]], [[void]],
[[[yypstate *yyps]], [[yyps]]])[
#endif]])
b4_percent_code_get([[provides]])[]dnl
[/* Copy the second part of user declarations. */
/* Copy the second part of user declarations. */
]b4_user_post_prologue
b4_percent_code_get[]dnl
@@ -1298,20 +1325,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
}
#endif /* YYERROR_VERBOSE */
]b4_yydestruct_generate([b4_c_function_def])b4_push_if([], [[
]b4_yydestruct_generate([b4_c_function_def])[
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
]b4_c_function_decl([yyparse], [int],
[[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
#else /* ! YYPARSE_PARAM */
]b4_c_function_decl([yyparse], [int], b4_parse_param)[
#endif /* ! YYPARSE_PARAM */]])b4_pure_if([], [
]b4_pure_if([], [
b4_declare_scanner_communication_variables])[]b4_push_if([[
struct yypstate
{]b4_declare_parser_state_variables[
/* Used to determine if this is the first time this instance has
@@ -1976,37 +1995,13 @@ yypushreturn:]])[
]b4_epilogue[]dnl
b4_defines_if(
[@output(b4_spec_defines_file@)@
b4_copyright([Bison interface for Yacc-like parsers in C])dnl
b4_copyright([Bison interface for Yacc-like parsers in C])[
b4_percent_code_get([[requires]])[]dnl
b4_token_enums_defines(b4_tokens)[
]b4_declare_yylstype[
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;
]b4_locations_if([[extern YYLTYPE ]b4_prefix[lloc;]])])dnl
b4_push_if([[
#ifndef YYPUSH_DECLS
# define YYPUSH_DECLS
struct ]b4_prefix[pstate;
typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
enum { YYPUSH_MORE = 4 };
]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
[[b4_prefix[pstate *yyps]], [[yyps]]]b4_pure_if([,
[[[int yypushed_char]], [[yypushed_char]]],
[[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
[[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
b4_parse_param]))
b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
[[b4_prefix[pstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
b4_parse_param]))])
b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
[[[void]], []])
b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
[[b4_prefix[pstate *yyps]], [[yyps]]])[
#endif
]])
b4_percent_code_get([[provides]])[]dnl
])dnl b4_defines_if
]b4_locations_if([[extern YYLTYPE ]b4_prefix[lloc;]])])[
]b4_cpp_guard_close([b4_spec_defines_file])[
]])dnl b4_defines_if
m4_divert_pop(0)
m4_popdef([b4_copyright_years])