mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-08-21 03:36:22 -06:00
the JSON dump now supports the entire GF language
This commit is contained in:
@@ -31,6 +31,7 @@ import qualified Data.ByteString.Char8 as BS(append,isPrefixOf)
|
||||
-- UTF-8-encoded bytestrings!
|
||||
import Data.Char(isDigit)
|
||||
import Data.Binary(Binary(..))
|
||||
import Text.JSON hiding (Result(..))
|
||||
import GF.Text.Pretty
|
||||
|
||||
|
||||
@@ -46,6 +47,10 @@ instance Binary ModuleName where
|
||||
put (MN id) = put id
|
||||
get = fmap MN get
|
||||
|
||||
instance JSON ModuleName where
|
||||
showJSON (MN id) = showJSON id
|
||||
readJSON o = MN <$> readJSON o
|
||||
|
||||
-- | the constructors labelled /INTERNAL/ are
|
||||
-- internal representation never returned by the parser
|
||||
data Ident =
|
||||
@@ -101,6 +106,14 @@ instance Pretty Ident where pp = pp . showIdent
|
||||
|
||||
instance Pretty RawIdent where pp = pp . showRawIdent
|
||||
|
||||
instance JSON Ident where
|
||||
showJSON i = showJSON $ ident2raw i
|
||||
readJSON o = identC <$> readJSON o
|
||||
|
||||
instance JSON RawIdent where
|
||||
showJSON i = showJSON $ showRawIdent i
|
||||
readJSON o = rawIdentS <$> readJSON o
|
||||
|
||||
identS :: String -> Ident
|
||||
identS = identC . rawIdentS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user