Refactor code
This commit is contained in:
parent
1fbc74f3ac
commit
0f00e35518
|
@ -22,7 +22,7 @@ public class RightParenthesis extends Token {
|
|||
}
|
||||
|
||||
@Override
|
||||
public TailCall<SExpression> parseListBackwards(Cons accumulator, Supplier<Token> getNextToken) {
|
||||
public TailCall<Cons> parseListBackwards(Cons accumulator, Supplier<Token> getNextToken) {
|
||||
return done(accumulator);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,12 +40,12 @@ public abstract class Token {
|
|||
public abstract SExpression parseSExpression(Supplier<Token> getNextToken);
|
||||
|
||||
public SExpression parseSExpressionTail(Supplier<Token> getNextToken) {
|
||||
Cons list = (Cons) parseListBackwards(NIL, getNextToken).invoke();
|
||||
Cons list = parseListBackwards(NIL, getNextToken).invoke();
|
||||
|
||||
return reverse(NIL, list).invoke();
|
||||
}
|
||||
|
||||
public TailCall<SExpression> parseListBackwards(Cons accumulator, Supplier<Token> getNextToken) {
|
||||
public TailCall<Cons> parseListBackwards(Cons accumulator, Supplier<Token> getNextToken) {
|
||||
Cons nextAccumulator = new Cons(parseSExpression(getNextToken), accumulator);
|
||||
Token next = getNextToken.get();
|
||||
|
||||
|
|
Loading…
Reference in New Issue