@@ -92,7 +92,7 @@ namespace Yosys
9292
9393 class LibertyInputStream {
9494 std::istream &f;
95- std::vector<char > buffer;
95+ std::vector<unsigned char > buffer;
9696 size_t buf_pos = 0 ;
9797 size_t buf_end = 0 ;
9898 bool eof = false ;
@@ -107,7 +107,7 @@ namespace Yosys
107107 LibertyInputStream (std::istream &f) : f(f) {}
108108
109109 size_t buffered_size () { return buf_end - buf_pos; }
110- const char *buffered_data () { return buffer.data () + buf_pos; }
110+ const unsigned char *buffered_data () { return buffer.data () + buf_pos; }
111111
112112 int get () {
113113 if (buf_pos == buf_end)
@@ -165,7 +165,7 @@ namespace Yosys
165165
166166 void report_unexpected_token (int tok);
167167 void parse_vector_range (int tok);
168- LibertyAst *parse ();
168+ LibertyAst *parse (bool top_level );
169169 void error () const ;
170170 void error (const std::string &str) const ;
171171
@@ -174,18 +174,29 @@ namespace Yosys
174174 const LibertyAst *ast = nullptr ;
175175
176176 LibertyParser (std::istream &f) : f(f), line(1 ) {
177- shared_ast.reset (parse ());
177+ shared_ast.reset (parse (true ));
178178 ast = shared_ast.get ();
179+ if (!ast) {
180+ #ifdef FILTERLIB
181+ fprintf (stderr, " No entries found in liberty file.\n " );
182+ exit (1 );
183+ #else
184+ log_error (" No entries found in liberty file.\n " );
185+ #endif
186+ }
179187 }
180188
181189#ifndef FILTERLIB
182190 LibertyParser (std::istream &f, const std::string &fname) : f(f), line(1 ) {
183191 shared_ast = LibertyAstCache::instance.cached_ast (fname);
184192 if (!shared_ast) {
185- shared_ast.reset (parse ());
193+ shared_ast.reset (parse (true ));
186194 LibertyAstCache::instance.parsed_ast (fname, shared_ast);
187195 }
188196 ast = shared_ast.get ();
197+ if (!ast) {
198+ log_error (" No entries found in liberty file `%s'.\n " , fname.c_str ());
199+ }
189200 }
190201#endif
191202 };
0 commit comments