style: prefer symbolic values rather than litterals

Instead of

    #define YYPACT_NINF -130
    #define yypact_value_is_default(Yystate) \
      (!!((Yystate) == (-130)))

generate

    #define YYPACT_NINF (-130)
    #define yypact_value_is_default(Yyn) \
      ((Yyn) == YYPACT_NINF)

* data/skeletons/c.m4 (b4_table_value_equals): Add support for $4.
* data/skeletons/glr.c, data/skeletons/yacc.c: Use it.
Also, use shorter macro argument names, the name of the macro is clear
enough.
This commit is contained in:
Akim Demaille
2019-09-30 07:17:01 +02:00
parent 4971409e39
commit a57e74a5bf
3 changed files with 14 additions and 14 deletions

View File

@@ -189,16 +189,16 @@ m4_define([b4_int_type_for],
[b4_int_type($1_min, $1_max)])
# b4_table_value_equals(TABLE, VALUE, LITERAL)
# --------------------------------------------
# b4_table_value_equals(TABLE, VALUE, LITERAL, SYMBOL)
# ----------------------------------------------------
# Without inducing a comparison warning from the compiler, check if the
# literal value LITERAL equals VALUE from table TABLE, which must have
# TABLE_min and TABLE_max defined.
# TABLE_min and TABLE_max defined. SYMBOL denotes
m4_define([b4_table_value_equals],
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|| m4_indir([b4_]$1[_max]) < $3), [1],
[[0]],
[(!!(($2) == ($3)))])])
[(($2) == $4)])])
## ----------------- ##