content: -- File generated by the BNF Converter (bnfc 2.9.4.1).
  
  {-# LANGUAGE CPP #-}
  {-# LANGUAGE FlexibleInstances #-}
  {-# LANGUAGE LambdaCase #-}
  #if __GLASGOW_HASKELL__ <= 708
  {-# LANGUAGE OverlappingInstances #-}
  #endif
  
  -- | Pretty-printer for Lang.
  
  module Lang.PrintLang where
  
  import Prelude
    ( ($), (.)
    , Bool(..), (==), (<)
    , Int, Integer, Double, (+), (-), (*)
    , String, (++)
    , ShowS, showChar, showString
    , all, elem, foldr, id, map, null, replicate, shows, span
    )
  import Data.Char ( Char, isSpace )
  import qualified Lang.AbsLang
  
  -- | The top-level printing method.
  
  printTree :: Print a => a -> String
  printTree = render . prt 0
  
  type Doc = [ShowS] -> [ShowS]
  
  doc :: ShowS -> Doc
  doc = (:)
  
  render :: Doc -> String
  render d = rend 0 False (map ($ "") $ d []) ""
    where
    rend
      :: Int        -- ^ Indentation level.
      -> Bool       -- ^ Pending indentation to be output before next character?
      -> [String]
      -> ShowS
    rend i p = \case
        "["      :ts -> char '[' . rend i False ts
        "("      :ts -> char '(' . rend i False ts
        "{"      :ts -> onNewLine i     p . showChar   '{'  . new (i+1) ts
        "}" : ";":ts -> onNewLine (i-1) p . showString "};" . new (i-1) ts
        "}"      :ts -> onNewLine (i-1) p . showChar   '}'  . new (i-1) ts
        [";"]        -> char ';'
        ";"      :ts -> char ';' . new i ts
        t  : ts@(s:_) | closingOrPunctuation s
                     -> pending . showString t . rend i False ts
        t        :ts -> pending . space t      . rend i False ts
        []           -> id
      where
      -- Output character after pending indentation.
      char :: Char -> ShowS
      char c = pending . showChar c
  
      -- Output pending indentation.
      pending :: ShowS
      pending = if p then indent i else id
  
    -- Indentation (spaces) for given indentation level.
    indent :: Int -> ShowS
    indent i = replicateS (2*i) (showChar ' ')
  
    -- Continue rendering in new line with new indentation.
    new :: Int -> [String] -> ShowS
    new j ts = showChar '\n' . rend j True ts
  
    -- Make sure we are on a fresh line.
    onNewLine :: Int -> Bool -> ShowS
    onNewLine i p = (if p then id else showChar '\n') . indent i
  
    -- Separate given string from following text by a space (if needed).
    space :: String -> ShowS
    space t s =
      case (all isSpace t', null spc, null rest) of
        (True , _   , True ) -> []              -- remove trailing space
        (False, _   , True ) -> t'              -- remove trailing space
        (False, True, False) -> t' ++ ' ' : s   -- add space if none
        _                    -> t' ++ s
      where
        t'          = showString t []
        (spc, rest) = span isSpace s
  
    closingOrPunctuation :: String -> Bool
    closingOrPunctuation [c] = c `elem` closerOrPunct
    closingOrPunctuation _   = False
  
    closerOrPunct :: String
    closerOrPunct = ")],;"
  
  parenth :: Doc -> Doc
  parenth ss = doc (showChar '(') . ss . doc (showChar ')')
  
  concatS :: [ShowS] -> ShowS
  concatS = foldr (.) id
  
  concatD :: [Doc] -> Doc
  concatD = foldr (.) id
  
  replicateS :: Int -> ShowS -> ShowS
  replicateS n f = concatS (replicate n f)
  
  -- | The printer class does the job.
  
  class Print a where
    prt :: Int -> a -> Doc
  
  instance {-# OVERLAPPABLE #-} Print a => Print [a] where
    prt i = concatD . map (prt i)
  
  instance Print Char where
    prt _ c = doc (showChar '\'' . mkEsc '\'' c . showChar '\'')
  
  instance Print String where
    prt _ = printString
  
  printString :: String -> Doc
  printString s = doc (showChar '"' . concatS (map (mkEsc '"') s) . showChar '"')
  
  mkEsc :: Char -> Char -> ShowS
  mkEsc q = \case
    s | s == q -> showChar '\\' . showChar s
    '\\' -> showString "\\\\"
    '\n' -> showString "\\n"
    '\t' -> showString "\\t"
    s -> showChar s
  
  prPrec :: Int -> Int -> Doc -> Doc
  prPrec i j = if j < i then parenth else id
  
  instance Print Integer where
    prt _ x = doc (shows x)
  
  instance Print Double where
    prt _ x = doc (shows x)
  
  instance Print Lang.AbsLang.Ident where
    prt _ (Lang.AbsLang.Ident i) = doc $ showString i
  instance Print Lang.AbsLang.Program where
    prt i = \case
      Lang.AbsLang.Prog toplevels -> prPrec i 0 (concatD [prt 0 toplevels])
  
  instance Print [Lang.AbsLang.TopLevel] where
    prt _ [] = concatD []
    prt _ (x:xs) = concatD [prt 0 x, prt 0 xs]
  
  instance Print Lang.AbsLang.TopLevel where
    prt i = \case
      Lang.AbsLang.TopDecl decl -> prPrec i 0 (concatD [prt 0 decl, doc (showString ";")])
      Lang.AbsLang.TopSub subdef -> prPrec i 0 (concatD [prt 0 subdef])
  
  instance Print Lang.AbsLang.Decl where
    prt i = \case
      Lang.AbsLang.NameDecl id_ -> prPrec i 0 (concatD [doc (showString "module"), prt 0 id_])
      Lang.AbsLang.ProtocolDecl protocol -> prPrec i 0 (concatD [doc (showString "protocol"), prt 0 protocol])
      Lang.AbsLang.FlavorDecl str -> prPrec i 0 (concatD [doc (showString "flavor"), printString str])
      Lang.AbsLang.StateDecl stateaspects -> prPrec i 0 (concatD [doc (showString "state"), prt 0 stateaspects])
      Lang.AbsLang.ActionTypeDecl actiontypename actiontype -> prPrec i 0 (concatD [doc (showString "actiontype"), prt 0 actiontypename, doc (showString "="), prt 0 actiontype])
      Lang.AbsLang.ActionDecl actionname actiontype actionarrayinfo provider protocol -> prPrec i 0 (concatD [doc (showString "action"), prt 0 actionname, doc (showString ":"), prt 1 actiontype, prt 0 actionarrayinfo, doc (showString "provided"), doc (showString "by"), prt 0 provider, doc (showString "via"), prt 0 protocol])
      Lang.AbsLang.GlobalVarDecl vardecl -> prPrec i 0 (concatD [prt 0 vardecl])
      Lang.AbsLang.TypeDecl typename typecompiledefinition -> prPrec i 0 (concatD [doc (showString "type"), prt 0 typename, prt 0 typecompiledefinition])
      Lang.AbsLang.TypeAliasDecl typename type_ -> prPrec i 0 (concatD [doc (showString "alias"), prt 0 typename, doc (showString "="), prt 0 type_])
      Lang.AbsLang.FieldsDecl typename fielddefs -> prPrec i 0 (concatD [doc (showString "fields"), prt 0 typename, doc (showString "["), prt 0 fielddefs, doc (showString "]")])
      Lang.AbsLang.NumericDecl typename n -> prPrec i 0 (concatD [doc (showString "numeric"), prt 0 typename, doc (showString "unsigned"), prt 0 n])
      Lang.AbsLang.DefineDecl definename defineparams exp -> prPrec i 0 (concatD [doc (showString "define"), prt 0 definename, prt 0 defineparams, doc (showString "="), prt 0 exp])
  
  instance Print [Lang.AbsLang.FieldDef] where
    prt _ [] = concatD []
    prt _ [x] = concatD [prt 0 x]
    prt _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs]
  
  instance Print [Lang.AbsLang.DefineParam] where
    prt _ [] = concatD []
    prt _ (x:xs) = concatD [prt 0 x, prt 0 xs]
  
  instance Print Lang.AbsLang.VarDecl where
    prt i = \case
      Lang.AbsLang.MkVarDecl type_ varnames -> prPrec i 0 (concatD [doc (showString "var"), prt 1 type_, prt 0 varnames])
  
  instance Print [Lang.AbsLang.VarName] where
    prt _ [] = concatD []
    prt _ [x] = concatD [prt 0 x]
    prt _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs]
  
  instance Print Lang.AbsLang.StateAspects where
    prt i = \case
      Lang.AbsLang.StateAspectList stateaspects -> prPrec i 0 (concatD [doc (showString "["), prt 0 stateaspects, doc (showString "]")])
  
  instance Print [Lang.AbsLang.StateAspect] where
    prt _ [] = concatD []
    prt _ [x] = concatD [prt 0 x]
    prt _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs]
  
  instance Print Lang.AbsLang.ActionArrayInfo where
    prt i = \case
      Lang.AbsLang.ActionSingle -> prPrec i 0 (concatD [])
      Lang.AbsLang.ActionArray exp -> prPrec i 0 (concatD [doc (showString "["), prt 0 exp, doc (showString "]")])
  
  instance Print Lang.AbsLang.Provider where
    prt i = \case
      Lang.AbsLang.ProviderExternal -> prPrec i 0 (concatD [doc (showString "external")])
      Lang.AbsLang.ProviderModule str -> prPrec i 0 (concatD [printString str])
      Lang.AbsLang.ProviderModuleShare str actionnames -> prPrec i 0 (concatD [doc (showString "("), printString str, prt 0 actionnames, doc (showString ")")])
  
  instance Print [Lang.AbsLang.ActionName] where
    prt _ [] = concatD []
    prt _ (x:xs) = concatD [prt 0 x, prt 0 xs]
  
  instance Print Lang.AbsLang.Protocol where
    prt i = \case
      Lang.AbsLang.ProtocolAuto -> prPrec i 0 (concatD [doc (showString "auto")])
      Lang.AbsLang.ProtocolGiven exp -> prPrec i 0 (concatD [prt 0 exp])
  
  instance Print Lang.AbsLang.TypeCompileDefinition where
    prt i = \case
      Lang.AbsLang.TypeCompileString str -> prPrec i 0 (concatD [doc (showString "=>"), printString str])
      Lang.AbsLang.TypeCompileInfer -> prPrec i 0 (concatD [])
  
  instance Print Lang.AbsLang.FieldDef where
    prt i = \case
      Lang.AbsLang.MkFieldDef fieldname type_ -> prPrec i 0 (concatD [prt 0 fieldname, doc (showString ":"), prt 0 type_])
  
  instance Print Lang.AbsLang.FieldName where
    prt i = \case
      Lang.AbsLang.FieldNameIdent id_ -> prPrec i 0 (concatD [prt 0 id_])
      Lang.AbsLang.FieldNameString str -> prPrec i 0 (concatD [printString str])
  
  instance Print Lang.AbsLang.FunPat where
    prt i = \case
      Lang.AbsLang.FunPatPat pattern_ -> prPrec i 0 (concatD [prt 0 pattern_])
      Lang.AbsLang.FunPatFun pattern_ funpat -> prPrec i 0 (concatD [prt 0 pattern_, doc (showString "->"), prt 0 funpat])
  
  instance Print Lang.AbsLang.Pattern where
    prt i = \case
      Lang.AbsLang.PatternParam param -> prPrec i 0 (concatD [prt 0 param])
      Lang.AbsLang.PatternTupleEmpty -> prPrec i 0 (concatD [doc (showString "()")])
      Lang.AbsLang.PatternTupleTwoPlus pattern_ patterns -> prPrec i 0 (concatD [doc (showString "("), prt 0 pattern_, doc (showString ","), prt 0 patterns, doc (showString ")")])
  
  instance Print [Lang.AbsLang.Pattern] where
    prt _ [] = concatD []
    prt _ [x] = concatD [prt 0 x]
    prt _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs]
  
  instance Print Lang.AbsLang.Param where
    prt i = \case
      Lang.AbsLang.MkParam id_ type_ -> prPrec i 0 (concatD [prt 0 id_, doc (showString ":"), prt 1 type_])
  
  instance Print Lang.AbsLang.ActionType where
    prt i = \case
      Lang.AbsLang.ActionTypeRaw funpat stateaspects1 stateaspects2 -> prPrec i 0 (concatD [prt 0 funpat, doc (showString "reading"), prt 0 stateaspects1, doc (showString "writing"), prt 0 stateaspects2])
      Lang.AbsLang.ActionTypeNamed actiontypename -> prPrec i 1 (concatD [prt 0 actiontypename])
  
  instance Print Lang.AbsLang.Type where
    prt i = \case
      Lang.AbsLang.FunType type_1 type_2 -> prPrec i 0 (concatD [prt 1 type_1, doc (showString "->"), prt 0 type_2])
      Lang.AbsLang.NamedType id_ -> prPrec i 1 (concatD [prt 0 id_])
      Lang.AbsLang.TupleZeroType -> prPrec i 1 (concatD [doc (showString "()")])
      Lang.AbsLang.TupleTwoPlusType type_ types -> prPrec i 1 (concatD [doc (showString "("), prt 0 type_, doc (showString ","), prt 0 types, doc (showString ")")])
  
  instance Print [Lang.AbsLang.Type] where
    prt _ [] = concatD []
    prt _ [x] = concatD [prt 0 x]
    prt _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs]
  
  instance Print Lang.AbsLang.SubDef where
    prt i = \case
      Lang.AbsLang.MkSub subflags subroutinename funpat sublines -> prPrec i 0 (concatD [prt 0 subflags, doc (showString "function"), prt 0 subroutinename, doc (showString ":"), prt 0 funpat, doc (showString "{"), prt 0 sublines, doc (showString "}")])
  
  instance Print [Lang.AbsLang.SubFlag] where
    prt _ [] = concatD []
    prt _ (x:xs) = concatD [prt 0 x, prt 0 xs]
  
  instance Print [Lang.AbsLang.SubLine] where
    prt _ [] = concatD []
    prt _ (x:xs) = concatD [prt 0 x, prt 0 xs]
  
  instance Print Lang.AbsLang.SubFlag where
    prt i = \case
      Lang.AbsLang.Inline -> prPrec i 0 (concatD [doc (showString "inline")])
  
  instance Print Lang.AbsLang.SubLine where
    prt i = \case
      Lang.AbsLang.SubVarDecl vardecl -> prPrec i 0 (concatD [prt 0 vardecl, doc (showString ";")])
      Lang.AbsLang.SubStm stm -> prPrec i 0 (concatD [prt 0 stm])
  
  instance Print Lang.AbsLang.Stm where
    prt i = \case
      Lang.AbsLang.Normal normalstm -> prPrec i 0 (concatD [prt 0 normalstm, doc (showString ";")])
      Lang.AbsLang.Abnormal abnormalstm -> prPrec i 0 (concatD [prt 0 abnormalstm])
  
  instance Print Lang.AbsLang.NormalStm where
    prt i = \case
      Lang.AbsLang.Assign assignish -> prPrec i 0 (concatD [prt 0 assignish])
      Lang.AbsLang.Return -> prPrec i 0 (concatD [doc (showString "return")])
      Lang.AbsLang.Goto gotolabel -> prPrec i 0 (concatD [doc (showString "goto"), prt 0 gotolabel])
      Lang.AbsLang.HintPower power actionname -> prPrec i 0 (concatD [doc (showString "setpower"), prt 0 power, prt 0 actionname])
  
  instance Print Lang.AbsLang.Power where
    prt i = \case
      Lang.AbsLang.PowerOn -> prPrec i 0 (concatD [doc (showString "on")])
      Lang.AbsLang.PowerOff -> prPrec i 0 (concatD [doc (showString "off")])
  
  instance Print Lang.AbsLang.Assignish where
    prt i = \case
      Lang.AbsLang.WithLhs exp1 exp2 -> prPrec i 0 (concatD [prt 0 exp1, doc (showString "="), prt 0 exp2])
      Lang.AbsLang.WithoutLhs exp -> prPrec i 0 (concatD [prt 0 exp])
      Lang.AbsLang.PlusEquals exp1 exp2 -> prPrec i 0 (concatD [prt 0 exp1, doc (showString "+="), prt 0 exp2])
      Lang.AbsLang.MinusEquals exp1 exp2 -> prPrec i 0 (concatD [prt 0 exp1, doc (showString "-="), prt 0 exp2])
      Lang.AbsLang.Increment exp -> prPrec i 0 (concatD [prt 0 exp, doc (showString "++")])
      Lang.AbsLang.Decrement exp -> prPrec i 0 (concatD [prt 0 exp, doc (showString "--")])
  
  instance Print Lang.AbsLang.AbnormalStm where
    prt i = \case
      Lang.AbsLang.Label gotolabel -> prPrec i 0 (concatD [doc (showString "label"), prt 0 gotolabel, doc (showString ":")])
      Lang.AbsLang.Scissors -> prPrec i 0 (concatD [doc (showString "--%<--")])
      Lang.AbsLang.While exp stmblock -> prPrec i 0 (concatD [doc (showString "while"), doc (showString "("), prt 0 exp, doc (showString ")"), prt 0 stmblock])
      Lang.AbsLang.For assignish1 exp assignish2 stmblock -> prPrec i 0 (concatD [doc (showString "for"), doc (showString "("), prt 0 assignish1, doc (showString ";"), prt 0 exp, doc (showString ";"), prt 0 assignish2, doc (showString ")"), prt 0 stmblock])
      Lang.AbsLang.ForEach varname exp1 exp2 stmblock -> prPrec i 0 (concatD [doc (showString "foreach"), doc (showString "("), prt 0 varname, doc (showString "in"), prt 0 exp1, doc (showString "..."), prt 0 exp2, doc (showString ")"), prt 0 stmblock])
      Lang.AbsLang.Block stmblock -> prPrec i 0 (concatD [prt 0 stmblock])
      Lang.AbsLang.IfLike iflikestm -> prPrec i 0 (concatD [prt 0 iflikestm])
  
  instance Print Lang.AbsLang.IfLikeStm where
    prt i = \case
      Lang.AbsLang.IfElse exp stmblock postelsestm -> prPrec i 0 (concatD [doc (showString "if"), doc (showString "("), prt 0 exp, doc (showString ")"), prt 0 stmblock, doc (showString "else"), prt 0 postelsestm])
      Lang.AbsLang.IfOnly exp stmblock -> prPrec i 0 (concatD [doc (showString "if"), doc (showString "("), prt 0 exp, doc (showString ")"), prt 0 stmblock])
  
  instance Print Lang.AbsLang.PostElseStm where
    prt i = \case
      Lang.AbsLang.ElseIf iflikestm -> prPrec i 0 (concatD [prt 0 iflikestm])
      Lang.AbsLang.ElseBlock stmblock -> prPrec i 0 (concatD [prt 0 stmblock])
  
  instance Print Lang.AbsLang.StmBlock where
    prt i = \case
      Lang.AbsLang.MkBlock stms -> prPrec i 0 (concatD [doc (showString "{"), prt 0 stms, doc (showString "}")])
  
  instance Print [Lang.AbsLang.Stm] where
    prt _ [] = concatD []
    prt _ (x:xs) = concatD [prt 0 x, prt 0 xs]
  
  instance Print Lang.AbsLang.StateAspect where
    prt i = \case
      Lang.AbsLang.MkStateAspect id_ -> prPrec i 0 (concatD [prt 0 id_])
  
  instance Print Lang.AbsLang.TypeName where
    prt i = \case
      Lang.AbsLang.MkTypeName id_ -> prPrec i 0 (concatD [prt 0 id_])
  
  instance Print Lang.AbsLang.VarName where
    prt i = \case
      Lang.AbsLang.MkVarName id_ -> prPrec i 0 (concatD [prt 0 id_])
  
  instance Print Lang.AbsLang.ActionTypeName where
    prt i = \case
      Lang.AbsLang.MkActionTypeName id_ -> prPrec i 0 (concatD [prt 0 id_])
  
  instance Print Lang.AbsLang.ActionName where
    prt i = \case
      Lang.AbsLang.MkActionName id_ -> prPrec i 0 (concatD [prt 0 id_])
  
  instance Print Lang.AbsLang.DefineName where
    prt i = \case
      Lang.AbsLang.MkDefineName id_ -> prPrec i 0 (concatD [prt 0 id_])
  
  instance Print Lang.AbsLang.DefineParam where
    prt i = \case
      Lang.AbsLang.MkDefineParam id_ -> prPrec i 0 (concatD [prt 0 id_])
  
  instance Print Lang.AbsLang.SubroutineName where
    prt i = \case
      Lang.AbsLang.MkSubroutineName id_ -> prPrec i 0 (concatD [prt 0 id_])
  
  instance Print Lang.AbsLang.GotoLabel where
    prt i = \case
      Lang.AbsLang.MkGotoLabel id_ -> prPrec i 0 (concatD [prt 0 id_])
  
  instance Print Lang.AbsLang.Call where
    prt i = \case
      Lang.AbsLang.ActionCall actionname args -> prPrec i 0 (concatD [doc (showString "do"), prt 0 actionname, prt 0 args])
      Lang.AbsLang.SubCall subroutinename args -> prPrec i 0 (concatD [doc (showString "call"), prt 0 subroutinename, prt 0 args])
  
  instance Print Lang.AbsLang.Args where
    prt i = \case
      Lang.AbsLang.MkArgs exps -> prPrec i 0 (concatD [prt 12 exps])
  
  instance Print [Lang.AbsLang.Exp] where
    prt 12 [] = concatD []
    prt 12 (x:xs) = concatD [prt 12 x, prt 12 xs]
    prt _ [x] = concatD [prt 0 x]
    prt _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs]
  
  instance Print Lang.AbsLang.Dict where
    prt i = \case
      Lang.AbsLang.MkDict dictassigs -> prPrec i 0 (concatD [doc (showString "{{"), prt 0 dictassigs, doc (showString "}}")])
  
  instance Print Lang.AbsLang.DictAssig where
    prt i = \case
      Lang.AbsLang.MkDictAssig id_ exp -> prPrec i 0 (concatD [prt 0 id_, doc (showString "="), prt 0 exp])
  
  instance Print [Lang.AbsLang.DictAssig] where
    prt _ [] = concatD []
    prt _ [x] = concatD [prt 0 x]
    prt _ (x:xs) = concatD [prt 0 x, doc (showString ","), prt 0 xs]
  
  instance Print Lang.AbsLang.Exp where
    prt i = \case
      Lang.AbsLang.EIfThenElse exp1 exp2 exp3 -> prPrec i 0 (concatD [doc (showString "if"), prt 0 exp1, doc (showString "then"), prt 0 exp2, doc (showString "else"), prt 0 exp3])
      Lang.AbsLang.EOr exp1 exp2 -> prPrec i 1 (concatD [prt 1 exp1, doc (showString "|"), prt 2 exp2])
      Lang.AbsLang.EAnd exp1 exp2 -> prPrec i 2 (concatD [prt 2 exp1, doc (showString "&"), prt 3 exp2])
      Lang.AbsLang.EXor exp1 exp2 -> prPrec i 2 (concatD [prt 2 exp1, doc (showString "^"), prt 3 exp2])
      Lang.AbsLang.EEq exp1 exp2 -> prPrec i 3 (concatD [prt 4 exp1, doc (showString "=="), prt 4 exp2])
      Lang.AbsLang.ENeq exp1 exp2 -> prPrec i 3 (concatD [prt 4 exp1, doc (showString "!="), prt 4 exp2])
      Lang.AbsLang.ELt exp1 exp2 -> prPrec i 3 (concatD [prt 4 exp1, doc (showString "<"), prt 4 exp2])
      Lang.AbsLang.EGt exp1 exp2 -> prPrec i 3 (concatD [prt 4 exp1, doc (showString ">"), prt 4 exp2])
      Lang.AbsLang.ELte exp1 exp2 -> prPrec i 3 (concatD [prt 4 exp1, doc (showString "<="), prt 4 exp2])
      Lang.AbsLang.EGte exp1 exp2 -> prPrec i 3 (concatD [prt 4 exp1, doc (showString ">="), prt 4 exp2])
      Lang.AbsLang.EPlus exp1 exp2 -> prPrec i 4 (concatD [prt 4 exp1, doc (showString "+"), prt 5 exp2])
      Lang.AbsLang.EMinus exp1 exp2 -> prPrec i 4 (concatD [prt 4 exp1, doc (showString "-"), prt 5 exp2])
      Lang.AbsLang.ETimes exp1 exp2 -> prPrec i 5 (concatD [prt 5 exp1, doc (showString "*"), prt 6 exp2])
      Lang.AbsLang.EDiv exp1 exp2 -> prPrec i 5 (concatD [prt 5 exp1, doc (showString "/"), prt 6 exp2])
      Lang.AbsLang.EMod exp1 exp2 -> prPrec i 5 (concatD [prt 5 exp1, doc (showString "%"), prt 6 exp2])
      Lang.AbsLang.EShiftL exp1 exp2 -> prPrec i 6 (concatD [prt 6 exp1, doc (showString "<<"), prt 7 exp2])
      Lang.AbsLang.EShiftR exp1 exp2 -> prPrec i 6 (concatD [prt 6 exp1, doc (showString ">>"), prt 7 exp2])
      Lang.AbsLang.EArithShiftR exp1 exp2 -> prPrec i 6 (concatD [prt 6 exp1, doc (showString "|>>"), prt 7 exp2])
      Lang.AbsLang.ENot exp -> prPrec i 7 (concatD [doc (showString "~"), prt 7 exp])
      Lang.AbsLang.ECall call -> prPrec i 8 (concatD [prt 0 call])
      Lang.AbsLang.EApp exp1 exp2 -> prPrec i 9 (concatD [prt 9 exp1, prt 10 exp2])
      Lang.AbsLang.ETypeAnn exp type_ -> prPrec i 10 (concatD [prt 10 exp, doc (showString "::"), prt 0 type_])
      Lang.AbsLang.EBlob str -> prPrec i 11 (concatD [doc (showString "fl"), printString str])
      Lang.AbsLang.EVar varname -> prPrec i 12 (concatD [prt 0 varname])
      Lang.AbsLang.EIntLit n -> prPrec i 12 (concatD [prt 0 n])
      Lang.AbsLang.EField exp fieldname -> prPrec i 12 (concatD [prt 12 exp, doc (showString "-->"), prt 0 fieldname])
      Lang.AbsLang.ETupleZero -> prPrec i 12 (concatD [doc (showString "()")])
      Lang.AbsLang.ETupleTwoPlus exp exps -> prPrec i 12 (concatD [doc (showString "("), prt 0 exp, doc (showString ","), prt 0 exps, doc (showString ")")])
      Lang.AbsLang.EProj exp n -> prPrec i 12 (concatD [prt 12 exp, doc (showString "."), prt 0 n])
      Lang.AbsLang.EIgnore -> prPrec i 12 (concatD [doc (showString "_")])
      Lang.AbsLang.EStr str -> prPrec i 12 (concatD [printString str])
      Lang.AbsLang.EDict dict -> prPrec i 12 (concatD [prt 0 dict])
  