Refactor code

This commit is contained in:
Mike Cifelli 2017-11-19 10:54:51 -05:00
parent 1fbc74f3ac
commit 0f00e35518
2 changed files with 3 additions and 3 deletions

View File

@ -22,7 +22,7 @@ public class RightParenthesis extends Token {
} }
@Override @Override
public TailCall<SExpression> parseListBackwards(Cons accumulator, Supplier<Token> getNextToken) { public TailCall<Cons> parseListBackwards(Cons accumulator, Supplier<Token> getNextToken) {
return done(accumulator); return done(accumulator);
} }

View File

@ -40,12 +40,12 @@ public abstract class Token {
public abstract SExpression parseSExpression(Supplier<Token> getNextToken); public abstract SExpression parseSExpression(Supplier<Token> getNextToken);
public SExpression parseSExpressionTail(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(); 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); Cons nextAccumulator = new Cons(parseSExpression(getNextToken), accumulator);
Token next = getNextToken.get(); Token next = getNextToken.get();