summaryrefslogtreecommitdiffstats
path: root/src/lexer.in.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2014-10-30 23:35:33 (GMT)
committerNico Weber <nicolasweber@gmx.de>2014-10-30 23:35:33 (GMT)
commit99ee3e818f1e7fa059b3ff0974521d2e427f1c35 (patch)
tree8458820f009b6a20b00adeb129d5055b281d2386 /src/lexer.in.cc
parentb92c1a4fd731df4c1a408023cd0d0b691bf79f2f (diff)
parent65151e7eefce514febd0a9676c5363c6d4c54b66 (diff)
downloadNinja-99ee3e818f1e7fa059b3ff0974521d2e427f1c35.zip
Ninja-99ee3e818f1e7fa059b3ff0974521d2e427f1c35.tar.gz
Ninja-99ee3e818f1e7fa059b3ff0974521d2e427f1c35.tar.bz2
Merge pull request #840 from sgraham/canon-win-squashed
CanonicalizePath handles \ on Windows
Diffstat (limited to 'src/lexer.in.cc')
-rw-r--r--src/lexer.in.cc25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/lexer.in.cc b/src/lexer.in.cc
index 93d5540..f861239 100644
--- a/src/lexer.in.cc
+++ b/src/lexer.in.cc
@@ -102,8 +102,6 @@ const char* Lexer::TokenErrorHint(Token expected) {
string Lexer::DescribeLastError() {
if (last_token_) {
switch (last_token_[0]) {
- case '\r':
- return "carriage returns are not allowed, use newlines";
case '\t':
return "tabs are not allowed, use spaces";
}
@@ -132,8 +130,9 @@ Lexer::Token Lexer::ReadToken() {
simple_varname = [a-zA-Z0-9_-]+;
varname = [a-zA-Z0-9_.-]+;
- [ ]*"#"[^\000\r\n]*"\n" { continue; }
- [ ]*[\n] { token = NEWLINE; break; }
+ [ ]*"#"[^\000\n]*"\n" { continue; }
+ [ ]*"\r\n" { token = NEWLINE; break; }
+ [ ]*"\n" { token = NEWLINE; break; }
[ ]+ { token = INDENT; break; }
"build" { token = BUILD; break; }
"pool" { token = POOL; break; }
@@ -168,13 +167,15 @@ bool Lexer::PeekToken(Token token) {
void Lexer::EatWhitespace() {
const char* p = ofs_;
+ const char* q;
for (;;) {
ofs_ = p;
/*!re2c
- [ ]+ { continue; }
- "$\n" { continue; }
- nul { break; }
- [^] { break; }
+ [ ]+ { continue; }
+ "$\r\n" { continue; }
+ "$\n" { continue; }
+ nul { break; }
+ [^] { break; }
*/
}
}
@@ -207,6 +208,11 @@ bool Lexer::ReadEvalString(EvalString* eval, bool path, string* err) {
eval->AddText(StringPiece(start, p - start));
continue;
}
+ "\r\n" {
+ if (path)
+ p = start;
+ break;
+ }
[ :|\n] {
if (path) {
p = start;
@@ -226,6 +232,9 @@ bool Lexer::ReadEvalString(EvalString* eval, bool path, string* err) {
eval->AddText(StringPiece(" ", 1));
continue;
}
+ "$\r\n"[ ]* {
+ continue;
+ }
"$\n"[ ]* {
continue;
}