summaryrefslogtreecommitdiff
path: root/tools/d2c/d2c_tok.l
diff options
context:
space:
mode:
Diffstat (limited to 'tools/d2c/d2c_tok.l')
-rw-r--r--tools/d2c/d2c_tok.l32
1 files changed, 19 insertions, 13 deletions
diff --git a/tools/d2c/d2c_tok.l b/tools/d2c/d2c_tok.l
index 9689b59..08562ce 100644
--- a/tools/d2c/d2c_tok.l
+++ b/tools/d2c/d2c_tok.l
@@ -39,7 +39,7 @@ void free_flex_memory(void) ;
%x hooks_begin hooks_content
-%x rules_begin rules_content rules_cond rules_cond_binval rules_action rules_action_see rules_action_call
+%x rules_begin rules_content rules_cond rules_cond_binval rules_cond_hexval rules_action rules_action_see rules_action_call
%%
@@ -84,9 +84,9 @@ void free_flex_memory(void) ;
<encoding_content>"@half" { BEGIN(encoding_bits); return HALF; }
<encoding_content>"@word" { BEGIN(encoding_bits); return WORD; }
-<encoding_bits>" " { }
-<encoding_bits>"\n" { BEGIN(encoding_content); }
-<encoding_bits>[A-Za-z][A-Za-z0-9_]* { d2c_lval.string = strdup(yytext); return NAME; }
+<encoding_bits>" " { }
+<encoding_bits>"\n" { BEGIN(encoding_content); }
+<encoding_bits>[A-Za-z_][A-Za-z0-9__]* { d2c_lval.string = strdup(yytext); return NAME; }
<encoding_bits>"(" { BEGIN(encoding_bits_size); }
<encoding_bits_size>[0-9]+ { d2c_lval.integer = atoi(yytext); return SIZE; }
@@ -135,8 +135,9 @@ void free_flex_memory(void) ;
-<conv_arg>[A-Za-z][A-Za-z0-9_]* {
+<conv_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
{
@@ -161,8 +162,9 @@ void free_flex_memory(void) ;
-<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;
else
{
@@ -203,18 +205,21 @@ void free_flex_memory(void) ;
<rules_content>"see " { BEGIN(rules_action_see); return SEE; }
<rules_content>"unpredictable" { return UNPREDICTABLE; }
<rules_content>"call" { BEGIN(rules_action_call); return CALL; }
+<rules_content>"chk_call" { BEGIN(rules_action_call); return CHK_CALL; }
<rules_content>"if" { BEGIN(rules_cond); return IF; }
<rules_cond>[ ]+ { }
<rules_cond>"(" { return EXPR_START; }
-<rules_cond>[A-Za-z][A-Za-z0-9]* { d2c_lval.string = strdup(yytext); return NAME; }
+<rules_cond>[A-Za-z_][A-Za-z0-9_]* { d2c_lval.string = strdup(yytext); return NAME; }
<rules_cond>"==" { return EQUAL; }
<rules_cond>"'" { BEGIN(rules_cond_binval); }
<rules_cond_binval>[01][01]* { d2c_lval.string = strdup(yytext); return BINVAL; }
<rules_cond_binval>"'" { BEGIN(rules_cond); }
-<rules_cond>[0-9][0-9]* { d2c_lval.string = strdup(yytext); return IMMVAL; }
+<rules_cond>"0x" { BEGIN(rules_cond_hexval); }
+<rules_cond_hexval>[0-9a-f][0-9a-f]* { d2c_lval.string = strdup(yytext); BEGIN(rules_cond); return HEXVAL; }
<rules_cond>")" { return EXPR_END; }
<rules_cond>"&&" { return AND; }
+<rules_cond>"&" { return AND_LOG; }
<rules_cond>";" { BEGIN(rules_action); return THEN; }
<rules_action>[ ]+ { }
@@ -224,11 +229,12 @@ void free_flex_memory(void) ;
<rules_action>"unpredictable" { BEGIN(rules_content); return UNPREDICTABLE; }
-<rules_action>"call" { BEGIN(rules_action_call); return CALL; }
-<rules_action_call>[\t ]+ { }
-<rules_action_call>[A-Za-z][A-Za-z0-9]* { d2c_lval.string = strdup(yytext); return NAME; }
-<rules_action_call>"(" { yy_push_state(arg); return OP; }
-<rules_action_call>[\n] { BEGIN(rules_content); }
+<rules_action>"call" { BEGIN(rules_action_call); return CALL; }
+<rules_action>"chk_call" { BEGIN(rules_action_call); return CHK_CALL; }
+<rules_action_call>[\t ]+ { }
+<rules_action_call>[A-Za-z_][A-Za-z0-9_]* { d2c_lval.string = strdup(yytext); return NAME; }
+<rules_action_call>"(" { yy_push_state(arg); return OP; }
+<rules_action_call>[\n] { BEGIN(rules_content); }
%%