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.l51
1 files changed, 49 insertions, 2 deletions
diff --git a/tools/d2c/d2c_tok.l b/tools/d2c/d2c_tok.l
index 8f54c8d..9689b59 100644
--- a/tools/d2c/d2c_tok.l
+++ b/tools/d2c/d2c_tok.l
@@ -19,7 +19,9 @@ void free_flex_memory(void) ;
%option noyywrap
%option nounput
%option noinput
-%option yylineno
+%option yylineno
+%option stack
+%option noyy_top_state
%x comments
@@ -33,9 +35,11 @@ void free_flex_memory(void) ;
%x conv_begin conv_content conv_arg conv_arg_binval
+%x arg arg_binval
+
%x hooks_begin hooks_content
-%x rules_begin rules_content rules_cond rules_cond_binval rules_action rules_action_see
+%x rules_begin rules_content rules_cond rules_cond_binval rules_action rules_action_see rules_action_call
%%
@@ -127,6 +131,10 @@ void free_flex_memory(void) ;
}
<conv_content>"=" { return EQ; }
<conv_content>"(" { BEGIN(conv_arg); return OP; }
+
+
+
+
<conv_arg>[A-Za-z][A-Za-z0-9_]* {
if (strcmp(yytext, "NOT") == 0) return NOT;
else if (strcmp(yytext, "EOR") == 0) return EOR;
@@ -147,6 +155,33 @@ void free_flex_memory(void) ;
+
+
+
+
+
+
+<arg>[A-Za-z][A-Za-z0-9_]* {
+ if (strcmp(yytext, "NOT") == 0) return NOT;
+ 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>"," { return COMMA; }
+<arg>":" { return COLON; }
+<arg>[ ]+ { }
+<arg>")" { yy_pop_state(); return CP; }
+
+
+
+
<encoding_content>"@hooks" { BEGIN(hooks_begin); return HOOKS; }
<hooks_begin>[ ]+ { }
<hooks_begin>"{" { BEGIN(hooks_content); }
@@ -165,6 +200,10 @@ void free_flex_memory(void) ;
<rules_content>[ \t\n]+ { }
<rules_content>"}" { BEGIN(encoding_content); }
+<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>"if" { BEGIN(rules_cond); return IF; }
<rules_cond>[ ]+ { }
<rules_cond>"(" { return EXPR_START; }
@@ -179,10 +218,18 @@ void free_flex_memory(void) ;
<rules_cond>";" { BEGIN(rules_action); return THEN; }
<rules_action>[ ]+ { }
+
<rules_action>"see " { BEGIN(rules_action_see); return SEE; }
<rules_action_see>[^\n]* { d2c_lval.cstring = yytext; BEGIN(rules_content); return INS_DETAILS; }
+
<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); }
+
%%