-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinst_lex.l
48 lines (30 loc) · 1.31 KB
/
inst_lex.l
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
%{
/*
* Copyright (c) 2020 Romain Dolbeau <[email protected]>
* MIT License
* See the LICENSE file at the top level of this software distribution for details.
*/
#include <stdio.h>
#include <stdlib.h>
#include "inst_par.h"
%}
CHAR [[:alnum:] ,'&./()-]
FCHARNAME [[:alpha:]]
CHARNAME [[:alnum:]_+-]
SPACE [ \t]
%%
^"I" { return INST; }
^"S" { return SEM; }
^"T" { return MEMSEM; }
^"P" { return PROL; }
^"E" { return EXTRA; }
"//".* { }
{FCHARNAME}{CHARNAME}{CHARNAME}* { yylval.string = strdup(yytext); return NAME; }
{CHARNAME}{32} { yylval.string = strdup(yytext); return NAME; }
"\"\"\""[^ù]*"\"\"\"" { yylval.string = strndup(yytext+3, strlen(yytext)-6); return STRING; }
"'''"[^ù]*"'''" { yylval.string = strndup(yytext+3, strlen(yytext)-6); return STRING; }
"\"".*"\"" { yylval.string = strndup(yytext+1, strlen(yytext)-2); return STRING; }
[0-9][0-9]* { yylval.num = atoi(yytext); return NUM; }
\n { return yytext[0]; }
{SPACE}+ { }
%%