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 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
.
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. Unlisted fields are treated as roots.
Rose tree describing a hierarchical SFM document.