diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-06-14 10:35:16 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-06-14 10:35:16 (GMT) |
commit | 4a2f5c39a29bdb4f626bfdb109753ca106a71a33 (patch) | |
tree | 9e16d13c063ebd861e9d6c48f940cb2bc62554d3 /tools/d2c/d2c_tok.l | |
parent | 04d108111fe7ddd01713b4ca22f8d96961ec2486 (diff) |
Handled properly the sign extension when extending values.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@539 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'tools/d2c/d2c_tok.l')
-rw-r--r-- | tools/d2c/d2c_tok.l | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/tools/d2c/d2c_tok.l b/tools/d2c/d2c_tok.l index 08562ce..300508d 100644 --- a/tools/d2c/d2c_tok.l +++ b/tools/d2c/d2c_tok.l @@ -33,9 +33,9 @@ void free_flex_memory(void) ; %x syntax syntax_name syntax_int syntax_ext -%x conv_begin conv_content conv_arg conv_arg_binval +%x conv_begin conv_content -%x arg arg_binval +%x arg arg_binval arg_hexval %x hooks_begin hooks_content @@ -130,12 +130,12 @@ void free_flex_memory(void) ; } } <conv_content>"=" { return EQ; } -<conv_content>"(" { BEGIN(conv_arg); return OP; } +<conv_content>"(" { yy_push_state(arg); return OP; } -<conv_arg>[A-Za-z_][A-Za-z0-9_]* { +<arg>[A-Za-z_][A-Za-z0-9_]* { if (strcmp(yytext, "NOT") == 0) return NOT; else if (strcmp(yytext, "AND") == 0) return AND_LOG; else if (strcmp(yytext, "EOR") == 0) return EOR; @@ -145,45 +145,21 @@ void free_flex_memory(void) ; return NAME; } } -<conv_arg>[0-9][0-9]* { d2c_lval.integer = atoi(yytext); return NUMBER; } -<conv_arg>"'" { BEGIN(conv_arg_binval); } -<conv_arg_binval>[01][01]* { d2c_lval.string = strdup(yytext); return BINVAL; } -<conv_arg_binval>"'" { BEGIN(conv_arg); } -<conv_arg>"," { return COMMA; } -<conv_arg>":" { return COLON; } -<conv_arg>[ ]+ { } -<conv_arg>")" { BEGIN(conv_content); return CP; } - - - - - - - - - -<arg>[A-Za-z_][A-Za-z0-9_]* { - if (strcmp(yytext, "NOT") == 0) return NOT; - else if (strcmp(yytext, "AND") == 0) return AND_LOG; - else if (strcmp(yytext, "EOR") == 0) return EOR; - else - { - d2c_lval.string = strdup(yytext); - return NAME; - } - } <arg>[0-9][0-9]* { d2c_lval.integer = atoi(yytext); return NUMBER; } <arg>"'" { BEGIN(arg_binval); } <arg_binval>[01][01]* { d2c_lval.string = strdup(yytext); return BINVAL; } <arg_binval>"'" { BEGIN(arg); } +<arg>"0x" { BEGIN(arg_hexval); } +<arg_hexval>[0-9a-f][0-9a-f]* { d2c_lval.string = strdup(yytext); BEGIN(arg); return HEXVAL; } <arg>"," { return COMMA; } <arg>":" { return COLON; } +<arg>"&" { return AND_LOG; } <arg>[ ]+ { } +<arg>"(" { yy_push_state(arg); return OP; } <arg>")" { yy_pop_state(); return CP; } - <encoding_content>"@hooks" { BEGIN(hooks_begin); return HOOKS; } <hooks_begin>[ ]+ { } <hooks_begin>"{" { BEGIN(hooks_content); } |