dtc: Basic integer expressions

Written by David Gibson <david@gibson.dropbear.id.au>. Additions by me:
* Ported to ToT dtc.
* Renamed cell to integer throughout.
* Implemented value range checks.
* Allow U/L/UL/LL/ULL suffix on literals.
* Enabled the commented test.

Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
This commit is contained in:
Stephen Warren 2012-04-03 20:56:00 -06:00 committed by Jon Loeliger
parent eaec1dbc59
commit 5f0c3b2d62
5 changed files with 265 additions and 25 deletions

View file

@ -110,7 +110,7 @@ static int pop_input_file(void);
return DT_LABEL;
}
<V1>[0-9]+|0[xX][0-9a-fA-F]+ {
<V1>([0-9]+|0[xX][0-9a-fA-F]+)(U|L|UL|LL|ULL)? {
yylval.literal = xstrdup(yytext);
DPRINT("Literal: '%s'\n", yylval.literal);
return DT_LITERAL;
@ -164,6 +164,15 @@ static int pop_input_file(void);
<*>{COMMENT}+ /* eat C-style comments */
<*>{LINECOMMENT}+ /* eat C++-style comments */
<*>"<<" { return DT_LSHIFT; };
<*>">>" { return DT_RSHIFT; };
<*>"<=" { return DT_LE; };
<*>">=" { return DT_GE; };
<*>"==" { return DT_EQ; };
<*>"!=" { return DT_NE; };
<*>"&&" { return DT_AND; };
<*>"||" { return DT_OR; };
<*>. {
DPRINT("Char: %c (\\x%02x)\n", yytext[0],
(unsigned)yytext[0]);