-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScanner.l
More file actions
43 lines (31 loc) · 859 Bytes
/
Scanner.l
File metadata and controls
43 lines (31 loc) · 859 Bytes
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
%{
#include "Parser.h"
#include "Constants.h"
#include <math.h>
int n_lines;
%}
%option noyywrap
%x COM
DIGIT [0-9]
%%
"//" BEGIN(COM);
<COM>"\n" BEGIN(0); n_lines++;
<COM>. ;
"x" yylval.value = TYPEX; return X;
"y" yylval.value = TYPEY; return Y;
"z" yylval.value = TYPEZ; return Z;
"id" yylval.value = TYPEID;return ID;
"h" yylval.value = TYPEH; return H;
"s" yylval.value = TYPES; return S;
"t" yylval.value = TYPET; return T;
"tdg" yylval.value = TYPETDG; return TDG;
"sdg" yylval.value = TYPESDG; return SDG;
"cx" return CX;
"repeat" return REPEAT;
"measure" yylval.value = TYPEMEASURE; return MEASURE;
"bloch" yylval.value = TYPEBLOCH; return BLOCH;
\n n_lines++;
{DIGIT}+ yylval.value = atoi(yytext); return NUMBER;
[\t\r ] ;
. return (yytext[0]);
%%