throw new UnendedLineException("An object declaration must have a body.");
source = (Token) source.getCar();
ArrayList<Token> lines = Interpreter.splitLines(source);
ArrayList<Pair<Access, Token>> staticObjects = new ArrayList<>(), staticMethods = new ArrayList<>(), staticVariables = new ArrayList<>();
while (lines.size() > 0) {
Token line = lines.remove(0);
Access access = Access.DEFAULT;
boolean use = false;
while (!line.isNull()) {
if (line.getCarType().equals(interpreter.importType)) {
use = true;
access = Access.PUBLIC;
break;
}
else if (line.getCarType().equals(Interpreter.scopeType)) {
access = Access.getAccess((String) line.getCar());
}
else if (line.getCarType().equals(Interpreter.staticType))
use = true;
else
break;
line = line.getNextToken();
}
//object [name] (extends <type>)? {body}
if (line.getCarType().equals(Interpreter.classType)) {
if (use) {
staticObjects.add(new Pair<>(access, line));
String nme;
frames[access.intValue()].addType((nme = (String) (line = line.getNextToken()).getCar()),
new InterpreterClass(nme, (line = line.getNextToken()).getNextToken(), frames[3], new Type<InterpreterClass>(nme)));
}
else
objects.add(new Pair<>(access, line));
}
else {
//Constructor
if (!use && line.getCar().equals(getName()) && line.getNextToken().getCarType().equals(Interpreter.parenthesesType))
methods.add(new Pair<>(access, line));
//Function
else if (line.getCarType().equals(Interpreter.identifierType) && line.getNextToken().getCarType().equals(Interpreter.identifierType) &&
line.getNextToken().getNextToken().getCarType().equals(Interpreter.parenthesesType))
if (use)
staticMethods.add(new Pair<>(access, line));
else
methods.add(new Pair<>(access, line));
//Variables
else if (use)
staticVariables.add(new Pair<>(access, line));
else
variables.add(new Pair<>(access, line));
}
}
construct(staticObjects, staticMethods, staticVariables, frames);
frames[0].writeVariable("class", new Token(this, getTokenType()), true); //Adds .class
}