summaryrefslogtreecommitdiff
path: root/tools/d2c/syntax/tokens.l
blob: ab1b0f321271d37d7d5ab2ca0186801bce51bac4 (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

%top {

#include "grammar.h"

}


%option noyywrap
%option nounput
%option noinput
%option yylineno
%option stack
%option noyy_top_state

%x named
%x internal
%x visible


%%


" "                     { }

"\""                    { yy_push_state(named); }
<named>[^ \"]+          { yylvalp->string = strdup(yytext); return OPERAND_NAME; }
<named>"\""             { yy_pop_state(); }

"{"                     { yy_push_state(internal); }
<internal>[^ }]+        { yylvalp->string = strdup(yytext); return OPERAND_INTERNAL; }
<internal>"}"           { yy_pop_state(); }

"<"                     { yy_push_state (visible); }
<visible>[^ >]+         { yylvalp->string = strdup(yytext); return OPERAND_VISIBLE; }
<visible>">"            { yy_pop_state(); }


%%