No need to nest in else.

This commit is contained in:
Gary Gregory 2021-03-05 13:54:34 -05:00
parent 443cc4a051
commit 7df132a848
1 changed files with 12 additions and 6 deletions

View File

@ -300,14 +300,17 @@ final class Lexer implements Closeable {
if (isDelimiter(c)) { if (isDelimiter(c)) {
token.type = TOKEN; token.type = TOKEN;
return token; return token;
} else if (isEndOfFile(c)) { }
if (isEndOfFile(c)) {
token.type = EOF; token.type = EOF;
token.isReady = true; // There is data at EOF token.isReady = true; // There is data at EOF
return token; return token;
} else if (readEndOfLine(c)) { }
if (readEndOfLine(c)) {
token.type = EORECORD; token.type = EORECORD;
return token; return token;
} else if (!isWhitespace(c)) { }
if (!isWhitespace(c)) {
// error invalid char between token and next delimiter // error invalid char between token and next delimiter
throw new IOException("(line " + getCurrentLineNumber() + throw new IOException("(line " + getCurrentLineNumber() +
") invalid char between encapsulated token and delimiter"); ") invalid char between encapsulated token and delimiter");
@ -350,14 +353,17 @@ final class Lexer implements Closeable {
if (readEndOfLine(ch)) { if (readEndOfLine(ch)) {
token.type = EORECORD; token.type = EORECORD;
break; break;
} else if (isEndOfFile(ch)) { }
if (isEndOfFile(ch)) {
token.type = EOF; token.type = EOF;
token.isReady = true; // There is data at EOF token.isReady = true; // There is data at EOF
break; break;
} else if (isDelimiter(ch)) { }
if (isDelimiter(ch)) {
token.type = TOKEN; token.type = TOKEN;
break; break;
} else if (isEscape(ch)) { }
if (isEscape(ch)) {
final int unescaped = readEscape(); final int unescaped = readEscape();
if (unescaped == END_OF_STREAM) { // unexpected char after escape if (unescaped == END_OF_STREAM) { // unexpected char after escape
token.content.append((char) ch).append((char) reader.getLastChar()); token.content.append((char) ch).append((char) reader.getLastChar());