-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcdlLex.l
49 lines (45 loc) · 937 Bytes
/
cdlLex.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
49
%{
#include"cdlParser.tab.h"
#include<stdlib.h>
#include<string.h>
%}
%%
[ \t\n]+ {}
^[m|M][0-9a-zA-Z_]+ {return TRANS;}
^[c|C][0-9a-zA-Z_]+ {return CAP;}
^[x|X][0-9a-zA-Z_]+ {return INSTANCE;}
^[d|D][0-9a-zA-Z_]+ {return DIODE;}
^[r|R][0-9a-zA-Z_]+ {return RESISTOR;}
[0-9\.-]+ {yylval.val=atof(yytext);return FNUMBER;}
\= {return EQUAL;}
^.ENDS {return ENDS;}
^.SUBCKT {return SUBCKT;}
^\+ {}
[a-zA-Z0-9_\-\[\]]* {
if(!strcmp(yytext,"U") || !strcmp(yytext,"u"))
{
return MICRON;
}
/*else if(!strcmp(yytext,"L"))
{
return LEN;
}
else if(!strcmp(yytext,"W"))
{
return WID;
} */
else
{
yylval.string=strdup(yytext);
return NAME;
}
}
%%
int yywrap()
{
return 1;
}
void yyerror(const char *s)
{
printf("\n\n%s at line no: in the line \n",s);
}