/** Our internal representation of a Paren * in the A0 language. * See http://www.radford.edu/itec380/2022spring-ibarland/Homeworks/Project/ * * @author Ian Barland * @version 2022.Apr.04 */ public record Paren(Expr e) implements Expr { static final String START_TOKEN = "/"; static final String STOP_TOKEN = "\\"; public String toString(/* Paren this */) { return START_TOKEN + this.e.toString() + STOP_TOKEN ; } public static Paren parse( java.util.Scanner s, String punctuation ) { UtilIan.verifyToken( UtilIan.nextSplittingBy(s,punctuation), START_TOKEN); // Consume the opening paren, and continue. // NOTE: recur with `Expr.parse` -- not `parse` = `Paren.parse` which is NOT what we want! Expr theInsideExpr = Expr.parse(s,punctuation); UtilIan.verifyToken( UtilIan.nextSplittingBy(s,punctuation), STOP_TOKEN); // Consume the closing paren, and continue. return new Paren(theInsideExpr); } public Value eval() { return this.e.eval(); } }