[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/6] tests: improve the generic yylex implementation.
From: |
Akim Demaille |
Subject: |
[PATCH 3/6] tests: improve the generic yylex implementation. |
Date: |
Tue, 26 Jun 2012 14:10:46 +0200 |
* tests/local.at (AT_YYSTYPE, AT_YYLTYPE): New.
(AT_YYLEX_FORMALS): Use them.
(AT_YYLEX_DEFINE): Be independent of the location implementation.
---
tests/local.at | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/tests/local.at b/tests/local.at
index 1646a5e..c1fcd60 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -162,11 +162,19 @@ m4_pushdef([AT_PURE_LEX_IF],
[AT_PURE_IF([$1],
[AT_SKEL_CC_IF([$1], [$2])])])
+m4_pushdef([AT_YYSTYPE],
+[AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::semantic_type]],
+ [[YYSTYPE]])])
+m4_pushdef([AT_YYLTYPE],
+[AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::location_type]],
+ [[YYLTYPE]])])
+
+
AT_PURE_LEX_IF(
[m4_pushdef([AT_LOC], [(*llocp)])
m4_pushdef([AT_VAL], [(*lvalp)])
m4_pushdef([AT_YYLEX_FORMALS],
- [YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
+ [AT_YYSTYPE *lvalp[]AT_LOCATION_IF([, AT_YYLTYPE *llocp])])
m4_pushdef([AT_YYLEX_ARGS],
[lvalp[]AT_LOCATION_IF([, llocp])])
m4_pushdef([AT_USE_LEX_ARGS],
@@ -204,6 +212,8 @@ m4_popdef([AT_YYLEX_PRE_FORMALS])
m4_popdef([AT_USE_LEX_ARGS])
m4_popdef([AT_YYLEX_ARGS])
m4_popdef([AT_YYLEX_FORMALS])
+m4_popdef([AT_YYLTYPE])
+m4_popdef([AT_YYSTYPE])
m4_popdef([AT_VAL])
m4_popdef([AT_LOC])
m4_popdef([AT_PURE_LEX_IF])
@@ -301,12 +311,13 @@ static
static char const input[] = "$1";
static size_t toknum = 0;
int res;
+ ]AT_USE_LEX_ARGS[;
if (! (toknum < sizeof input))
abort ();
res = input[toknum++];
- ]$2;[]AT_LOCATION_IF([[
- ]AT_NAME_PREFIX[lloc.first_line = ]AT_NAME_PREFIX[lloc.last_line = 1;
- ]AT_NAME_PREFIX[lloc.first_column = ]AT_NAME_PREFIX[lloc.last_column =
toknum;]])[
+ ]$2[;]AT_LOCATION_IF([[
+ ]AT_LOC_FIRST_LINE[ = ]AT_LOC_LAST_LINE[ = 1;
+ ]AT_LOC_FIRST_COLUMN[ = ]AT_LOC_LAST_COLUMN[ = toknum;]])[
return res;
}]dnl
])
--
1.7.11.1
- [PATCH 0/6] Refactor the test suite, Akim Demaille, 2012/06/27
- Re: [PATCH 0/6] Refactor the test suite, Akim Demaille, 2012/06/26
- [PATCH 1/6] tests: fix confusion between api.prefix and name-prefix., Akim Demaille, 2012/06/27
- [PATCH 3/6] tests: improve the generic yylex implementation.,
Akim Demaille <=
- [PATCH 4/6] tests: use assert instead of plain abort., Akim Demaille, 2012/06/27
- [PATCH 5/6] tests: use the generic yyerror function., Akim Demaille, 2012/06/27
- [PATCH 6/6] tests: do not output m4 set up., Akim Demaille, 2012/06/27
- [PATCH 2/6] tests: generalize the compilation macros., Akim Demaille, 2012/06/27