mirror of
https://github.com/AppleCommander/bastools.git
synced 2025-01-23 11:30:24 +00:00
Displaying a more intelligent error message with invalid tokens in the
input stream. #20
This commit is contained in:
parent
cc12f7ccba
commit
f729ef7c6d
@ -158,8 +158,18 @@ public class TokenReader {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new IOException(String.format(
|
||||
"Unknown! ttype=%d, nval=%f, sval=%s\n", tokenizer.ttype, tokenizer.nval, tokenizer.sval));
|
||||
String message = String.format("Unknown or unexpected character '%c'", tokenizer.ttype);
|
||||
if (tokenizer.ttype == StreamTokenizer.TT_WORD) {
|
||||
message = String.format("Unknown or unexpected string '%s'", tokenizer.sval);
|
||||
} else if (tokenizer.ttype == StreamTokenizer.TT_NUMBER) {
|
||||
message = String.format("Unknown or unexpected number %f", tokenizer.nval);
|
||||
} else if (tokenizer.ttype == StreamTokenizer.TT_EOF) {
|
||||
message = "Unexpected EOF";
|
||||
} else if (tokenizer.ttype == StreamTokenizer.TT_EOL) {
|
||||
message = "Unexpected EOL";
|
||||
}
|
||||
message += String.format(" found on line #%d", tokenizer.lineno());
|
||||
throw new IOException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user