diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-05-25 15:40:06 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-05-25 15:40:06 +0200 |
commit | 427efeae13912b66e1c030c7645a2b1f322dff4d (patch) | |
tree | cb263ab770942ebbba3ea631288385b392c4e08c /build2/cc/lexer.cxx | |
parent | 71d9aedda0919fb22e39d6e6ce60506ceb69812e (diff) |
Fix few bugs in C++ lexer and parser
Diffstat (limited to 'build2/cc/lexer.cxx')
-rw-r--r-- | build2/cc/lexer.cxx | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/build2/cc/lexer.cxx b/build2/cc/lexer.cxx index 3eb5d5b..05c734c 100644 --- a/build2/cc/lexer.cxx +++ b/build2/cc/lexer.cxx @@ -76,7 +76,7 @@ namespace build2 using type = token_type; void lexer:: - next (token& t, xchar c) + next (token& t, xchar c, bool ignore_pp) { for (;; c = skip_spaces ()) { @@ -101,18 +101,27 @@ namespace build2 // that we assume there cannot be #include directives. // // This may not work for things like #error that can contain - // pretty much anything. + // pretty much anything. Also note that lines that start with + // # can contain # further down. // - for (;;) + if (ignore_pp) { - c = skip_spaces (false); // Stop at newline. + for (;;) + { + c = skip_spaces (false); // Stop at newline. - if (eos (c) || c == '\n') - break; + if (eos (c) || c == '\n') + break; - next (t, c); // Keep using the passed token for buffers. + next (t, c, false); // Keep using the passed token for buffers. + } + break; + } + else + { + t.type = type::punctuation; + return; } - break; } // Single-letter punctuation. // |