summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-04-05 19:17:24 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-04-05 19:17:24 +0200
commit696d94d796f76d1d83c740b184f0cf8b9cbfc9d3 (patch)
treeb941b0d3651587ba48e091a6c2a1d2916e7df1e2 /src
parenta4c2f94f8b14db9489b202c8dff21880e9c1f739 (diff)
downloadsolar-696d94d796f76d1d83c740b184f0cf8b9cbfc9d3.tar
solar-696d94d796f76d1d83c740b184f0cf8b9cbfc9d3.zip
lex: handle preprocesser directives embedded into code blocks
Diffstat (limited to 'src')
-rw-r--r--src/lex.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lex.cpp b/src/lex.cpp
index 70362a7..851ac87 100644
--- a/src/lex.cpp
+++ b/src/lex.cpp
@@ -256,6 +256,7 @@ int lex_t::lex_block(parser_value_t *value) {
bool line_comment = false;
bool block_comment = false;
bool str = false;
+ bool pp = false;
size_t pos = 0;
size_t len = 1024;
@@ -272,7 +273,7 @@ int lex_t::lex_block(parser_value_t *value) {
char cur = current();
if (line_comment) {
- if (cur == '\n' || cur == '\r')
+ if (cur == '\n')
line_comment = false;
}
else if (block_comment) {
@@ -283,6 +284,10 @@ int lex_t::lex_block(parser_value_t *value) {
if (prev != '\\' && cur == '"')
str = false;
}
+ else if (pp) {
+ if (prev != '\\' && cur == '\n')
+ pp = false;
+ }
else {
if (cur == '{') {
parens++;
@@ -296,6 +301,9 @@ int lex_t::lex_block(parser_value_t *value) {
else if (cur == '"') {
str = true;
}
+ else if (cur == '#') {
+ pp = true;
+ }
else if (prev == '/' && cur == '/') {
line_comment = true;
}