The pp-aterm tool adds layout to an ATerm to make its structure more clear.

Example:

The following Tiger program

  let function fact(n : int) : int =
        if n < 1 then 1 else (n * fact(n - 1))
   in printint(fact(10))
  end

is represented in abstract syntax by:

  Let([FunDecs([FunDec("fact",[FArg("n",Tp(Tid("int")))],Tp(Tid("int")),
  If(Lt(Var("n"),Int("1")),Int("1"),Seq([Times(Var("n"),Call(
  Var("fact"),[Minus(Var("n"),Int("1"))]))])))])],[Call(
  Var("printint"),[Call(Var("fact"),[Int("10")])])])

pp-aterm rewrites this ATerm to:

Let(
  [ FunDecs(
      [ FunDec(
          "fact"
        , [FArg("n", Tp(Tid("int")))]
        , Tp(Tid("int"))
        , If(
            Lt(Var("n"), Int("1"))
          , Int("1")
          , Seq(
              [ Times(
                  Var("n")
                , Call(
                    Var("fact")
                  , [Minus(Var("n"), Int("1"))]
                  )
                )
              ]
            )
          )
        )
      ]
    )
  ]
, [ Call(
      Var("printint")
    , [Call(Var("fact"), [Int("10")])]
    )
  ]
)

Revision: r1.1 - 13 Feb 2004 - 09:21 - MartinBravenboer
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback