Runtime support for converting AST representations back to generated types.
Defines the OfAstM error monad and argument-parsing combinators used by
the ofAst functions that #strata_gen emits.
Equations
Instances For
@[implicit_reducible]
Equations
- StrataDDM.instToStringOfAstM = { toString := fun (e : StrataDDM.OfAstM α) => StrataDDM.instToStringOfAstM._private_1 e }
@[implicit_reducible]
Equations
- StrataDDM.instReprOfAstM = { reprPrec := fun (e : StrataDDM.OfAstM α) (prec : Nat) => StrataDDM.instReprOfAstM._private_1 e prec }
@[implicit_reducible]
Equations
- One or more equations did not get rendered due to their size.
Thrown when an expression is provided but not expected.
Equations
Instances For
Thrown when an expression is provided but not expected.
Equations
- StrataDDM.OfAstM.throwUnknownType e = Except.error (toString "Unknown type " ++ toString (repr e) ++ toString ".")
Instances For
def
StrataDDM.OfAstM.throwExpectedExpr
{Ann : Type}
{α : Type u_1}
[Repr Ann]
(a : ArgF Ann)
:
OfAstM α
Raise error when passed an argument that is not an expression when expression expected.
Equations
- StrataDDM.OfAstM.throwExpectedExpr a = StrataDDM.OfAstM.throwExpected "expression" a
Instances For
Raise error when passed an argument that is not an expression when expression expected.
Equations
- StrataDDM.OfAstM.throwExpectedOperation a = StrataDDM.OfAstM.throwExpected "operation" a
Instances For
Equations
- StrataDDM.OfAstM.throwUnexpectedBvar tp = Except.error (toString tp ++ toString " has unexpected bound variable.")
Instances For
def
StrataDDM.OfAstM.throwUnexpectedArgCount
{α : Type u_1}
(tp : QualifiedIdent)
(expected actual : Nat)
:
OfAstM α
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- StrataDDM.OfAstM.throwUnknownIdentifier tp f = Except.error (toString tp ++ toString " given unknown operator " ++ toString f ++ toString ".")
Instances For
def
StrataDDM.OfAstM.checkArgCount
{α : Type u_1}
(tp : QualifiedIdent)
(expected : Nat)
(args : Array α)
:
Equations
- StrataDDM.OfAstM.checkArgCount tp expected args = if p : args.size = expected then pure { down := p } else StrataDDM.OfAstM.throwUnexpectedArgCount tp expected args.size
Instances For
def
StrataDDM.OfAstM.checkEtaExprArgCount
{Tp : Type u_1}
(tp : QualifiedIdent)
(expected : Array (String × Tp))
(args : Array Arg)
:
Equations
Instances For
def
StrataDDM.OfAstM.ofExpressionM
{α : Type}
{β : Type u_1}
[Repr α]
[SizeOf α]
(val : ArgF α)
(act : (e : ExprF α) → sizeOf e < sizeOf val → OfAstM β)
:
OfAstM β
Equations
- StrataDDM.OfAstM.ofExpressionM (StrataDDM.ArgF.expr a1) act_2 = act_2 a1 ⋯
- StrataDDM.OfAstM.ofExpressionM val act = StrataDDM.OfAstM.throwExpected "expression" val
Instances For
def
StrataDDM.OfAstM.ofTypeM
{α : Type}
{β : Type u_1}
[Repr α]
[SizeOf α]
(val : ArgF α)
(act : (e : TypeExprF α) → sizeOf e < sizeOf val → OfAstM β)
:
OfAstM β
Equations
- StrataDDM.OfAstM.ofTypeM (StrataDDM.ArgF.type a1) act_2 = act_2 a1 ⋯
- StrataDDM.OfAstM.ofTypeM val act = StrataDDM.OfAstM.throwExpected "type" val
Instances For
def
StrataDDM.OfAstM.ofOperationM
{α : Type}
{β : Type u_1}
[Repr α]
[SizeOf α]
(val : ArgF α)
(act : (o : OperationF α) → sizeOf o < sizeOf val → OfAstM β)
:
OfAstM β
Equations
- StrataDDM.OfAstM.ofOperationM (StrataDDM.ArgF.op a1) act_2 = act_2 a1 ⋯
- StrataDDM.OfAstM.ofOperationM val act = StrataDDM.OfAstM.throwExpected "operation" val
Instances For
Equations
- StrataDDM.OfAstM.ofIdentM (StrataDDM.ArgF.ident ann val) = pure val
- StrataDDM.OfAstM.ofIdentM x✝ = StrataDDM.OfAstM.throwExpected "identifier" x✝
Instances For
Equations
- StrataDDM.OfAstM.ofAnnIdentM (StrataDDM.ArgF.ident ann val) = pure { ann := ann, val := val }
- StrataDDM.OfAstM.ofAnnIdentM x✝ = StrataDDM.OfAstM.throwExpected "identifier" x✝
Instances For
Equations
- StrataDDM.OfAstM.ofNumM (StrataDDM.ArgF.num ann val) = pure val
- StrataDDM.OfAstM.ofNumM x✝ = StrataDDM.OfAstM.throwExpected "numeric literal" x✝
Instances For
Equations
- StrataDDM.OfAstM.ofAnnNumM (StrataDDM.ArgF.num ann val) = pure { ann := ann, val := val }
- StrataDDM.OfAstM.ofAnnNumM x✝ = StrataDDM.OfAstM.throwExpected "numeric literal" x✝
Instances For
Equations
- StrataDDM.OfAstM.ofDecimalM (StrataDDM.ArgF.decimal ann val) = pure val
- StrataDDM.OfAstM.ofDecimalM x✝ = StrataDDM.OfAstM.throwExpected "scientific literal" x✝
Instances For
Equations
- StrataDDM.OfAstM.ofAnnDecimalM (StrataDDM.ArgF.decimal ann val) = pure { ann := ann, val := val }
- StrataDDM.OfAstM.ofAnnDecimalM x✝ = StrataDDM.OfAstM.throwExpected "scientific literal" x✝
Instances For
Equations
- StrataDDM.OfAstM.ofStrlitM (StrataDDM.ArgF.strlit ann val) = pure val
- StrataDDM.OfAstM.ofStrlitM x✝ = StrataDDM.OfAstM.throwExpected "string literal" x✝
Instances For
Equations
- StrataDDM.OfAstM.ofAnnStrlitM (StrataDDM.ArgF.strlit ann val) = pure { ann := ann, val := val }
- StrataDDM.OfAstM.ofAnnStrlitM x✝ = StrataDDM.OfAstM.throwExpected "string literal" x✝
Instances For
Equations
- StrataDDM.OfAstM.ofBytesM (StrataDDM.ArgF.bytes ann val) = pure val
- StrataDDM.OfAstM.ofBytesM x✝ = StrataDDM.OfAstM.throwExpected "byte array" x✝
Instances For
Equations
- StrataDDM.OfAstM.ofAnnBytesM (StrataDDM.ArgF.bytes ann val) = pure { ann := ann, val := val }
- StrataDDM.OfAstM.ofAnnBytesM x✝ = StrataDDM.OfAstM.throwExpected "byte array" x✝
Instances For
Convert Ann Bool to OperationF
Equations
- One or more equations did not get rendered due to their size.
Instances For
Convert OperationF to Ann Bool
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
Instances For
def
StrataDDM.OfAstM.ofOptionM
{α β : Type}
[Repr α]
[SizeOf α]
(arg : ArgF α)
(act : (e : ArgF α) → sizeOf e < sizeOf arg → OfAstM β)
:
Equations
- StrataDDM.OfAstM.ofOptionM (StrataDDM.ArgF.option ann none) act_3 = pure { ann := ann, val := none }
- StrataDDM.OfAstM.ofOptionM (StrataDDM.ArgF.option ann (some v)) act_3 = (fun (v : β) => { ann := ann, val := some v }) <$> act_3 v ⋯
- StrataDDM.OfAstM.ofOptionM arg act = StrataDDM.OfAstM.throwExpected "option" arg
Instances For
def
StrataDDM.OfAstM.ofSeqM
{α β : Type}
[Repr α]
[SizeOf α]
(sep : SepFormat)
(arg : ArgF α)
(act : (e : ArgF α) → sizeOf e < sizeOf arg → OfAstM β)
:
Equations
- One or more equations did not get rendered due to their size.
- StrataDDM.OfAstM.ofSeqM sep arg act = StrataDDM.OfAstM.throwExpected sep.toString arg
Instances For
def
StrataDDM.OfAstM.matchTypeParamOrType
{Ann : Type}
{α : Type u_1}
[Repr Ann]
(a : ArgF Ann)
(onTypeParam : Ann → α)
(onType : TypeExprF Ann → OfAstM α)
:
OfAstM α
Distinguishes between a type parameter (category reference) and a type expression in Init.TypeP, applying the appropriate handler.
Equations
- One or more equations did not get rendered due to their size.
- StrataDDM.OfAstM.matchTypeParamOrType (StrataDDM.ArgF.type tp) onTypeParam onType = onType tp
- StrataDDM.OfAstM.matchTypeParamOrType a onTypeParam onType = StrataDDM.OfAstM.throwExpected "Type parameter or type expression" a