summaryrefslogtreecommitdiff
path: root/tools/d2c/tokens.l
diff options
context:
space:
mode:
Diffstat (limited to 'tools/d2c/tokens.l')
-rw-r--r--tools/d2c/tokens.l110
1 files changed, 36 insertions, 74 deletions
diff --git a/tools/d2c/tokens.l b/tools/d2c/tokens.l
index e48d079..1e4b7b0 100644
--- a/tools/d2c/tokens.l
+++ b/tools/d2c/tokens.l
@@ -6,41 +6,19 @@
}
-
%{
- //typedef struct _rented_coder rented_coder;
-
-
-//#include "d2c-d2c_gram.h"
-
-#include <ctype.h>
-#include <string.h>
-
-
#include "manual.h"
-
-
%}
+
%option noyywrap
%option nounput
- //%option noinput
%option yylineno
%option stack
%option noyy_top_state
- //%option reentrant
- //%option bison-bridge
-
-/* %option bison-bridge */
-/* %option bison-locations */
-/* %option ecs */
-/* %option nodefault */
-/* %option noyywrap */
-/* %option reentrant */
-
%x comments
@@ -52,81 +30,65 @@
%x raw_line
-
%%
-[ \t\n]+ { }
-
-"/*" { BEGIN(comments); }
-<comments>"*/" { BEGIN(INITIAL); }
-<comments>[^*\n] { }
-<comments>"Copyright"[^\n]* { yylvalp->string = strdup(yytext); return COPYRIGHT; }
-<comments>"*" { }
-<comments>"\n" { }
-
-
-"@title" { BEGIN(ins_name); return TITLE; }
-
-<ins_name>[ ][A-Za-z-]+ { yylvalp->string = strdup(yytext + 1); BEGIN(try_details); return INS_NAME; }
-<try_details>[ ,/] { BEGIN(ins_details); }
-<try_details>[\n] { BEGIN(INITIAL); }
-
-<ins_details>[^\n]* { yylvalp->cstring = yytext; return INS_DETAILS; }
-<ins_details>[\n] { BEGIN(INITIAL); }
-
-
-
-"@encoding" { BEGIN(encoding); return ENCODING; }
-
-<encoding>[ ] { }
-<encoding>"(" { BEGIN(encoding_type); }
-
-<encoding_type>[A-Za-z] { yylvalp->string = strdup(yytext); return TYPE; }
-<encoding_type>[0-9]+ { yylvalp->integer = atoi(yytext); return NUMBER; }
-<encoding_type>")" { BEGIN(encoding); }
-
-<encoding>"{" { BEGIN(encoding_content); }
-<encoding_content>[ \t\n]+ { }
-<encoding_content>"}" { BEGIN(INITIAL); }
-
-
-
-<encoding_content>"@half " { yy_push_state(raw_line); return HALF; }
-<encoding_content>"@word " { yy_push_state(raw_line); return WORD; }
-
-
-<raw_line>[^\n]+ { yylvalp->cstring = yytext; return RAW_LINE; }
-<raw_line>"\n" { yy_pop_state(); }
+[ \t\n]+ { }
+"/*" { BEGIN(comments); }
+<comments>"*/" { BEGIN(INITIAL); }
+<comments>[^*\n] { }
+<comments>"Copyright"[^\n]* { yylvalp->string = strdup(yytext); return COPYRIGHT; }
+<comments>"*" { }
+<comments>"\n" { }
+"@title" { BEGIN(ins_name); return TITLE; }
-<encoding_content>"@syntax " { yy_push_state(raw_line); return SYNTAX; }
+<ins_name>[ ][A-Za-z-]+ { yylvalp->string = strdup(yytext + 1); BEGIN(try_details); return INS_NAME; }
+<try_details>[ ,/-] { BEGIN(ins_details); yylvalp->character = yytext[0]; return INS_SEP; }
+<try_details>[\n] { BEGIN(INITIAL); }
+<ins_details>[^\n]* { yylvalp->cstring = yytext; return INS_DETAILS; }
+<ins_details>[\n] { BEGIN(INITIAL); }
+"@encoding" { BEGIN(encoding); return ENCODING; }
-<encoding_content>"@conv" { return CONV; }
+<encoding>[ ] { }
+<encoding>"(" { BEGIN(encoding_type); }
+<encoding_type>[A-Za-z] { yylvalp->string = strdup(yytext); return TYPE; }
+<encoding_type>[0-9]+ { yylvalp->integer = atoi(yytext); return NUMBER; }
+<encoding_type>")" { BEGIN(encoding); }
+<encoding>"{" { BEGIN(encoding_content); }
+<encoding_content>[ \t\n]+ { }
+<encoding_content>"}" { BEGIN(INITIAL); }
-<encoding_content>"{" {
- read_block(temp);
- yylvalp->cstring = temp; return RAW_BLOCK;
- }
+<encoding_content>"@format" { yy_push_state(raw_line); return FORMAT; }
+<encoding_content>"@half" { yy_push_state(raw_line); return HALF; }
+<encoding_content>"@word" { yy_push_state(raw_line); return WORD; }
+<encoding_content>"@syntax" { yy_push_state(raw_line); return SYNTAX; }
+<encoding_content>"@conv" { return CONV; }
+<encoding_content>"@hooks" { return HOOKS; }
+<encoding_content>"@rules" { return RULES; }
-<encoding_content>"@hooks" { return HOOKS; }
+<raw_line>[^\n]+ { yylvalp->cstring = yytext; return RAW_LINE; }
+<raw_line>"\n" { yy_pop_state(); }
-<encoding_content>"@rules" { return RULES; }
+<encoding_content>"{" {
+ read_block(temp);
+ yylvalp->cstring = temp; return RAW_BLOCK;
+ }
%%