File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed
regression/verilog/preprocessor Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 1+ CORE
2+ multi-line-define1.v
3+ --preprocess
4+ // Enable multi-line checking
5+ activate-multi-line-match
6+ `line 1 "multi-line-define1.v" 0
7+
8+ A
9+ B
10+ C
11+ ^EXIT=0$
12+ ^SIGNAL=0$
13+ --
14+ ^PREPROCESSING FAILED$
Original file line number Diff line number Diff line change 1+ `define foo A \
2+ B \
3+ C
4+ `foo
Original file line number Diff line number Diff line change @@ -362,13 +362,23 @@ void verilog_preprocessort::directive()
362362 // skip whitespace
363363 tokenizer ().skip_ws ();
364364
365- // Read any tokens until end of line.
365+ // Read any tokens until end of line,
366+ // but note that \n can be escaped with a backslash.
366367 // Note that any defines in this sequence
367368 // are not expanded at this point.
368369 while (!tokenizer ().eof () && tokenizer ().peek () != ' \n ' )
369370 {
370371 auto token = tokenizer ().next_token ();
371- define.tokens .push_back (std::move (token));
372+ if (token == ' \\ ' && tokenizer ().peek () == ' \n ' )
373+ {
374+ // Eat the newline, which is escaped.
375+ // Not clear whether the newline is meant to show
376+ // in the expansion.
377+ auto nl = tokenizer ().next_token ();
378+ define.tokens .push_back (std::move (nl));
379+ }
380+ else
381+ define.tokens .push_back (std::move (token));
372382 }
373383
374384#ifdef DEBUG
You can’t perform that action at this time.
0 commit comments