diff options
| author | Thomas Hallgren <th-github@altocumulus.org> | 2019-01-23 02:47:10 +0100 |
|---|---|---|
| committer | Thomas Hallgren <th-github@altocumulus.org> | 2019-01-23 02:47:10 +0100 |
| commit | 951b8841187ed2ba4c2815a074e68697544f31a5 (patch) | |
| tree | 50633e6d928789c240454eb65eaedc6b2ad59f59 /src/compiler/GF/Grammar/Canonical.hs | |
| parent | fc5c2b5a22f66912c1e5dab97a35c2f229093255 (diff) | |
Export of concrete syntax to Haskell now goes via Canonical GF
TODO: better treatment of Predef functions and record subtyping coercions
Diffstat (limited to 'src/compiler/GF/Grammar/Canonical.hs')
| -rw-r--r-- | src/compiler/GF/Grammar/Canonical.hs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/compiler/GF/Grammar/Canonical.hs b/src/compiler/GF/Grammar/Canonical.hs index 6d08b815f..0da72d634 100644 --- a/src/compiler/GF/Grammar/Canonical.hs +++ b/src/compiler/GF/Grammar/Canonical.hs @@ -14,6 +14,7 @@ data Grammar = Grammar Abstract [Concrete] deriving Show -- | Abstract Syntax data Abstract = Abstract ModId Flags [CatDef] [FunDef] deriving Show +abstrName (Abstract mn _ _ _) = mn data CatDef = CatDef CatId [CatId] deriving Show data FunDef = FunDef FunId Type deriving Show @@ -54,6 +55,7 @@ data LinValue = ConcatValue LinValue LinValue | FloatConstant Float | IntConstant Int | ParamConstant ParamValue + | PredefValue PredefId | RecordValue [RecordRowValue] | StrConstant String | TableValue LinType [TableRowValue] @@ -64,29 +66,30 @@ data LinValue = ConcatValue LinValue LinValue | PreValue [([String], LinValue)] LinValue | Projection LinValue LabelId | Selection LinValue LinValue - deriving (Eq,Show) + deriving (Eq,Ord,Show) data LinPattern = ParamPattern ParamPattern | RecordPattern [RecordRow LinPattern] | WildPattern - deriving (Eq,Show) + deriving (Eq,Ord,Show) type ParamValue = Param LinValue type ParamPattern = Param LinPattern type ParamValueDef = Param ParamId -data Param arg = Param ParamId [arg] deriving (Eq,Show) +data Param arg = Param ParamId [arg] deriving (Eq,Ord,Show) type RecordRowType = RecordRow LinType type RecordRowValue = RecordRow LinValue data RecordRow rhs = RecordRow LabelId rhs deriving (Eq,Ord,Show) -data TableRowValue = TableRowValue LinPattern LinValue deriving (Eq,Show) +data TableRowValue = TableRowValue LinPattern LinValue deriving (Eq,Ord,Show) -- *** Identifiers in Concrete Syntax -newtype LabelId = LabelId String deriving (Eq,Ord,Show) -data VarValueId = VarValueId String deriving (Eq,Show) +newtype PredefId = PredefId String deriving (Eq,Ord,Show) +newtype LabelId = LabelId String deriving (Eq,Ord,Show) +data VarValueId = VarValueId String deriving (Eq,Ord,Show) -- | Name of param type or param value newtype ParamId = ParamId String deriving (Eq,Ord,Show) @@ -96,7 +99,7 @@ newtype ParamId = ParamId String deriving (Eq,Ord,Show) newtype ModId = ModId String deriving (Eq,Show) -newtype CatId = CatId String deriving (Eq,Show) +newtype CatId = CatId String deriving (Eq,Ord,Show) newtype FunId = FunId String deriving (Eq,Show) data VarId = Anonymous | VarId String deriving Show @@ -203,6 +206,7 @@ instance PPA LinValue where FloatConstant f -> pp f IntConstant n -> pp n ParamConstant pv -> ppA pv + PredefValue p -> ppA p RecordValue [] -> pp "<>" RecordValue rvs -> block rvs PreValue alts def -> @@ -245,6 +249,8 @@ instance Pretty ModId where pp (ModId s) = pp s instance Pretty CatId where pp (CatId s) = pp s instance Pretty FunId where pp (FunId s) = pp s instance Pretty LabelId where pp (LabelId s) = pp s +instance Pretty PredefId where pp = ppA +instance PPA PredefId where ppA (PredefId s) = pp s instance Pretty ParamId where pp = ppA instance PPA ParamId where ppA (ParamId s) = pp s instance Pretty VarValueId where pp (VarValueId s) = pp s |
