diff options
author | Eddie Hung <eddieh@ece.ubc.ca> | 2019-04-03 03:36:11 -0700 |
---|---|---|
committer | Eddie Hung <eddieh@ece.ubc.ca> | 2019-04-03 03:36:11 -0700 |
commit | d8465590ac8d66f6f522aae1007d25abb7efd4d5 (patch) | |
tree | 927878c0ace042920149d72fe0443f569bd5e54c /passes/techmap/libparse.cc | |
parent | f9fb05cf6684d855ce2fc776a20cd5552a4ef4a8 (diff) | |
parent | 721fa1cbd87c52a3adfce260f35fc33a7ae7ac4d (diff) | |
download | yosys-d8465590ac8d66f6f522aae1007d25abb7efd4d5.tar.gz yosys-d8465590ac8d66f6f522aae1007d25abb7efd4d5.tar.bz2 yosys-d8465590ac8d66f6f522aae1007d25abb7efd4d5.zip |
Merge remote-tracking branch 'origin/master' into xc7srl
Diffstat (limited to 'passes/techmap/libparse.cc')
-rw-r--r-- | passes/techmap/libparse.cc | 61 |
1 files changed, 54 insertions, 7 deletions
diff --git a/passes/techmap/libparse.cc b/passes/techmap/libparse.cc index 8eadd8735..991cc4498 100644 --- a/passes/techmap/libparse.cc +++ b/passes/techmap/libparse.cc @@ -155,11 +155,13 @@ int LibertyParser::lexer(std::string &str) // check for a backslash if (c == '\\') { - c = f.get(); + c = f.get(); if (c == '\r') c = f.get(); - if (c == '\n') + if (c == '\n') { + line++; return lexer(str); + } f.unget(); return '\\'; } @@ -186,14 +188,39 @@ LibertyAst *LibertyParser::parse() int tok = lexer(str); - while (tok == 'n') + // there are liberty files in the wild that + // have superfluous ';' at the end of + // a { ... }. We simply ignore a ';' here. + // and get to the next statement. + + while ((tok == 'n') || (tok == ';')) tok = lexer(str); if (tok == '}' || tok < 0) return NULL; - if (tok != 'v') - error(); + if (tok != 'v') { + std::string eReport; + switch(tok) + { + case 'n': + error("Unexpected newline."); + break; + case '[': + case ']': + case '}': + case '{': + case '\"': + case ':': + eReport = "Unexpected '"; + eReport += static_cast<char>(tok); + eReport += "'."; + error(eReport); + break; + default: + error(); + } + } LibertyAst *ast = new LibertyAst; ast->id = str; @@ -282,8 +309,28 @@ LibertyAst *LibertyParser::parse() } continue; } - if (tok != 'v') - error(); + if (tok != 'v') { + std::string eReport; + switch(tok) + { + case 'n': + error("Unexpected newline."); + break; + case '[': + case ']': + case '}': + case '{': + case '\"': + case ':': + eReport = "Unexpected '"; + eReport += static_cast<char>(tok); + eReport += "'."; + error(eReport); + break; + default: + error(); + } + } ast->args.push_back(arg); } continue; |