From 5f0c3b2d6235dec65fff1628a97f45e21680b36d Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Tue, 3 Apr 2012 20:56:00 -0600 Subject: dtc: Basic integer expressions Written by David Gibson . 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 --- dtc-lexer.l | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'dtc-lexer.l') diff --git a/dtc-lexer.l b/dtc-lexer.l index 73d190c..4715f31 100644 --- a/dtc-lexer.l +++ b/dtc-lexer.l @@ -110,7 +110,7 @@ static int pop_input_file(void); return DT_LABEL; } -[0-9]+|0[xX][0-9a-fA-F]+ { +([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]); -- cgit v1.2.3-59-g8ed1b