factor the handling of m4 escaping

The conversion from @ to @@ and so forth is coded is too many
different places.  Factor, a bit.

* src/scan-code.l: Instead of duplicating the logic of obstack_escape,
use it.
It sure is less efficient, but the cost is negligible.
This allows to factor rules that are alike.
And to factor some start-condition clauses.
* tests/input.at (Stray $ or @): New.
* NEWS: Document it.
This commit is contained in:
Akim Demaille
2012-07-27 11:22:22 +02:00
parent e20e6a50d5
commit 263137264f
3 changed files with 57 additions and 39 deletions

View File

@@ -1371,6 +1371,36 @@ m4_popdef([AT_TEST])
AT_CLEANUP
## -------------- ##
## Stray $ or @. ##
## -------------- ##
AT_SETUP([[Stray $ or @]])
AT_DATA_GRAMMAR([[input.y]],
[[%token TOK
%destructor { $%; @%; } <*>;
%initial-action { $%; @%; };
%printer { $%; @%; } <*>;
%%
exp: TOK { $%; @%; };
]])
AT_BISON_CHECK([[input.y]], 0, [],
[[input.y:10.19: warning: stray '$'
input.y:10.23: warning: stray '@'
input.y:11.19: warning: stray '$'
input.y:11.23: warning: stray '@'
input.y:12.19: warning: stray '$'
input.y:12.23: warning: stray '@'
input.y:14.19: warning: stray '$'
input.y:14.23: warning: stray '@'
]])
AT_CLEANUP
## ---------------- ##
## Code injection. ##
## ---------------- ##