api.location.type: support it in C

Reported by Balázs Scheidler.

* data/skeletons/c.m4 (b4_location_type_define): Use api.location.type
if defined.
* doc/bison.texi: Document it.
* tests/local.at (AT_C_IF, AT_LANG_CASE): New.
Support Span in C.
* tests/calc.at (Span): Convert it to be usable in C and C++.
Check api.location.type with yacc.c and glr.c.
This commit is contained in:
Akim Demaille
2019-04-22 19:24:11 +02:00
parent 971e72514f
commit 9260e5ca4f
7 changed files with 58 additions and 22 deletions

View File

@@ -157,6 +157,8 @@ m4_pushdef([AT_LANG],
[AT_CXX_IF([c++],
[AT_D_IF([d],
[c])])])])
m4_pushdef([AT_C_IF],
[m4_if(AT_LANG, [c], [$1], [$2])])
m4_pushdef([AT_GLR_IF],
[m4_bmatch([$3], [%glr-parser\|%skeleton "glr\..*"], [$1], [$2])])
m4_pushdef([AT_LALR1_CC_IF],
@@ -288,13 +290,12 @@ AT_TOKEN_CTOR_IF(
m4_pushdef([AT_YYLEX_PRE_ARGS], [])
])])
# Handle the different types of location components.
AT_CXX_IF(
[AT_LOCATION_TYPE_SPAN_IF(
# Handle the different types of location components.
AT_LOCATION_TYPE_SPAN_IF(
[AT_LOC_PUSHDEF([first.l], [first.c], [last.l], [last.c])],
[AT_LOC_PUSHDEF([begin.line], [begin.column], [end.line], [end.column])])],
[AT_LOC_PUSHDEF([first_line], [first_column], [last_line], [last_column])])
[AT_CXX_IF([AT_LOC_PUSHDEF([begin.line], [begin.column], [end.line], [end.column])],
[AT_LOC_PUSHDEF([first_line], [first_column], [last_line], [last_column])])])
AT_GLR_IF([AT_KEYWORDS([glr])])
@@ -334,6 +335,7 @@ m4_popdef([AT_LEXPARAM_IF])
m4_popdef([AT_YACC_IF])
m4_popdef([AT_GLR_IF])
m4_popdef([AT_CXX_IF])
m4_popdef([AT_C_IF])
m4_popdef([AT_LANG])
m4_popdef([AT_JAVA_IF])
m4_popdef([AT_GLR_CC_IF])
@@ -349,6 +351,12 @@ AT_LOC_POPDEF])dnl
## Generating Grammar Files. ##
## -------------------------- ##
# AT_LANG_CASE(LANG1, IF-LANG1, LANG2, IF-LANG2, ..., DEFAULT)
# ------------------------------------------------------------
m4_define([AT_LANG_CASE],
[m4_case(AT_LANG, $@)])
# _AT_LANG_DISPATCH(LANG, MACRO, ARGS)
# ------------------------------------
# Call the specialization of MACRO for LANG with ARGS. Complain if
@@ -990,7 +998,7 @@ AT_CHECK([[$SHELL ../../../javacomp.sh ]$1],
# AT_LANG_FOR_EACH_STD(BODY)
# -------------------------------
# --------------------------
m4_define([AT_LANG_FOR_EACH_STD], [AT_LANG_DISPATCH([$0], $@)])