Performed some minor code cleanup
This commit is contained in:
parent
6f4a319dab
commit
064f905045
|
@ -14,15 +14,15 @@ public class Eof extends Token {
|
|||
|
||||
@Override
|
||||
public SExpression parseSExpression(Supplier<Token> getNextToken) {
|
||||
throw new EofEncounteredException(this);
|
||||
throw new EofEncounteredException(getPosition());
|
||||
}
|
||||
|
||||
public static class EofEncounteredException extends LineColumnException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public EofEncounteredException(Token token) {
|
||||
super(token.getPosition());
|
||||
public EofEncounteredException(FilePosition position) {
|
||||
super(position);
|
||||
}
|
||||
|
||||
public String getMessagePrefix() {
|
||||
|
|
|
@ -15,7 +15,7 @@ public class RightParenthesis extends Token {
|
|||
|
||||
@Override
|
||||
public SExpression parseSExpression(Supplier<Token> getNextToken) {
|
||||
throw new StartsWithRightParenthesisException(this);
|
||||
throw new StartsWithRightParenthesisException(getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,12 +27,12 @@ public class RightParenthesis extends Token {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public StartsWithRightParenthesisException(Token token) {
|
||||
super(token.getPosition());
|
||||
public StartsWithRightParenthesisException(FilePosition position) {
|
||||
super(position);
|
||||
}
|
||||
|
||||
public String getMessagePrefix() {
|
||||
return "Expression begins with ')'";
|
||||
return "expression begins with ')'";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,18 +27,6 @@ public abstract class Token {
|
|||
return position;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return position.getFileName();
|
||||
}
|
||||
|
||||
public int getLine() {
|
||||
return position.getLineNumber();
|
||||
}
|
||||
|
||||
public int getColumn() {
|
||||
return position.getColumnNumber();
|
||||
}
|
||||
|
||||
// sExpr ::= NUMBER | IDENTIFIER | STRING | QUOTE_MARK sExpr | LEFT_PAREN sExprTail
|
||||
public abstract SExpression parseSExpression(Supplier<Token> getNextToken);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class ErrorManagerTester {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.indicatorSet = new HashSet<>();
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.io.InputStream;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import file.FilePosition;
|
||||
import token.Token;
|
||||
|
||||
public class LispScannerLineColumnTester {
|
||||
|
@ -24,8 +25,8 @@ public class LispScannerLineColumnTester {
|
|||
return lineColumn;
|
||||
}
|
||||
|
||||
public boolean isEqual(Token token) {
|
||||
return (this.line == token.getLine()) && (this.column == token.getColumn());
|
||||
public boolean isEqual(FilePosition position) {
|
||||
return (this.line == position.getLineNumber()) && (this.column == position.getColumnNumber());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +36,7 @@ public class LispScannerLineColumnTester {
|
|||
|
||||
for (LineColumn lineColumn : expectedLineColumnList) {
|
||||
Token nextToken = lispScanner.getNextToken();
|
||||
assertTrue(lineColumn.isEqual(nextToken));
|
||||
assertTrue(lineColumn.isEqual(nextToken.getPosition()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.io.InputStream;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import file.FilePosition;
|
||||
|
||||
public class LispScannerTextTester {
|
||||
|
||||
private void assertTokenTextMatches(String input, String[] expectedTextList) {
|
||||
|
@ -31,8 +33,9 @@ public class LispScannerTextTester {
|
|||
private void assertInputFileNameMatches(String input, String expectedInputFileName) {
|
||||
InputStream stringInputStream = createInputStreamFromString(input);
|
||||
LispScanner lispScanner = new LispScanner(stringInputStream, expectedInputFileName);
|
||||
FilePosition tokenPosition = lispScanner.getNextToken().getPosition();
|
||||
|
||||
assertEquals(expectedInputFileName, lispScanner.getNextToken().getFileName());
|
||||
assertEquals(expectedInputFileName, tokenPosition.getFileName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue