mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-30 23:02:50 -06:00
Expose GF.Grammar.Canonical + some refactoring
to make it available in other tools by depending on the gf package and importing it
This commit is contained in:
@@ -95,10 +95,7 @@ instance JSON LinType where
|
||||
|
||||
instance JSON LinValue where
|
||||
showJSON lv = case lv of
|
||||
-- basic values (Str, Float, Int) are encoded as JSON strings/numbers:
|
||||
StrConstant s -> showJSON s
|
||||
FloatConstant f -> showJSON f
|
||||
IntConstant n -> showJSON n
|
||||
LiteralValue l -> showJSON l
|
||||
-- concatenation is encoded as a JSON array:
|
||||
ConcatValue v v' -> showJSON [showJSON v, showJSON v']
|
||||
-- most values are encoded as JSON objects:
|
||||
@@ -115,6 +112,13 @@ instance JSON LinValue where
|
||||
-- records are encoded directly as JSON records:
|
||||
RecordValue rows -> showJSON rows
|
||||
|
||||
instance JSON LinLiteral where
|
||||
showJSON l = case l of
|
||||
-- basic values (Str, Float, Int) are encoded as JSON strings/numbers:
|
||||
StrConstant s -> showJSON s
|
||||
FloatConstant f -> showJSON f
|
||||
IntConstant n -> showJSON n
|
||||
|
||||
instance JSON LinPattern where
|
||||
showJSON linpat = case linpat of
|
||||
-- wildcards and patterns without arguments are encoded as strings:
|
||||
@@ -161,6 +165,10 @@ instance JSON VarId where
|
||||
showJSON Anonymous = showJSON "_"
|
||||
showJSON (VarId x) = showJSON x
|
||||
|
||||
instance JSON QualId where
|
||||
showJSON (Qual (ModId m) n) = showJSON (m++"_"++n)
|
||||
showJSON (Unqual n) = showJSON n
|
||||
|
||||
instance JSON Flags where
|
||||
-- flags are encoded directly as JSON records (i.e., objects):
|
||||
showJSON (Flags fs) = makeObj [(f,showJSON v) | (f, v) <- fs]
|
||||
|
||||
Reference in New Issue
Block a user