forked from GitHub/gf-core
GF.Grammar.Canonical: add TuplePattern and CommentedValue
This commit is contained in:
@@ -69,6 +69,7 @@ data LinValue = ConcatValue LinValue LinValue
|
|||||||
| PreValue [([String], LinValue)] LinValue
|
| PreValue [([String], LinValue)] LinValue
|
||||||
| Projection LinValue LabelId
|
| Projection LinValue LabelId
|
||||||
| Selection LinValue LinValue
|
| Selection LinValue LinValue
|
||||||
|
| CommentedValue String LinValue
|
||||||
deriving (Eq,Ord,Show)
|
deriving (Eq,Ord,Show)
|
||||||
|
|
||||||
data LinLiteral = FloatConstant Float
|
data LinLiteral = FloatConstant Float
|
||||||
@@ -78,6 +79,7 @@ data LinLiteral = FloatConstant Float
|
|||||||
|
|
||||||
data LinPattern = ParamPattern ParamPattern
|
data LinPattern = ParamPattern ParamPattern
|
||||||
| RecordPattern [RecordRow LinPattern]
|
| RecordPattern [RecordRow LinPattern]
|
||||||
|
| TuplePattern [LinPattern]
|
||||||
| WildPattern
|
| WildPattern
|
||||||
deriving (Eq,Ord,Show)
|
deriving (Eq,Ord,Show)
|
||||||
|
|
||||||
@@ -213,6 +215,7 @@ instance Pretty LinValue where
|
|||||||
Projection lv l -> ppA lv<>"."<>l
|
Projection lv l -> ppA lv<>"."<>l
|
||||||
Selection tv pv -> ppA tv<>"!"<>ppA pv
|
Selection tv pv -> ppA tv<>"!"<>ppA pv
|
||||||
VariantValue vs -> "variants"<+>block vs
|
VariantValue vs -> "variants"<+>block vs
|
||||||
|
CommentedValue s v -> "{-" <+> s <+> "-}" $$ v
|
||||||
_ -> ppA lv
|
_ -> ppA lv
|
||||||
|
|
||||||
instance PPA LinValue where
|
instance PPA LinValue where
|
||||||
@@ -253,6 +256,7 @@ instance PPA LinPattern where
|
|||||||
ppA p =
|
ppA p =
|
||||||
case p of
|
case p of
|
||||||
RecordPattern r -> block r
|
RecordPattern r -> block r
|
||||||
|
TuplePattern ps -> "<"<>punctuate "," ps<>">"
|
||||||
WildPattern -> pp "_"
|
WildPattern -> pp "_"
|
||||||
_ -> parens p
|
_ -> parens p
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user