-
Notifications
You must be signed in to change notification settings - Fork 6
/
h5mlex.l
35 lines (25 loc) · 882 Bytes
/
h5mlex.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
/*made by elodream copyright elodream 2022*/
/*scanner for h5maker file */
%option noyywrap
%option header-file="h5mlex.hpp"
%{
#include "h5mparse.hxx"
#include <iostream>
#include<fstream>
using namespace std;
string location;
%}
%x locenv
var [a-zA-Z]+[0-9]*
%%
"\"" { location.clear(); BEGIN(locenv); }
<locenv>"\"" { BEGIN(INITIAL);yylval.str=(char*)malloc(sizeof(char)*location.size());sprintf(yylval.str,"%s",location.c_str());return(PATH); }
<locenv><<EOF>> { BEGIN(INITIAL);yylval.str=new char[location.size()+1] ;sprintf(yylval.str,"%s",location.c_str());return(PATH); }
<locenv>. { location+=yytext[0]; }
";" {return SEMI;}
"=" {return EQUAL;}
{var} {yylval.str=new char[strlen(yytext)]; return VAR;}
"{" {return LBRACE;}
"}" {return RBRACE;}
"\n" {}
%%