summaryrefslogtreecommitdiffstats
path: root/src/lexer.in.cc
diff options
context:
space:
mode:
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;
}