예제 #1
0
 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));
   }
 }
예제 #2
0
 @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;
 }
예제 #3
0
 public Sequence(Iterable<TypedAST> first) {
   exps = new LinkedList<TypedAST>();
   for (TypedAST elem : first) exps.add(check(elem));
 }
예제 #4
0
 public Sequence(TypedAST first) {
   exps.add(check(first));
 }
예제 #5
0
 public int size() {
   return exps.size();
 }
예제 #6
0
 public TypedAST getLast() {
   return exps.getLast();
 }
예제 #7
0
 @Override
 public Iterator<TypedAST> iterator() {
   return exps.iterator();
 }
예제 #8
0
 @Override
 public void writeArgsToTree(TreeWriter writer) {
   writer.writeArgs(exps.toArray());
   // TODO Auto-generated method stub
 }