CSC448: Code/AST/PrettyPrinter Example: AST [6/18] Previous pageContentsNext page

Decl (TypeInt, counter)
FunDef (TypeVoid, increment_counter, List<Decl>[],
  StatCompound (
    List<Decl>[
    ]
    List<Stat>[
      StatExp (ExpAssign (ExpVar (counter), ExpBinOp (ExpVar (counter), +, ExpInt (1))))
      StatReturn ()
    ]
  )
)
FunDef (TypeInt, get_counter, List<Decl>[],
  StatCompound (
    List<Decl>[
    ]
    List<Stat>[
      StatReturn (ExpVar (counter))
    ]
  )
)
FunDef (TypeVoid, print_counter, List<Decl>[],
  StatCompound (
    List<Decl>[
    ]
    List<Stat>[
      StatExp (ExpFunCall (_print_array, List<Exp>[ExpString ("counter = ")])
      StatExp (ExpFunCall (_print_int, List<Exp>[ExpVar (counter)])
      StatExp (ExpFunCall (_print_newline, List<Exp>[])
      StatReturn ()
    ]
  )
)
FunDef (TypeVoid, _clogs_main, List<Decl>[Decl (TypeInt, argc), Decl (TypeArray (TypeArray (TypeInt)), argv)],
  StatCompound (
    List<Decl>[
    ]
    List<Stat>[
      StatCompound (
        List<Decl>[
          Decl (TypeInt, n)
        ]
        List<Stat>[
          StatExp (ExpComma (ExpAssign (ExpVar (n), ExpInt (1)), ExpInt (2)))
          StatExp (ExpFunCall (_print_int, List<Exp>[ExpVar (n)])
          StatExp (ExpFunCall (_print_newline, List<Exp>[])
          StatExp (ExpAssign (ExpVar (n), ExpComma (ExpInt (1), ExpInt (2))))
          StatExp (ExpFunCall (_print_int, List<Exp>[ExpVar (n)])
          StatExp (ExpFunCall (_print_newline, List<Exp>[])
        ]
      )
      StatCompound (
        List<Decl>[
          Decl (TypeInt, copy)
        ]
        List<Stat>[
          StatExp (ExpAssign (ExpVar (counter), ExpInt (1)))
          StatExp (ExpFunCall (print_counter, List<Exp>[])
          StatExp (ExpAssign (ExpVar (copy), ExpComma (ExpFunCall (increment_counter, List<Exp>[], ExpFunCall (get_counter, List<Exp>[])))
          StatExp (ExpFunCall (_print_array, List<Exp>[ExpString ("copy = ")])
          StatExp (ExpFunCall (_print_int, List<Exp>[ExpVar (copy)])
          StatExp (ExpFunCall (_print_newline, List<Exp>[])
          StatExp (ExpFunCall (print_counter, List<Exp>[])
        ]
      )
      StatReturn ()
    ]
  )
)

Created with file:ast/AnotherPrinter.java [source] [doc-public] [doc-private]

Previous pageContentsNext page