15
15
*/
16
16
17
17
/* track line numbers*/
18
- %option yylineno
18
+ %option yylineno
19
19
20
20
/* No lexing accross files */
21
21
%option noyywrap
42
42
* Use a prefix to avoid name clashes with other
43
43
* flex lexers
44
44
*/
45
- %option prefix="blifparse_"
45
+ %option prefix="blifparse_"
46
46
47
47
/* Common character classes */
48
- ID_SET [^ \t\r\n\\ = ]
48
+ ID_SET [^ \t\r\n\\ =" ]
49
49
BACK_SLASH [\\ ]
50
50
WS [ \t ]
51
51
ENDL (\n | \n\r | \r\n )
@@ -63,37 +63,37 @@ ENDL (\n|\n\r|\r\n)
63
63
return blifparse::Parser::make_EOL ();
64
64
}
65
65
^ {WS }* {ENDL } { /* Ignore blank lines. */ }
66
- \\ {ENDL }{WS }* {ENDL } {
67
- /*
68
- * Do forward end of line if the last line was a continuation.
66
+ \\ {ENDL }{WS }* {ENDL } {
67
+ /*
68
+ * Do forward end of line if the last line was a continuation.
69
69
*
70
- * Some times line continuations are followed by blank lines (which
71
- * are otherwise ignored). In these cases we *do* want to
72
- * forward EOL, so the parser knows the continued line has finished
73
- */
74
- return blifparse::Parser::make_EOL ();
70
+ * Some times line continuations are followed by blank lines (which
71
+ * are otherwise ignored). In these cases we *do* want to
72
+ * forward EOL, so the parser knows the continued line has finished
73
+ */
74
+ return blifparse::Parser::make_EOL ();
75
75
}
76
76
<* >\\ {ENDL } { /* line continuation (don't forward EOL to parser) */ }
77
- {ENDL } {
78
- return blifparse::Parser::make_EOL ();
77
+ {ENDL } {
78
+ return blifparse::Parser::make_EOL ();
79
79
}
80
80
<* >{WS }+ { /* skip white space */ }
81
- <* >\. names {
81
+ <* >\. names {
82
82
/*
83
83
* To process the single output cover rows of the names directly as symbols
84
84
* (rather than as strings) we use a special lexer state.
85
85
*/
86
86
BEGIN (NAMES);
87
- return blifparse::Parser::make_DOT_NAMES ();
87
+ return blifparse::Parser::make_DOT_NAMES ();
88
88
}
89
- <* >\. latch {
89
+ <* >\. latch {
90
90
/*
91
- * The initial state value of a latch is ambiguous (it chould be
91
+ * The initial state value of a latch is ambiguous (it chould be
92
92
* interpreted as a string or logic value string). So we use
93
93
* a special lexer state to capture it.
94
94
*/
95
- BEGIN (LATCH);
96
- return blifparse::Parser::make_DOT_LATCH ();
95
+ BEGIN (LATCH);
96
+ return blifparse::Parser::make_DOT_LATCH ();
97
97
}
98
98
<* >\. model { BEGIN (INITIAL); return blifparse::Parser::make_DOT_MODEL (); }
99
99
<* >\. subckt { BEGIN (INITIAL); return blifparse::Parser::make_DOT_SUBCKT (); }
@@ -107,6 +107,7 @@ ENDL (\n|\n\r|\r\n)
107
107
<* >\. param { BEGIN (INITIAL); return blifparse::Parser::make_DOT_PARAM (); /*BLIF extension */ }
108
108
<* >\. cname { BEGIN (INITIAL); return blifparse::Parser::make_DOT_CNAME (); /*BLIF extension */ }
109
109
110
+
110
111
= { return blifparse::Parser::make_EQ ();}
111
112
<LATCH >fe { return blifparse::Parser::make_LATCH_FE (); }
112
113
<LATCH >re { return blifparse::Parser::make_LATCH_RE (); }
@@ -118,43 +119,51 @@ ENDL (\n|\n\r|\r\n)
118
119
<LATCH >1 { return blifparse::Parser::make_LOGIC_TRUE (); }
119
120
<LATCH >2 { return blifparse::Parser::make_LATCH_INIT_2 (); }
120
121
<LATCH >3 { return blifparse::Parser::make_LATCH_INIT_3 (); }
121
- <LATCH >{ENDL } {
122
+ <LATCH >{ENDL } {
122
123
/*
123
124
* Latches are only every defined on a single line,
124
125
* so when we see the end of a line while in the LATCH
125
126
* state we can go back to the regular (INITIAL) state.
126
127
*/
127
- BEGIN (INITIAL); return blifparse::Parser::make_EOL ();
128
+ BEGIN (INITIAL); return blifparse::Parser::make_EOL ();
128
129
}
129
130
<SO_COVER >0 { return blifparse::Parser::make_LOGIC_FALSE (); }
130
131
<SO_COVER >1 { return blifparse::Parser::make_LOGIC_TRUE (); }
131
132
<SO_COVER >\- { return blifparse::Parser::make_LOGIC_DONT_CARE (); }
132
133
<SO_COVER >{ENDL } { return blifparse::Parser::make_EOL (); }
133
- <NAMES >{ENDL } {
134
+ <NAMES >{ENDL } {
134
135
/*
135
136
* Once we reach the end of a line in NAMES state (i.e. the end of a .names line)
136
137
* we expect the truth table (in single output cover format) to follow, so we enter
137
138
* the SO_COVER state.
138
139
*/
139
- BEGIN (SO_COVER);
140
- return blifparse::Parser::make_EOL ();
140
+ BEGIN (SO_COVER);
141
+ return blifparse::Parser::make_EOL ();
141
142
}
142
- <INITIAL ,NAMES ,LATCH >(({ID_SET }| {BACK_SLASH })* {ID_SET }) {
143
+ <INITIAL ,NAMES ,LATCH >([ \" ][ ^ \r\n\" ] * [ \" ]) | ( ({ID_SET }| {BACK_SLASH })* {ID_SET }) {
143
144
/*
144
- * We allow all sorts of characters in regular strings.
145
+ * There two types of STRING's this
146
+ * expression recognizes:
147
+ * - Quoted strings, with no string
148
+ * escape allowed, no line continuation
149
+ * allowed.
150
+ * - Unquoted strings.
151
+ *
152
+ * For the unquoted strings, we allow all
153
+ * sorts of characters in regular strings.
145
154
* However we need to be careful about line continuations
146
- * in particular, it is possible that we could have a string
147
- * followed by a continuation with no space for this reason,
148
- * we do not allow a continuation (backslash, \\ in escaped
155
+ * in particular, it is possible that we could have a string
156
+ * followed by a continuation with no space for this reason,
157
+ * we do not allow a continuation (backslash, \\ in escaped
149
158
* form in the regex) in the last character of the string.
150
159
*/
151
- return blifparse::Parser::make_STRING (blifparse_get_text (yyscanner));
160
+ return blifparse::Parser::make_STRING (blifparse_get_text (yyscanner));
152
161
}
153
162
<<EOF>> { /* If the file has no blank line at the end there will
154
- not be the expected EOL following the last command.
155
- So first time through, return EOL, and subsequently
163
+ not be the expected EOL following the last command.
164
+ So first time through, return EOL, and subsequently
156
165
return 0 (which indicated end of file). This ensures
157
- there will always be an EOL provided to the parser.
166
+ there will always be an EOL provided to the parser.
158
167
However it may also generate a stray EOL if the last
159
168
line IS blank - so the parser must handle those correclty. */
160
169
static bool once; return (once = !once) ? blifparse::Parser::make_EOL () : blifparse::Parser::make_EOF ();
0 commit comments