package calculator.interpreter.ast;
import java.util.LinkedList;
import calculator.interpreter.Cell;
import calculator.interpreter.Environment;
import calculator.interpreter.ast.meta.Annotation;
import calculator.interpreter.ast.meta.DocumentationLine;
/**
* The base statement class
*/
public abstract class Statement extends Node {
/** the annotations associated with statement */
public final LinkedList<Annotation> annotations = new LinkedList<Annotation>();
/** the documentation lines associated with statement */
public final LinkedList<DocumentationLine> documentation = new LinkedList<DocumentationLine>();
/**
* @return true if the statement has metadata
*/
public boolean hasMetadata() {
return !annotations.isEmpty() || !documentation.isEmpty();
}
/**
* The evaluate statement
*
* @param env the evaluation environment
* @param result the evaluation result (the cell might be null, in that case
* the result must be discarded).
* @return new context (if environment is not changed returns {@code env}
* argument)
*/
public abstract Environment eval(Environment env, Cell result);
}