mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-19 01:39:32 -06:00
PGF Service: add an option to return syntax trees in JSON format
The parse/translate/c-parse/c-translate commands now recognize the option jsontree=true to augment the returned JSON structure with a field called "jsontree" next to the field "tree", or "jsontrees" next to "trees", containing the the returned syntax tree in JSON format (the same format returned by the abstrjson command, similar to the format returned in the "brackets" field).
This commit is contained in:
@@ -349,12 +349,12 @@ browse pgf id = fmap (\def -> (def,producers,consumers)) definition
|
||||
expIds _ ids = ids
|
||||
|
||||
-- | A type for plain applicative trees
|
||||
data ATree = Other Tree | App CId [ATree] deriving Show
|
||||
data Trie = Oth Tree | Ap CId [[Trie ]] deriving Show
|
||||
data ATree t = Other t | App CId [ATree t] deriving Show
|
||||
data Trie = Oth Tree | Ap CId [[Trie ]] deriving Show
|
||||
-- ^ A type for tries of plain applicative trees
|
||||
|
||||
-- | Convert a 'Tree' to an 'ATree'
|
||||
toATree :: Tree -> ATree
|
||||
toATree :: Tree -> ATree Tree
|
||||
toATree e = maybe (Other e) app (unApp e)
|
||||
where
|
||||
app (f,es) = App f (map toATree es)
|
||||
|
||||
Reference in New Issue
Block a user