Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,47 @@
package jfkbits;
public class LispParser
{
LispTokenizer tokenizer;
public LispParser(LispTokenizer input)
{
tokenizer=input;
}
public class ParseException extends Exception
{
}
public interface Expr
{
// abstract parent for Atom and ExprList
}
public Expr parseExpr() throws ParseException
{
Token token = tokenizer.next();
switch(token.type)
{
case '(': return parseExprList(token);
case '"': return new StringAtom(token.text);
default: return new Atom(token.text);
}
}
protected ExprList parseExprList(Token openParen) throws ParseException
{
ExprList acc = new ExprList();
while(tokenizer.peekToken().type != ')')
{
Expr element = parseExpr();
acc.add(element);
}
Token closeParen = tokenizer.next();
return acc;
}
}