cminus/submit/ast/Call.java

38 lines
719 B
Java

/*
* Code formatter project
* CS 4481
*/
package submit.ast;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author edwajohn
*/
public class Call extends AbstractNode implements Expression {
private final String id;
private final List<Expression> args;
public Call(String id, List<Expression> args) {
this.id = id;
this.args = new ArrayList<>(args);
}
@Override
public void toCminus(StringBuilder builder, String prefix) {
builder.append(id).append("(");
for (Expression arg : args) {
arg.toCminus(builder, prefix);
builder.append(", ");
}
if (!args.isEmpty()) {
builder.setLength(builder.length() - 2);
}
builder.append(")");
}
}