/** Our internal representation of a Paren * in the D0 language. * See http://www.radford.edu/itec380/2022fall-ibarland/Homeworks/Project/ * * @author Ian Barland * @version 2023.Apr.10 */ public record Paren(Expr e) implements Expr { static final String START_TOKEN = "o"; static final String STOP_TOKEN = "o"; 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 'dark', 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 'light', and continue. return new Paren(theInsideExpr); } public Value eval() { return this.e.eval(); } }