module z/anno/Types
imports
  z/Names
exports
  sorts Type Type2 Signature NameTypePair

  context-free syntax
    "[" {ZName ","}+ "]" {Type2 ","}+ -> Type {cons("ZGenType")}
    Type2                             -> Type

    "GIVEN" ZName                     -> Type2 {cons("ZGivenType")}
    "GENTYPE" ZName                   -> Type2 {cons("ZGenParaType")}
    "ℙ" Type2                         -> Type2 {cons("ZPowType")}
    {Type2 "×"}+                      -> Type2 {cons("ZProdType")}
    "[" Signature "]"                 -> Type2 {cons("ZSchemaType")}
    "(" Type2 ")"                     -> Type2 {bracket}

    {NameTypePair ";"}*               -> Signature {cons("ZSig")}
    ZName ":" Type                    -> NameTypePair {cons("ZNameTypePair")}

    "(" ZExpr "%" Type ")"            -> ZTerm {cons("ZTypedExpr")}
    Para  "%" Signature               -> Para {cons("ZTypedPara")}
    ZName "↘" WORD "↖"                -> ZName {cons("ZTypedName")}

  context-free priorities
    {
      left: {Type2 "×"}+ -> Type2
            Type2 -> {Type2 "×"}+
    }
