Skip to content

Commit fa792ca

Browse files
committed
lecture: fix typo (Visitor)
1 parent fad89c9 commit fa792ca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lecture/pattern/visitor.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,11 @@ public class EvalVisitor implements ExprVisitor {
375375

376376
public void visit(NumExpr e) { erg.push(e.getValue()); }
377377
public void visit(MulExpr e) {
378-
e.getE1().accept(this); e.getE1().accept(this);
378+
e.getE1().accept(this); e.getE2().accept(this);
379379
erg.push(erg.pop() * erg.pop());
380380
}
381381
public void visit(AddExpr e) {
382-
e.getE1().accept(this); e.getE1().accept(this);
382+
e.getE1().accept(this); e.getE2().accept(this);
383383
erg.push(erg.pop() + erg.pop());
384384
}
385385
public int getResult() { return erg.peek(); }
@@ -390,11 +390,11 @@ public class PrintVisitor implements ExprVisitor {
390390

391391
public void visit(NumExpr e) { erg.push("NumExpr(" + e.getValue() + ")"); }
392392
public void visit(MulExpr e) {
393-
e.getE1().accept(this); e.getE1().accept(this);
393+
e.getE1().accept(this); e.getE2().accept(this);
394394
erg.push("MulExpr(" + erg.pop() + ", " + erg.pop() + ")");
395395
}
396396
public void visit(AddExpr e) {
397-
e.getE1().accept(this); e.getE1().accept(this);
397+
e.getE1().accept(this); e.getE2().accept(this);
398398
erg.push("AddExpr(" + erg.pop() + ", " + erg.pop() + ")");
399399
}
400400
public String getResult() { return erg.peek(); }

0 commit comments

Comments
 (0)