public Sequence(TypedAST first, TypedAST second) { if (first instanceof Sequence) { exps.addAll(((Sequence) first).exps); } else if (first != null) { exps.add(check(first)); } if (second instanceof Sequence) { exps.addAll(((Sequence) second).exps); } else if (second != null) { exps.add(check(second)); } }
@Override public Type typecheck(Environment env, Optional<Type> expected) { Type lastType = new Unit(); for (TypedAST t : exps) { if (t == null) continue; lastType = t.typecheck(env, (exps.getLast() == t) ? expected : Optional.empty()); if (t instanceof EnvironmentExtender) env = ((EnvironmentExtender) t).extend(env, env); } retType = lastType; return lastType; }
public Sequence(Iterable<TypedAST> first) { exps = new LinkedList<TypedAST>(); for (TypedAST elem : first) exps.add(check(elem)); }
public Sequence(TypedAST first) { exps.add(check(first)); }
public int size() { return exps.size(); }
public TypedAST getLast() { return exps.getLast(); }
@Override public Iterator<TypedAST> iterator() { return exps.iterator(); }
@Override public void writeArgsToTree(TreeWriter writer) { writer.writeArgs(exps.toArray()); // TODO Auto-generated method stub }