the JSON dump now supports the entire GF language

This commit is contained in:
Krasimir Angelov
2025-03-26 14:56:08 +01:00
parent 65e4ca309c
commit e6c4775ade
9 changed files with 227 additions and 1340 deletions
+13
View File
@@ -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