Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / mbkspf / spf.l
1 %{
2 #include <string.h>
3 #include "y.tab.h"
4
5 #define YY_NO_UNPUT
6
7 extern int spf_Line ;
8 static int spf_i, ripmod, outputeol=0 ;
9
10 void debug()
11 {
12 }
13
14 //#devicename {alphanum}({hdiv}|{alphanum}|{vector})*
15 %}
16 %s IDENTIFIER
17 %x COMMENT DOT RIPITALL
18
19 upper_alpha [A-Z]
20 lower_alpha [a-z]
21 num [0-9]
22 space [ \t]
23 eol \n
24 eolcont \n[ \t]*\+
25 emptyline \n[ \t]*$
26 alpha ({upper_alpha}|{lower_alpha})
27 alphanum ({alpha}|{num})
28 version {num}+(\.{num})+
29 integer {num}+
30 number -?{num}+(\.({num}*))?
31 enumber -?{num}+(\.({num}*))?(e|E)[+|-]?{num}+
32 v0 (\[{num}+\])
33 v1 (\<{num}+\>)
34 v2 (\{{num}+\})
35 v3 (\({num}+\))
36 v4 (\\\[{num}+\\\])
37 vector ({v0}|{v1}|{v2}|{v3}|{v4})
38 hdiv ([[./:_|@#\$%\-!+\\'`~,;=\?\^\&\*])
39 identifier [^() \t\n."'*][^() \t\n]*
40 qstring "\"".*"\""
41 resistor ^(r|R){identifier}
42 capacity ^(c|C){identifier}
43 startbar ^\*\|{space}*
44 aste \*
45 dollar \$
46 begindot ^[ \t]*\.
47 %%
48 ^\* { BEGIN RIPITALL; ripmod=0;}
49 {startbar}[^ ]+ {
50 outputeol=1;
51 if (strcasecmp(yytext,"*|p")==0) return (_PIN);
52 if (strcasecmp(yytext,"*|i")==0) return (_INST);
53 if (strcasecmp(yytext,"*|s")==0) return (_SUB);
54
55 ripmod=0;
56 if (strcasecmp(yytext,"*|design")==0) return (_DESIGN) ;
57 if (strcasecmp(yytext,"*|date")==0) return (_DATE) ;
58 if (strcasecmp(yytext,"*|vendor")==0) return (_VENDOR) ;
59 if (strcasecmp(yytext,"*|program")==0) return (_PROGRAM) ;
60 if (strcasecmp(yytext,"*|version")==0) return (_VERSION) ;
61 if (strcasecmp(yytext,"*|dspf")==0) return (_DSPF) ;
62 if (strcasecmp(yytext,"*|ground_net")==0) return (_GROUND_NET) ;
63 if (strcasecmp(yytext,"*|net")==0) return (_NET) ;
64
65 BEGIN RIPITALL;
66 if (strcasecmp(yytext,"*|divider")==0) ripmod=1;
67 if (strcasecmp(yytext,"*|delimiter")==0) ripmod=2;
68 if (strcasecmp(yytext,"*|busbit")==0) ripmod=3;
69
70 if (ripmod==0) {outputeol=0;}
71 }
72 <RIPITALL>.*$ {BEGIN INITIAL;
73 if (ripmod==1) { sprintf(spflval.text, "*|divider%s", yytext); return _DIVIDER; }
74 if (ripmod==2) { sprintf(spflval.text, "*|delimiter%s", yytext); return _DELIMITER; }
75 if (ripmod==3) { sprintf(spflval.text, "*|busbit%s", yytext); return _BUSBIT; }
76 }
77 {eol} {
78 spf_Line++;
79 if (outputeol)
80 {
81 outputeol=0;
82 return (_ENDOFSPICELINE);
83 }
84 }
85
86 {eolcont} {spf_Line++; }
87 {emptyline} {spf_Line++; }
88 {space} { /* separators */ }
89 \( {return (_LEFTPAR) ; }
90 \) {return (_RIGHTPAR) ; }
91 <COMMENT>{eolcont}.*$ {spf_Line++;}
92 <COMMENT>{emptyline} {spf_Line++;}
93 <COMMENT>{eol} {BEGIN INITIAL; spf_Line++;}
94 <COMMENT>.* {BEGIN INITIAL; spf_Line++;}
95 {begindot}[Ss][Uu][Bb][cC][kK][tT] {BEGIN INITIAL; outputeol=1; return (_SUBCKT) ; /* native */ }
96 {begindot}[Ee][nN][dD] {BEGIN INITIAL; outputeol=1; return (_END) ; /* SPICE */ }
97 {begindot}[eE][nN][dD][sS] {BEGIN INITIAL; outputeol=1; return (_ENDS) ; /* statements */ }
98 {begindot}. {BEGIN COMMENT;}
99 {resistor} {outputeol=1; strcpy(spflval.text, yytext) ; return (_RESISTANCE) ; }
100 {capacity} {outputeol=1; strcpy(spflval.text, yytext) ; return (_CAPACITANCE) ; }
101
102 ^[ \t]*\+ {}
103 ^[ \t]*[abABd-qD-Qs-zS-Z].*$ {BEGIN COMMENT;}
104
105 {dollar}.*$ {}
106
107 {qstring} {strcpy(spflval.text, yytext) ; return (_QSTRING) ; }
108 {identifier} {strcpy(spflval.text, yytext) ; return (_TEXT) ; }
109 . {outputeol=1; return *yytext;}
110 %%
111
112 int yywrap() { return 1; }