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.cc37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/lexer.in.cc b/src/lexer.in.cc
index 852d6e9..ec3ad6b 100644
--- a/src/lexer.in.cc
+++ b/src/lexer.in.cc
@@ -89,24 +89,25 @@ const char* Lexer::TokenName(Token t) {
return NULL; // not reached
}
-const char* Lexer::TokenErrorHint(Token t) {
- switch (t) {
- case ERROR: return "";
- case BUILD: return "";
- case COLON: return " ($ also escapes ':')";
- case DEFAULT: return "";
- case EQUALS: return "";
- case IDENT: return "";
- case INCLUDE: return "";
- case INDENT: return "";
- case NEWLINE: return "";
- case PIPE2: return "";
- case PIPE: return "";
- case RULE: return "";
- case SUBNINJA: return "";
- case TEOF: return "";
+const char* Lexer::TokenErrorHint(Token expected) {
+ switch (expected) {
+ case COLON:
+ return " ($ also escapes ':')";
+ default:
+ return "";
+ }
+}
+
+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";
+ }
}
- return "";
+ return "lexing error";
}
void Lexer::UnreadToken() {
@@ -248,7 +249,7 @@ bool Lexer::ReadEvalString(EvalString* eval, bool path, string* err) {
}
[^] {
last_token_ = start;
- return Error("lexing error", err);
+ return Error(DescribeLastError(), err);
}
*/
}