Copyright | See LICENSE file |
---|---|
License | BSD3 |
Maintainer | Brad Neimann |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Brassica.SFM.SFM
Contents
Description
This module implements basic support for the SIL Standard Format
Marker (SFM) format, used by dictionary software such as
FieldWorks. This format forms
the basis of standards such as Multi-Dictionary Formatter (MDF),
implemented here in Brassica.SFM.MDF
.
Synopsis
- data Field = Field {}
- type SFM = [Field]
- parseSFM :: String -> String -> Either (ParseErrorBundle String Void) SFM
- exactPrintField :: Field -> String
- exactPrintSFM :: SFM -> String
- stripSourcePos :: Field -> Field
- type Hierarchy = Map String String
- data SFMTree
- toTree :: Hierarchy -> SFM -> SFMTree
- fromTree :: SFMTree -> SFM
- mapField :: (Field -> Field) -> SFMTree -> SFMTree
- searchField :: (Field -> Maybe a) -> SFMTree -> [a]
Linear SFM documents
A single field of an SFM file.
Constructors
Field | |
Fields
|
Arguments
:: String | Name of source file |
-> String | Input SFM data to parse |
-> Either (ParseErrorBundle String Void) SFM |
Parse an SFM file to an SFM
value.
exactPrintSFM :: SFM -> String Source #
Given an SFM
, reconstruct the original file. A trivial wrapper
around exactPrintField
.
stripSourcePos :: Field -> Field Source #
Set the fieldSourcePos
of a Field
to Nothing
. Useful for
making debug output shorter.
Hierarchies
type Hierarchy = Map String String Source #
The hierarchy underlying an SFM document, defined as a map from field names to their parents. Fields which are absent from the map are treated as roots.
Rose tree describing a hierarchical SFM document.
toTree :: Hierarchy -> SFM -> SFMTree Source #
Generate a tree structure from an SFM
document according to the
given Hierarchy
. Fields are converted to Filled
nodes,
containing as many following nodes as possible, until the next node
which is at the same level of the hierarchy or lower. Missing
nodes are created for any missing levels of the hierarchy.