summaryrefslogtreecommitdiff
path: root/tools/d2c/tokens.l
blob: e48d07971f0a169bccf7b153b5c85849461d5267 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

%top {

#include "grammar.h"

}



%{

    //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

%x ins_name try_details ins_details
%x encoding encoding_type encoding_content

%x encoding_bits encoding_bits_size

%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(); }




<encoding_content>"@syntax "        { yy_push_state(raw_line); return SYNTAX; }





<encoding_content>"@conv"           { return CONV; }




<encoding_content>"{" {
    read_block(temp);
    yylvalp->cstring = temp; return RAW_BLOCK;
 }







<encoding_content>"@hooks"          { return HOOKS; }

<encoding_content>"@rules"          { return RULES; }


%%