Commit f4bb45ac authored by Camil Staps's avatar Camil Staps 🐧

Clean.PrettyPrint: PE_Update, PE_Selection, PD_Instance implementations

parent 917029dc
......@@ -18,10 +18,12 @@ where
st` = { st & cpp_indent = st.cpp_indent + 1 }
context = if (isEmpty cd.class_context) "" (" | " +++ join st " & " cd.class_context)
args = if (isEmpty cd.class_args) "" (join_start st " " cd.class_args)
print st (PD_Instance {pim_pi={pi_ident,pi_types,pi_context}})
= print st ("instance " :+: pi_ident :+: " " :+: join st ", " pi_types :+: pi_context`)
print st (PD_Instance {pim_pi={pi_ident,pi_types,pi_context},pim_members})
= print st ("instance " :+: pi_ident :+: " " :+: join st ", " pi_types :+: pi_context` :+: members)
where
pi_context` = if (isEmpty pi_context) PrintNil (" | " :+: join st " & " pi_context)
members = if (isEmpty pim_members) PrintNil (" where" :+: join_start st` ("\n" :+: st`) pim_members)
st` = {st & cpp_indent = st.cpp_indent + 1}
print st (PD_Instances pis=:[{pim_pi={pi_ident}}:_])
= print st ("instance " :+: pi_ident :+: " " :+: join st ", " (map (\i -> i.pim_pi.pi_types) pis))
print st (PD_Generic {gen_ident,gen_type,gen_vars})
......
......@@ -58,9 +58,33 @@ where
= print st (bind_dst :+: "=:" :+: bind_src)
print st PE_WildCard
= "_"
print st (PE_Update e1 sels e2)
= print {st & cpp_parens=False} ("{" :+: e1 :+: " & " :+: printParsedSelections st sels :+: "=" :+: e2 :+: "}")
print st (PE_Selection psk pe pes)
= print st (pe :+: sel :+: printParsedSelections st pes)
where
sel = case psk of
ParsedNormalSelector = "."
(ParsedUniqueSelector _) = "!"
// | PE_ArrayPattern ![ElemAssignment]
// | PE_UpdateComprehension !ParsedExpr !ParsedExpr !ParsedExpr ![Qualifier]
// | PE_ArrayCompr !ArrayKind !ParsedExpr ![Qualifier]
// | PE_Matches !Ident /*expr*/!ParsedExpr /*pattern*/!ParsedExpr !Position
// | PE_QualifiedIdent !Ident !String
// | 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
print st pe
= abort "UNKNOWN_PE"
printParsedSelections :: CPPState [ParsedSelection] -> String
printParsedSelections st [PS_Array pe] = print {st & cpp_parens=False} ("[" :+: pe :+: "]")
printParsedSelections st _ = "UNKNOWN_PARSEDSELECTION"
instance print Rhs
where
print st {rhs_alts,rhs_locals=LocalParsedDefs []}
......
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