Commit 502a89fb authored by Camil Staps's avatar Camil Staps 🐧

Clean.PrettyPrint: Array comprehensions, ABC code, dynamics

parent 3f54cdcd
......@@ -2,6 +2,6 @@ definition module CleanPrettyPrint.Definition
from CleanPrettyPrint.Util import class print
from syntax import :: ParsedDefinition, :: Type, :: TypeContext
from syntax import :: ParsedDefinition, :: Type, :: AType, :: ATypeVar, :: TypeContext
instance print ParsedDefinition, Type, TypeContext
instance print ParsedDefinition, Type, AType, ATypeVar, TypeContext
......@@ -106,8 +106,8 @@ where
= print st bt
//print st (TFA atvs type)
// = "TFA"
//print st (GTV tv)
// = "GTV"
print st (GTV tv)
= print st (tv :+: "^")
print st (TV tv)
= print st tv
print st (TFAC atvs t tc)
......
......@@ -70,13 +70,22 @@ where
(ParsedUniqueSelector _) = "!"
print st (PE_UpdateComprehension base (PE_Update _ sels new) _ qs) //TODO verify
= print st ("{" :+: base :+: " & " :+: printParsedSelections st sels :+: "=" :+: new :+: " \\\\ " :+: join st ", " qs :+: "}")
print st (PE_ArrayCompr ak pe qs)
= print st ("{" :+: ak :+: pe :+: " \\\\ " :+: join st ", " qs :+: "}")
print st (PE_ABC_Code lines inline)
= print st ("code " :+: if inline "inline " "" :+: "{" :+:
join_start st` ("\n" :+: st`) lines :+: "\n" :+: st :+: "}")
where
st` = {st & cpp_indent = st.cpp_indent + 1}
print st (PE_DynamicPattern pe dt)
= print st ("(" :+: pe :+: " :: " :+: dt :+: ")")
print st (PE_Dynamic pe (Yes dt))
= printp st ("dynamic " :+: pe :+: " :: " :+: dt)
print st (PE_Dynamic pe No)
= printp st ("dynamic " :+: pe)
// | PE_ArrayPattern ![ElemAssignment]
// | PE_ArrayCompr !ArrayKind !ParsedExpr ![Qualifier]
// | PE_Matches !Ident /*expr*/!ParsedExpr /*pattern*/!ParsedExpr !Position
// | PE_ABC_Code ![String] !Bool
// | PE_Any_Code !(CodeBinding Ident) !(CodeBinding Ident) ![String]
// | PE_DynamicPattern !ParsedExpr !DynamicType
// | PE_Dynamic !ParsedExpr !(Optional DynamicType)
// | PE_Generic !Ident !TypeKind /* AA: For generics, kind indexed identifier */
// | PE_TypeSignature !ArrayKind !ParsedExpr
// | PE_Empty
......@@ -206,3 +215,16 @@ compound_rhs :: OptGuardedAlts -> Bool
compound_rhs (GuardedAlts _ _) = True
compound_rhs (UnGuardedExpr {ewl_nodes=[_:_]}) = True
compound_rhs _ = False
// Dynamics
instance print DynamicType
where
print st {dt_uni_vars,dt_type,dt_contexts}
= print st (uni_vars :+: dt_type :+: context)
where
uni_vars = case dt_uni_vars of
[] = PrintNil
vs = "A." :+: join st " " vs :+: ": "
context = case dt_contexts of
[] = PrintNil
cs = " | " :+: join st " & " cs
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment