OutputStmt.java 994 B

1234567891011121314151617181920212223242526272829303132333435
  1. //OutputStmt:top//
  2. //OutputStmt:import//
  3. import java.util.*;
  4. // <stmt>OutputStmt ::= <OUT> <exp> <SEMI>
  5. public class OutputStmt extends Stmt /*OutputStmt:class*/ {
  6. public static final String $className = "OutputStmt";
  7. public static final String $ruleString =
  8. "<stmt>OutputStmt ::= <OUT> <exp> <SEMI>";
  9. public Token out;
  10. public Exp exp;
  11. public Token semi;
  12. public OutputStmt(Token out, Exp exp, Token semi) {
  13. //OutputStmt:init//
  14. this.out = out;
  15. this.exp = exp;
  16. this.semi = semi;
  17. }
  18. public static OutputStmt parse(Scan scn$, Trace trace$) {
  19. if (trace$ != null)
  20. trace$ = trace$.nonterm("<stmt>OutputStmt", scn$.lno);
  21. Token out = scn$.match(Token.Match.OUT, trace$);
  22. Exp exp = Exp.parse(scn$, trace$);
  23. Token semi = scn$.match(Token.Match.SEMI, trace$);
  24. return new OutputStmt(out, exp, semi);
  25. }
  26. public void execute() { System.out.println(exp.eval()); }
  27. //OutputStmt//
  28. }