aboutsummaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorThomas Sailer <sailer@tsailer.ch>2021-08-25 21:34:26 +0200
committerZachary Snow <zachary.j.snow@gmail.com>2021-12-15 18:06:02 -0700
commit4cd2f03e36d09f936d39f8499e26fb0a2bc897f9 (patch)
tree9a18d32ec0ab99f5e197fd3fc00b152b7867b66c /frontends
parent477eeefd9b6c1c98ee5d41cdf407011cf40794a7 (diff)
downloadyosys-4cd2f03e36d09f936d39f8499e26fb0a2bc897f9.tar.gz
yosys-4cd2f03e36d09f936d39f8499e26fb0a2bc897f9.tar.bz2
yosys-4cd2f03e36d09f936d39f8499e26fb0a2bc897f9.zip
preprocessor: do not destroy double slash escaped identifiers
The preprocessor currently destroys double slash containing escaped identifiers (for example \a//b ). This is due to next_token trying to convert single line comments (//) into /* */ comments. This then leads to an unintuitive error message like this: ERROR: syntax error, unexpected '*' This patch fixes the error by recognizing escaped identifiers and returning them as single token. It also adds a testcase.
Diffstat (limited to 'frontends')
-rw-r--r--frontends/verilog/preproc.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/frontends/verilog/preproc.cc b/frontends/verilog/preproc.cc
index 17f567587..883531e78 100644
--- a/frontends/verilog/preproc.cc
+++ b/frontends/verilog/preproc.cc
@@ -142,6 +142,16 @@ static std::string next_token(bool pass_newline = false)
return_char(ch);
}
}
+ else if (ch == '\\')
+ {
+ while ((ch = next_char()) != 0) {
+ if (ch < 33 || ch > 126) {
+ return_char(ch);
+ break;
+ }
+ token += ch;
+ }
+ }
else if (ch == '/')
{
if ((ch = next_char()) != 0) {