mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 02:33:03 +00:00
tests: handle locations in the generic yyerror functions.
* tests/local.at (AT_YYERROR_DECLARE_EXTERN, AT_YYERROR_DECLARE) (AT_YYERROR_DEFINE): Handle locations for C and C++. * tests/calc.at: Use it for C++ (as C has extra arguments which are not yet handled by AT_BISON_OPTION_PUSHDEFS). * tests/actions.at: Adjust.
This commit is contained in:
@@ -674,7 +674,7 @@ Reading a token: Next token is token 'd' (1.4-1.4: <> printer for 'd' @ 4)
|
|||||||
Shifting token 'd' (1.4-1.4: <> printer for 'd' @ 4)
|
Shifting token 'd' (1.4-1.4: <> printer for 'd' @ 4)
|
||||||
Entering state 6
|
Entering state 6
|
||||||
Reading a token: Now at end of input.
|
Reading a token: Now at end of input.
|
||||||
syntax error, unexpected $end, expecting 'e'
|
1.5-4: syntax error, unexpected $end, expecting 'e'
|
||||||
Error: popping token 'd' (1.4-1.4: <> printer for 'd' @ 4)
|
Error: popping token 'd' (1.4-1.4: <> printer for 'd' @ 4)
|
||||||
Stack now 0 1 3 5
|
Stack now 0 1 3 5
|
||||||
Error: popping token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3)
|
Error: popping token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3)
|
||||||
|
|||||||
@@ -376,15 +376,7 @@ power (int base, int exponent)
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_YYERROR_DEFINE],
|
||||||
/* A C++ error reporting function. */
|
|
||||||
void
|
|
||||||
AT_NAME_PREFIX::parser::error (const location_type& l, const std::string& m)
|
|
||||||
{
|
|
||||||
(void) l;
|
|
||||||
std::cerr << AT_LOCATION_IF([l << ": " << ])m << std::endl;
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[/* A C error reporting function. */
|
[/* A C error reporting function. */
|
||||||
static void
|
static void
|
||||||
yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
|
yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ static int
|
|||||||
# pair.
|
# pair.
|
||||||
m4_define([AT_YYERROR_DECLARE_EXTERN],
|
m4_define([AT_YYERROR_DECLARE_EXTERN],
|
||||||
[m4_case(AT_LANG,
|
[m4_case(AT_LANG,
|
||||||
[c], [void AT_API_PREFIX[]error (const char *msg);])[]dnl
|
[c], [void AT_API_PREFIX[]error (]AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])[const char *msg);])[]dnl
|
||||||
])
|
])
|
||||||
|
|
||||||
m4_define([AT_YYERROR_DECLARE],
|
m4_define([AT_YYERROR_DECLARE],
|
||||||
@@ -325,15 +325,28 @@ m4_define([AT_YYERROR_DECLARE],
|
|||||||
m4_define([AT_YYERROR_DEFINE],
|
m4_define([AT_YYERROR_DEFINE],
|
||||||
[m4_case(AT_LANG,
|
[m4_case(AT_LANG,
|
||||||
[c], [[#include <stdio.h>
|
[c], [[#include <stdio.h>
|
||||||
|
/* A C error reporting function. */
|
||||||
static void
|
static void
|
||||||
]AT_API_PREFIX[error (char const *msg)
|
yyerror (]AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])[const char *msg)
|
||||||
{
|
{
|
||||||
|
]AT_YYERROR_SEES_LOC_IF([[
|
||||||
|
fprintf (stderr, "%d.%d",
|
||||||
|
]AT_LOC_FIRST_LINE[, ]AT_LOC_FIRST_COLUMN[);
|
||||||
|
if (]AT_LOC_FIRST_LINE[ != ]AT_LOC_LAST_LINE[)
|
||||||
|
fprintf (stderr, "-%d.%d",
|
||||||
|
]AT_LOC_LAST_LINE[, ]AT_LOC_LAST_COLUMN[ - 1);
|
||||||
|
else if (]AT_LOC_FIRST_COLUMN[ != ]AT_LOC_LAST_COLUMN[ - 1)
|
||||||
|
fprintf (stderr, "-%d",
|
||||||
|
]AT_LOC_LAST_COLUMN[ - 1);
|
||||||
|
fprintf (stderr, ": ");]])[
|
||||||
fprintf (stderr, "%s\n", msg);
|
fprintf (stderr, "%s\n", msg);
|
||||||
}]],
|
}]],
|
||||||
[c++], [[void
|
[c++], [[/* A C++ error reporting function. */
|
||||||
]AT_NAME_PREFIX[::parser::error (const yy::location &, std::string const &msg)
|
void
|
||||||
|
]AT_NAME_PREFIX[::parser::error (const location_type& l, const std::string& m)
|
||||||
{
|
{
|
||||||
std::cerr << msg << std::endl;
|
(void) l;
|
||||||
|
std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl;
|
||||||
}]],
|
}]],
|
||||||
[java], [[public void yyerror (String msg)
|
[java], [[public void yyerror (String msg)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user