diff options
author | Luis Ontanon <luis.ontanon@gmail.com> | 2007-03-23 00:15:48 +0000 |
---|---|---|
committer | Luis Ontanon <luis.ontanon@gmail.com> | 2007-03-23 00:15:48 +0000 |
commit | 9a64c881a1ec1216de3c08efc21f27f0a18e55fb (patch) | |
tree | 53db331c30d732c3b714c90374ec76a7fa6809ad /tools | |
parent | e28d403669fe76d68fbaf0642d9cd7200fff871c (diff) |
squelch signedness warnings generated by generated code due to mayors being decleared as signed but added as signed in tables (it will generate larger tables when the number of tokens or actions is more than MAX_INT8, MAX_INT16).
svn path=/trunk/; revision=21138
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lemon/lemon.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c index 94ee6a631d..eadccdb892 100644 --- a/tools/lemon/lemon.c +++ b/tools/lemon/lemon.c @@ -2507,6 +2507,18 @@ void Parse(struct lemon *gp) ps.filename = gp->filename; ps.errorcnt = 0; ps.state = INITIALIZE; + ps.prevrule = NULL; + ps.preccounter = 0; + ps.lastrule = NULL; + ps.firstrule = NULL; + ps.lhs = NULL; + ps.nrhs = 0; + ps.lhsalias = NULL; + ps.declkeyword = NULL; + ps.declargslot = NULL; + ps.decllnslot = NULL; + ps.declassoc = UNK; + ps.fallback = NULL; /* Begin by reading the input file */ fp = fopen(ps.filename,"rb"); @@ -3479,6 +3491,16 @@ static const char *minimum_size_type(int lwr, int upr){ } } +static const char *minimum_signed_size_type(int lwr, int upr){ + if( lwr>=-127 && upr<=127 ){ + return "signed char"; + }else if( lwr>=-32767 && upr<32767 ){ + return "short"; + }else{ + return "int"; + } +} + /* ** Each state contains a set of token transaction and a set of ** nonterminal transactions. Each of these sets makes an instance @@ -3553,10 +3575,10 @@ void ReportTable( /* Generate the defines */ fprintf(out,"#define YYCODETYPE %s\n", - minimum_size_type(0, lemp->nsymbol+5)); lineno++; + minimum_signed_size_type(0, lemp->nsymbol+5)); lineno++; fprintf(out,"#define YYNOCODE %d\n",lemp->nsymbol+1); lineno++; fprintf(out,"#define YYACTIONTYPE %s\n", - minimum_size_type(0, lemp->nstate+lemp->nrule+5)); lineno++; + minimum_signed_size_type(0, lemp->nstate+lemp->nrule+5)); lineno++; if( lemp->wildcard ){ fprintf(out,"#define YYWILDCARD %d\n", lemp->wildcard->index); lineno++; |