Skip to content

Commit 44a62c6

Browse files
authored
Merge pull request #1388 from litghost/update_libblifparse
Update libblifparse
2 parents f13e8bf + 2a3b399 commit 44a62c6

File tree

4 files changed

+69
-35
lines changed

4 files changed

+69
-35
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
language: cpp
2+
dist: trusty #Ubuntu 14.04 by default
3+
sudo: false #Use container based infrastructure
4+
5+
matrix:
6+
include:
7+
#Extensive testing for base compiler
8+
- env: MATRIX_EVAL="CC=gcc-5 CXX=g++-5"
9+
addons: { apt: { packages: ["cmake", "g++-5", "libtbb-dev", "flex", "bison"], sources: ["ubuntu-toolchain-r-test"] } }
10+
before_install:
11+
- eval "${MATRIX_EVAL}" #Set compiler versions
12+
- echo $CC
13+
- echo $CXX
14+
15+
script:
16+
#Build
17+
- mkdir -p build
18+
- pushd build
19+
- cmake ..
20+
- make -j2
21+
22+
#Test
23+
- ../test/test_parser.sh ../test

libs/EXTERNAL/libblifparse/src/blif_lexer.l

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
/* track line numbers*/
18-
%option yylineno
18+
%option yylineno
1919

2020
/* No lexing accross files */
2121
%option noyywrap
@@ -42,10 +42,10 @@
4242
* Use a prefix to avoid name clashes with other
4343
* flex lexers
4444
*/
45-
%option prefix="blifparse_"
45+
%option prefix="blifparse_"
4646

4747
/* Common character classes */
48-
ID_SET [^ \t\r\n\\=]
48+
ID_SET [^ \t\r\n\\="]
4949
BACK_SLASH [\\]
5050
WS [ \t]
5151
ENDL (\n|\n\r|\r\n)
@@ -63,37 +63,37 @@ ENDL (\n|\n\r|\r\n)
6363
return blifparse::Parser::make_EOL();
6464
}
6565
^{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.
6969
*
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();
7575
}
7676
<*>\\{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();
7979
}
8080
<*>{WS}+ { /* skip white space */ }
81-
<*>\.names {
81+
<*>\.names {
8282
/*
8383
* To process the single output cover rows of the names directly as symbols
8484
* (rather than as strings) we use a special lexer state.
8585
*/
8686
BEGIN(NAMES);
87-
return blifparse::Parser::make_DOT_NAMES();
87+
return blifparse::Parser::make_DOT_NAMES();
8888
}
89-
<*>\.latch {
89+
<*>\.latch {
9090
/*
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
9292
* interpreted as a string or logic value string). So we use
9393
* a special lexer state to capture it.
9494
*/
95-
BEGIN(LATCH);
96-
return blifparse::Parser::make_DOT_LATCH();
95+
BEGIN(LATCH);
96+
return blifparse::Parser::make_DOT_LATCH();
9797
}
9898
<*>\.model { BEGIN(INITIAL); return blifparse::Parser::make_DOT_MODEL(); }
9999
<*>\.subckt { BEGIN(INITIAL); return blifparse::Parser::make_DOT_SUBCKT(); }
@@ -107,6 +107,7 @@ ENDL (\n|\n\r|\r\n)
107107
<*>\.param { BEGIN(INITIAL); return blifparse::Parser::make_DOT_PARAM(); /*BLIF extension */}
108108
<*>\.cname { BEGIN(INITIAL); return blifparse::Parser::make_DOT_CNAME(); /*BLIF extension */}
109109

110+
110111
= { return blifparse::Parser::make_EQ();}
111112
<LATCH>fe { return blifparse::Parser::make_LATCH_FE(); }
112113
<LATCH>re { return blifparse::Parser::make_LATCH_RE(); }
@@ -118,43 +119,51 @@ ENDL (\n|\n\r|\r\n)
118119
<LATCH>1 { return blifparse::Parser::make_LOGIC_TRUE(); }
119120
<LATCH>2 { return blifparse::Parser::make_LATCH_INIT_2(); }
120121
<LATCH>3 { return blifparse::Parser::make_LATCH_INIT_3(); }
121-
<LATCH>{ENDL} {
122+
<LATCH>{ENDL} {
122123
/*
123124
* Latches are only every defined on a single line,
124125
* so when we see the end of a line while in the LATCH
125126
* state we can go back to the regular (INITIAL) state.
126127
*/
127-
BEGIN(INITIAL); return blifparse::Parser::make_EOL();
128+
BEGIN(INITIAL); return blifparse::Parser::make_EOL();
128129
}
129130
<SO_COVER>0 { return blifparse::Parser::make_LOGIC_FALSE(); }
130131
<SO_COVER>1 { return blifparse::Parser::make_LOGIC_TRUE(); }
131132
<SO_COVER>\- { return blifparse::Parser::make_LOGIC_DONT_CARE(); }
132133
<SO_COVER>{ENDL} { return blifparse::Parser::make_EOL(); }
133-
<NAMES>{ENDL} {
134+
<NAMES>{ENDL} {
134135
/*
135136
* Once we reach the end of a line in NAMES state (i.e. the end of a .names line)
136137
* we expect the truth table (in single output cover format) to follow, so we enter
137138
* the SO_COVER state.
138139
*/
139-
BEGIN(SO_COVER);
140-
return blifparse::Parser::make_EOL();
140+
BEGIN(SO_COVER);
141+
return blifparse::Parser::make_EOL();
141142
}
142-
<INITIAL,NAMES,LATCH>(({ID_SET}|{BACK_SLASH})*{ID_SET}) {
143+
<INITIAL,NAMES,LATCH>([\"][^\r\n\"]*[\"])|(({ID_SET}|{BACK_SLASH})*{ID_SET}) {
143144
/*
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.
145154
* 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
149158
* form in the regex) in the last character of the string.
150159
*/
151-
return blifparse::Parser::make_STRING(blifparse_get_text(yyscanner));
160+
return blifparse::Parser::make_STRING(blifparse_get_text(yyscanner));
152161
}
153162
<<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
156165
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.
158167
However it may also generate a stray EOL if the last
159168
line IS blank - so the parser must handle those correclty. */
160169
static bool once; return (once = !once) ? blifparse::Parser::make_EOL() : blifparse::Parser::make_EOF();

libs/EXTERNAL/libblifparse/test/eblif/test.eblif

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.inputs a b clk
33
.outputs o_dff
44

5-
.names 1\a 3 a_-1234567890~|:*/\[\]\.\{\}^+$;'"?<>
5+
.names 1\a 3 a_-1234567890~|:*/\[\]\.\{\}^+$;'?<>
66

77
.names a b \
88
a_and_b
@@ -16,6 +16,8 @@
1616
.cname my_dff
1717
.param parama param_valuea
1818
.param attra attr_valuea
19+
.param paramb " A B "
20+
.attr attrb "I have a space"
1921

2022
.conn dff_q o_dff
2123

libs/EXTERNAL/libblifparse/test/test_parser.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ do
1313
echo
1414
echo "File: $blif_file"
1515
#valgrind --leak-check=full --track-origins=yes ./blifparse_test $blif_file
16-
./blifparse_test $blif_file
16+
./blifparse_test $blif_file > blif_parse_test.log
1717
exit_code=$?
1818
if [[ $exit_code -ne 0 ]]; then
1919
echo "Error" >&2

0 commit comments

Comments
 (0)