mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
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:
parent
eaec1dbc59
commit
5f0c3b2d62
5 changed files with 265 additions and 25 deletions
11
dtc-lexer.l
11
dtc-lexer.l
|
@ -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]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue