expression =
symbol
| quoted_string
| "[" , { expression } , "]"
| "(" , { expression } , ")" ;symbol_character =
? not (")" | "(" | "[" | "]" | U+0022 | WHITESPACE) ? ;
symbol =
symbol_character , { symbol_character } ;
quoted_character =
? not U+0022 ? ;
quoted_string =
U+0022 , (quoted_character | escape) , { (quoted_character | escape) } , U+0022 ;
escape =
escape_carriage
| escape_newline
| escape_tab
| escape_quote
| escape_unicode4
| escape_unicode8 ;
escape_carriage =
"\r" ;
escape_newline =
"\n" ;
escape_quote =
"\" , U+0022 ;
escape_tab =
"\t" ;
escape_unicode4 =
"\u" ,
hex_digit , hex_digit , hex_digit , hex_digit ;
escape_unicode8 =
"\u" ,
hex_digit , hex_digit , hex_digit , hex_digit ,
hex_digit , hex_digit , hex_digit , hex_digit ;
hex_digit =
"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0" |
"a" | "A" | "b" | "B" | "c" | "C" | "d" | "D" | "e" | "E" | "f" | "F" ;
data Rule = MAnySymbol | MAnyQuoted | MAnyList | MExactSymbol String | MExactQuoted String | MExactList [Rule] | MChoice [Rule] | MListVariadic [Rule] Rule deriving Eq
instance Show Rule where show (MExactSymbol s) = "(#exact-symbol " ++ s ++ ")" show (MExactQuoted s) = "(#exact-quoted " ++ s ++ ")" show (MExactList s) = "(#exact-list [" ++ (concatMap show s) ++ "])" show MAnySymbol = "#any-symbol" show MAnyQuoted = "#any-quoted" show MAnyList = "#any-list" show (MChoice s) = "(#choice [" ++ (concatMap show s) ++ "])" show (MListVariadic s m) = "(#variadic [" ++ (concatMap show s) ++ "]" ++ (show m) ++ ")"
matches :: SE.Expr -> Rule -> Bool
matches (SE.ESymbol e) (MExactSymbol s) = e == s
matches (SE.ESymbol _) (MExactQuoted _) = False
matches (SE.ESymbol _) (MExactList _) = False
matches (SE.ESymbol _) MAnySymbol = True
matches (SE.ESymbol _) MAnyQuoted = False
matches (SE.ESymbol _) MAnyList = False
matches (SE.ESymbol _) (MListVariadic _ _) = False
matches (SE.EQuoted _) MAnySymbol = False
matches (SE.EQuoted _) MAnyQuoted = True
matches (SE.EQuoted _) MAnyList = False
matches (SE.EQuoted e) (MExactQuoted s) = e == s
matches (SE.EQuoted _) (MExactSymbol _) = False
matches (SE.EQuoted _) (MExactList _) = False
matches (SE.EQuoted _) (MListVariadic _ _) = False
matches (SE.EList _) (MExactSymbol _) = False
matches (SE.EList _) (MExactQuoted _) = False
matches (SE.EList _) MAnySymbol = False
matches (SE.EList _) MAnyQuoted = False
matches (SE.EList _) MAnyList = True
matches (SE.EList s) (MExactList m) =
(length s) == (length m) && all (\(xe,xm) -> matches xe xm) (zip s m)
matches (SE.EList s) (MListVariadic m0 mr) =
if (length s >= length m0)
then
let
prefix_zip = take (length m0) (zip s m0)
prefix_ok = all (\(xe,xm) -> matches xe xm) prefix_zip
suffix = drop (length m0) s
suffix_zip = zip suffix (replicate (length suffix) mr)
suffix_ok = all (\(xe,xm) -> matches xe xm) suffix_zip
in
prefix_ok && suffix_ok
else
False
matches e (MChoice m0)= 1 == length (filter (matches e) m0)
> matches (SE.ESymbol "x") MAnySymbol True > matches (SE.EQuoted "x") MAnySymbol False
> matches (SE.EList [SE.ESymbol "x", SE.ESymbol "y", SE.ESymbol "z"]) (MExactList [MExactSymbol "x", MExactSymbol "y", MExactSymbol "z"]) True > matches (SE.EList [SE.ESymbol "x", SE.ESymbol "y", SE.ESymbol "y"]) (MExactList [MExactSymbol "x", MExactSymbol "y", MExactSymbol "z"]) False > matches (SE.EList [SE.ESymbol "x", SE.ESymbol "y"]) (MExactList [MExactSymbol "x", MExactSymbol "y", MExactSymbol "z"]) False
data InlineContent = ICText InlineText | ICTerm InlineTerm | ICImage InlineImage | ICVerbatim InlineVerbatim | ICLink InlineLinkInternal | ICLinkExternal InlineLinkExternal | ICListOrdered InlineListOrdered | ICListUnordered InlineListUnordered | ICFootnoteRef InlineFootnoteRef | ICTable InlineTable | ICInclude InlineInclude deriving Eq
type_character =
? p{IsLetter} | p{isNumber} | U+005F ? ;
type =
type_character , { type_character } ;
data InlineText = InlineText String deriving Eq
data InlineTerm = InlineTerm {
termType :: Maybe String,
termContent :: [InlineText]
} deriving Eq
data InlineImage = InlineImage {
imageType :: Maybe String,
imageTarget :: URI.T,
imageSize :: Maybe Size,
imageContent :: [InlineText]
} deriving Eq
data InlineVerbatim = InlineVerbatim {
verbatimType :: Maybe String,
verbatimContent :: InlineText
} deriving Eq
data InlineLinkInternal = InlineLinkInternal {
linkInternalTarget :: ID.T,
linkInternalContent :: [LinkContent]
} deriving Eq
data InlineLinkExternal = InlineLinkExternal {
linkExternalTarget :: URI.T,
linkExternalContent :: [LinkContent]
} deriving Eq
data InlineFootnoteRef = InlineFootnoteRef {
footnoteTarget :: ID.T
} deriving Eq
data InlineListOrdered = InlineListOrdered {
listOrderedItems :: [ListItem]
} deriving Eq
data InlineListUnordered = InlineListUnordered {
listUnorderedItems :: [ListItem]
} deriving Eq
data TableCell = TableCell {
tableCellContent :: [TableCellContent]
} deriving Eq
data TableRow = TableRow {
tableRowCells :: [TableCell]
} deriving Eq
data InlineTable = InlineTable {
tableType :: Maybe String,
tableSummary :: [InlineText],
tableHead :: Maybe TableHead,
tableBody :: TableBody
} deriving Eq
data TableRow = TableRow {
tableRowCells :: [TableCell]
} deriving Eq
tableCheck :: InlineTable -> Bool
tableCheck table =
case (tableHead table) of
Nothing -> True
Just th ->
let rows = tableBodyRows $ tableBody table
expected = length $ tableHeadNames th
in all (\row -> length (tableRowCells row) == expected) rows
data TableCellContent = TCText InlineText | TCTerm InlineTerm | TCImage InlineImage | TCVerbatim InlineVerbatim | TCLink InlineLinkInternal | TCLinkExternal InlineLinkExternal | TCListOrdered InlineListOrdered | TCListUnordered InlineListUnordered | TCFootnoteRef InlineFootnoteRef | TCInclude InlineInclude deriving Eq
data InlineInclude = InlineInclude {
includeFile :: String
} deriving Eq
module InlineContent where
import qualified URI
import qualified ID
data InlineText =
InlineText String
deriving Eq
data InlineTerm = InlineTerm {
termType :: Maybe String,
termContent :: [InlineText]
} deriving Eq
data Size = Size {
sizeWidth :: Integer,
sizeHeight :: Integer
} deriving Eq
data InlineImage = InlineImage {
imageType :: Maybe String,
imageTarget :: URI.T,
imageSize :: Maybe Size,
imageContent :: [InlineText]
} deriving Eq
data InlineVerbatim = InlineVerbatim {
verbatimType :: Maybe String,
verbatimContent :: InlineText
} deriving Eq
data LinkContent
= LCText InlineText
| LCImage InlineImage
deriving Eq
data InlineLinkInternal = InlineLinkInternal {
linkInternalTarget :: ID.T,
linkInternalContent :: [LinkContent]
} deriving Eq
data InlineLinkExternal = InlineLinkExternal {
linkExternalTarget :: URI.T,
linkExternalContent :: [LinkContent]
} deriving Eq
data ListItem = ListItem {
listItemContent :: [InlineContent]
} deriving Eq
data InlineListOrdered = InlineListOrdered {
listOrderedItems :: [ListItem]
} deriving Eq
data InlineListUnordered = InlineListUnordered {
listUnorderedItems :: [ListItem]
} deriving Eq
data InlineFootnoteRef = InlineFootnoteRef {
footnoteTarget :: ID.T
} deriving Eq
type TableColumnName = [InlineText]
data TableHead = TableHead {
tableHeadNames :: [TableColumnName]
} deriving Eq
data TableCell = TableCell {
tableCellContent :: [TableCellContent]
} deriving Eq
data TableCellContent
= TCText InlineText
| TCTerm InlineTerm
| TCImage InlineImage
| TCVerbatim InlineVerbatim
| TCLink InlineLinkInternal
| TCLinkExternal InlineLinkExternal
| TCListOrdered InlineListOrdered
| TCListUnordered InlineListUnordered
| TCFootnoteRef InlineFootnoteRef
| TCInclude InlineInclude
deriving Eq
data TableRow = TableRow {
tableRowCells :: [TableCell]
} deriving Eq
data TableBody = TableBody {
tableBodyRows :: [TableRow]
} deriving Eq
data InlineTable = InlineTable {
tableType :: Maybe String,
tableSummary :: [InlineText],
tableHead :: Maybe TableHead,
tableBody :: TableBody
} deriving Eq
tableCheck :: InlineTable -> Bool
tableCheck table =
case (tableHead table) of
Nothing -> True
Just th ->
let rows = tableBodyRows $ tableBody table
expected = length $ tableHeadNames th
in all (\row -> length (tableRowCells row) == expected) rows
data InlineInclude = InlineInclude {
includeFile :: String
} deriving Eq
data InlineContent
= ICText InlineText
| ICTerm InlineTerm
| ICImage InlineImage
| ICVerbatim InlineVerbatim
| ICLink InlineLinkInternal
| ICLinkExternal InlineLinkExternal
| ICListOrdered InlineListOrdered
| ICListUnordered InlineListUnordered
| ICFootnoteRef InlineFootnoteRef
| ICTable InlineTable
| ICInclude InlineInclude
deriving Eq
id_character =
? p{IsLetter} | p{isNumber} | U+005F | U+002D | U+002E ? ;
id =
id_character , { id_character } ;
module IDExistence where
import qualified ID
import qualified BlockContent as BC
import qualified Control.Monad as CM
class HasID a where
hasID :: ID.T -> a -> Maybe ID.T
maybeEq :: Eq a => a -> Maybe a -> Maybe a
maybeEq x Nothing = Nothing
maybeEq x (Just y) = if x == y then Just y else Nothing
instance HasID BC.BlockParagraph where
hasID k b = maybeEq k (BC.para_id b)
instance HasID BC.BlockFormalItem where
hasID k b = maybeEq k (BC.formal_id b)
instance HasID BC.BlockFootnote where
hasID k b = maybeEq k (Just $ BC.footnote_id b)
instance HasID BC.SubsectionContent where
hasID k (BC.SCParagraph b) = hasID k b
hasID k (BC.SCFormalItem b) = hasID k b
hasID k (BC.SCFootnote b) = hasID k b
instance HasID BC.BlockSubsection where
hasID k b =
case maybeEq k (BC.subsection_id b) of
Just x -> Just k
Nothing -> CM.foldM hasID k (BC.subsection_content b)
instance HasID BC.BlockSection where
hasID k b =
case maybeEq k (BC.section_id b) of
Just x -> Just k
Nothing ->
case BC.section_content b of
Left ss -> CM.foldM hasID k ss
Right sc -> CM.foldM hasID k sc
instance HasID BC.BlockPart where
hasID k b =
case maybeEq k (BC.part_id b) of
Just x -> Just k
Nothing -> CM.foldM hasID k (BC.part_content b)
instance HasID BC.BlockDocument where
hasID k b =
case maybeEq k (BC.document_id b) of
Just x -> Just k
Nothing ->
case BC.document_content b of
Left p -> CM.foldM hasID k p
Right s -> CM.foldM hasID k s
data BlockParagraph = BlockParagraph {
para_type :: Maybe String,
para_id :: Maybe ID.T,
para_content :: [I.InlineContent]
}
data BlockFormalItem = BlockFormalItem {
formal_type :: Maybe String,
formal_id :: Maybe ID.T,
formal_title :: [I.InlineText],
formal_content :: [I.InlineContent]
}
data BlockFootnote = BlockFootnote {
footnote_type :: Maybe String,
footnote_id :: ID.T,
footnote_content :: [I.InlineContent]
}
data SubsectionContent = SCParagraph BlockParagraph | SCFormalItem BlockFormalItem | SCFootnote BlockFootnote
data BlockSubsection = BlockSubsection {
subsection_type :: Maybe String,
subsection_id :: Maybe ID.T,
subsection_title :: [I.InlineText],
subsection_content :: [SubsectionContent]
}
data BlockSection = BlockSection {
section_type :: Maybe String,
section_id :: Maybe ID.T,
section_title :: [I.InlineText],
section_content :: Either [BlockSubsection] [SubsectionContent]
}
data BlockPart = BlockPart {
part_type :: Maybe String,
part_id :: Maybe ID.T,
part_title :: [I.InlineText],
part_content :: [BlockSection]
}
data BlockDocument = BlockDocument {
document_type :: Maybe String,
document_id :: Maybe ID.T,
document_title :: [I.InlineText],
document_content :: Either [BlockPart] [BlockSection]
}
data BlockImport = BlockImport {
importFile :: String
}
canon_inline =
(#choice [
canon_footnote_ref
canon_image
canon_include
canon_link
canon_link_external
canon_list_ordered
canon_list_unordered
canon_term
canon_text
canon_verbatim
])
canon_text = (#choice [#any-symbol #any-quoted]) canon_text_or_include = (#choice [canon_text canon_include])
canon_type =
(#exact-list [#exact-symbol "type"] #any-symbol)
canon_term_name =
(#exact-symbol "term")
canon_term =
(#choice [
(#variadic [canon_term_name] canon_text_or_include)
(#variadic [canon_term_name canon_type] canon_text_or_include)
])
canon_target =
(#exact-list [#exact-symbol "target"] canon_text)
canon_size =
(#exact-list [#exact-symbol "size"] #any-symbol #any-symbol)
canon_image_name =
(#exact-symbol "image")
canon_image =
(#choice [
(#variadic [canon_image_name canon_target] canon_text_or_include)
(#variadic [canon_image_name canon_target canon_type] canon_text_or_include)
(#variadic [canon_image_name canon_target canon_size] canon_text_or_include)
(#variadic [canon_image_name canon_target canon_size canon_type] canon_text_or_include)
])
canon_verbatim_name =
(#exact-symbol "verbatim")
canon_verbatim =
(#choice [
(#exact-list [canon_verbatim_name canon_text_or_include])
(#exact-list [canon_verbatim_name canon_type canon_text_or_include])
])
canon_link_name = (#exact-symbol "link") canon_link = (#variadic [canon_link_name canon_target] canon_text_or_include)
canon_link_external_name = (#exact-symbol "link-ext") canon_link_external = (#variadic [canon_link_external_name canon_target] canon_text_or_include)
canon_footnote_ref_name = (#exact-symbol "footnote-ref") canon_footnote_ref = (#exact-list canon_footnote_ref_name canon_text)
canon_list_item_name = (#exact-symbol "item") canon_list_item = (#variadic [canon_list_item_name] canon_inline) canon_list_ordered_name = (#exact-symbol "list-ordered") canon_list_ordered = (#variadic [canon_list_ordered_name] canon_list_item)
canon_list_unordered_name = (#exact-symbol "list-unordered") canon_list_unordered = (#variadic [canon_list_unordered_name] canon_list_item)
canon_table_name =
(#exact-symbol "table")
canon_table_summary_name =
(#exact-symbol "summary")
canon_table_summary =
(#variadic [canon_table_summary_name] canon_text_or_include)
canon_table_body_cell_name =
(#exact-symbol "cell")
canon_table_body_cell =
(#variadic [canon_table_body_cell_name] canon_inline)
canon_table_body_row_name =
(#exact-symbol "row")
canon_table_body_row =
(#variadic [canon_table_body_row_name] canon_table_body_cell)
canon_table_body_name =
(#exact-symbol "body")
canon_table_body =
(#variadic [canon_table_body_name] canon_table_body_row)
canon_table_body_head_cell_name =
(#exact-symbol "name")
canon_table_body_head_cell =
(#variadic [canon_table_body_head_cell_name] canon_text)
canon_table_head_name =
(#exact-symbol "head")
canon_table_head =
(#variadic [canon_table_head_name] canon_table_head_cell)
canon_table =
(#choice [
(#exact-list [canon_table_name canon_table_summary cannon_table_body])
(#exact-list [canon_table_name canon_table_summary canon_type cannon_table_body])
(#exact-list [canon_table_name canon_table_summary cannon_table_head cannon_table_body])
(#exact-list [canon_table_name canon_table_summary canon_type cannon_table_head cannon_table_body])
])
canon_include_name = (#exact-symbol "include") canon_include = (#exact-list [canon_include_name #any-quoted])
canon_id_name =
(#exact-symbol "id")
canon_id =
(#exact-list [canon_id_name canon_text])
canon_paragraph_name =
(#exact-symbol "paragraph")
canon_paragraph =
(#choice [
(#variadic [canon_paragraph_name] canon_inline)
(#variadic [canon_paragraph_name canon_id] canon_inline)
(#variadic [canon_paragraph_name canon_id canon_type] canon_inline)
(#variadic [canon_paragraph_name canon_type canon_id] canon_inline)
(#variadic [canon_paragraph_name canon_type] canon_inline)
])
canon_title_name =
(#exact-symbol "title")
canon_title =
(#variadic [canon_title_name] canon_text)
canon_formal_item_name =
(#exact-symbol "formal-item")
canon_formal_item =
(#choice [
(#variadic [canon_formal_item_name canon_title] canon_inline)
(#variadic [canon_formal_item_name canon_title canon_id] canon_inline)
(#variadic [canon_formal_item_name canon_title canon_id canon_type] canon_inline)
(#variadic [canon_formal_item_name canon_title canon_type canon_id] canon_inline)
(#variadic [canon_formal_item_name canon_title canon_type] canon_inline)
])
canon_footnote_name =
(#exact-symbol "footnote")
canon_footnote =
(#choice [
(#variadic [canon_footnote_name canon_id] canon_inline)
(#variadic [canon_footnote_name canon_id canon_type] canon_inline)
])
canon_subsection_name =
(#exact-symbol "subsection")
canon_subsection_content =
(#choice [canon_paragraph canon_footnote canon_formal_item])
canon_subsection =
(#choice [
(#variadic [canon_subsection_name canon_title] canon_subsection_content)
(#variadic [canon_subsection_name canon_title canon_id] canon_subsection_content)
(#variadic [canon_subsection_name canon_title canon_id canon_type] canon_subsection_content)
(#variadic [canon_subsection_name canon_title canon_type canon_id] canon_subsection_content)
(#variadic [canon_subsection_name canon_title canon_type] canon_subsection_content)
])
canon_section_name =
(#exact-symbol "section")
canon_section_content =
(#choice [canon_subsection canon_subsection_content])
canon_section =
(#choice [
(#variadic [canon_section_name canon_title] canon_section_content)
(#variadic [canon_section_name canon_title canon_id] canon_section_content)
(#variadic [canon_section_name canon_title canon_id canon_type] canon_section_content)
(#variadic [canon_section_name canon_title canon_type canon_id] canon_section_content)
(#variadic [canon_section_name canon_title canon_type] canon_section_content)
])
canon_part_name =
(#exact-symbol "part")
canon_part =
(#choice [
(#variadic [canon_part_name canon_title] canon_section)
(#variadic [canon_part_name canon_title canon_id] canon_section)
(#variadic [canon_part_name canon_title canon_id canon_type] canon_section)
(#variadic [canon_part_name canon_title canon_type canon_id] canon_section)
(#variadic [canon_part_name canon_title canon_type] canon_section)
])
canon_document_name =
(#exact-symbol "document")
canon_document_content =
(#choice [canon_section canon_part])
canon_document =
(#choice [
(#variadic [canon_document_name canon_title] canon_document_content)
(#variadic [canon_document_name canon_title canon_id] canon_document_content)
(#variadic [canon_document_name canon_title canon_id canon_type] canon_document_content)
(#variadic [canon_document_name canon_title canon_type canon_id] canon_document_content)
(#variadic [canon_document_name canon_title canon_type] canon_document_content)
])
canon_import_name = (#exact-symbol "import") canon_import = (#exact-list [canon_import_name canon_text])
[subsection [title An example subsection]] [paragraph] This is some content for the first paragraph. [paragraph] This is some [term [type emphasis] content] for the second paragraph. [subsection [title Another example subsection]] [paragraph] This is some content for the first paragraph of the next section.
data ImperativeContent = ICParagraph ImperativeParagraph | ICFormalItem ImperativeFormalItem | ICFootnote ImperativeFootnote | ICSubsection ImperativeSubsection | ICSection ImperativeSection | ICPart ImperativePart | ICDocument ImperativeDocument | ICImport ImperativeImport deriving Eq
instance Ord ImperativeContent where compare (ICParagraph _) (ICParagraph _) = EQ compare (ICParagraph _) (ICFormalItem _) = EQ compare (ICParagraph _) (ICFootnote _) = EQ compare (ICParagraph _) (ICSubsection _) = LT compare (ICParagraph _) (ICSection _) = LT compare (ICParagraph _) (ICPart _) = LT compare (ICParagraph _) (ICDocument _) = LT compare (ICFormalItem _) (ICParagraph _) = EQ compare (ICFormalItem _) (ICFormalItem _) = EQ compare (ICFormalItem _) (ICFootnote _) = EQ compare (ICFormalItem _) (ICSubsection _) = LT compare (ICFormalItem _) (ICSection _) = LT compare (ICFormalItem _) (ICPart _) = LT compare (ICFormalItem _) (ICDocument _) = LT compare (ICFootnote _) (ICParagraph _) = EQ compare (ICFootnote _) (ICFormalItem _) = EQ compare (ICFootnote _) (ICFootnote _) = EQ compare (ICFootnote _) (ICSubsection _) = LT compare (ICFootnote _) (ICSection _) = LT compare (ICFootnote _) (ICPart _) = LT compare (ICFootnote _) (ICDocument _) = LT compare (ICSubsection _) (ICParagraph _) = GT compare (ICSubsection _) (ICFormalItem _) = GT compare (ICSubsection _) (ICFootnote _) = GT compare (ICSubsection _) (ICSubsection _) = EQ compare (ICSubsection _) (ICSection _) = LT compare (ICSubsection _) (ICPart _) = LT compare (ICSubsection _) (ICDocument _) = LT compare (ICSection _) (ICParagraph _) = GT compare (ICSection _) (ICFormalItem _) = GT compare (ICSection _) (ICFootnote _) = GT compare (ICSection _) (ICSubsection _) = GT compare (ICSection _) (ICSection _) = EQ compare (ICSection _) (ICPart _) = LT compare (ICSection _) (ICDocument _) = LT compare (ICPart _) (ICParagraph _) = GT compare (ICPart _) (ICFormalItem _) = GT compare (ICPart _) (ICFootnote _) = GT compare (ICPart _) (ICSubsection _) = GT compare (ICPart _) (ICSection _) = GT compare (ICPart _) (ICPart _) = EQ compare (ICPart _) (ICDocument _) = LT compare (ICDocument _) (ICParagraph _) = GT compare (ICDocument _) (ICFormalItem _) = GT compare (ICDocument _) (ICFootnote _) = GT compare (ICDocument _) (ICSubsection _) = GT compare (ICDocument _) (ICSection _) = GT compare (ICDocument _) (ICPart _) = GT compare (ICDocument _) (ICDocument _) = EQ compare (ICImport i) e = compare (importContent i) e compare e (ICImport i) = compare e (importContent i)
importContent :: ImperativeImport -> ImperativeContent importContent _ = undefined
data ImperativeParagraph = ImperativeParagraph {
para_type :: Maybe String,
para_id :: Maybe ID.T
} deriving Eq
imperative_paragraph =
(#choice [
(#exact-list [canon_paragraph_name])
(#exact-list [canon_paragraph_name canon_id])
(#exact-list [canon_paragraph_name canon_id canon_type])
(#exact-list [canon_paragraph_name canon_type canon_id])
(#exact-list [canon_paragraph_name canon_type])
])
data ImperativeFormalItem = ImperativeFormalItem {
formal_type :: Maybe String,
formal_id :: Maybe ID.T,
formal_title :: [I.InlineText]
} deriving Eq
imperative_formal_item =
(#choice [
(#exact-list [canon_formal_item_name canon_title])
(#exact-list [canon_formal_item_name canon_title canon_id])
(#exact-list [canon_formal_item_name canon_title canon_id canon_type])
(#exact-list [canon_formal_item_name canon_title canon_type canon_id])
(#exact-list [canon_formal_item_name canon_title canon_type])
])
data ImperativeFootnote = ImperativeFootnote {
footnote_type :: Maybe String,
footnote_id :: ID.T
} deriving Eq
imperative_footnote =
(#choice [
(#exact-list [canon_footnote_name canon_id])
(#exact-list [canon_footnote_name canon_id canon_type])
])
data ImperativeSubsection = ImperativeSubsection {
subsection_type :: Maybe String,
subsection_id :: Maybe ID.T,
subsection_title :: [I.InlineText]
} deriving Eq
imperative_subsection =
(#choice [
(#exact-list [canon_subsection_name canon_title])
(#exact-list [canon_subsection_name canon_title canon_id])
(#exact-list [canon_subsection_name canon_title canon_id canon_type])
(#exact-list [canon_subsection_name canon_title canon_type canon_id])
(#exact-list [canon_subsection_name canon_title canon_type])
])
data ImperativeSection = ImperativeSection {
section_type :: Maybe String,
section_id :: Maybe ID.T,
section_title :: [I.InlineText]
} deriving Eq
imperative_section =
(#choice [
(#exact-list [canon_section_name canon_title])
(#exact-list [canon_section_name canon_title canon_id])
(#exact-list [canon_section_name canon_title canon_id canon_type])
(#exact-list [canon_section_name canon_title canon_type canon_id])
(#exact-list [canon_section_name canon_title canon_type])
])
data ImperativePart = ImperativePart {
part_type :: Maybe String,
part_id :: Maybe ID.T,
part_title :: [I.InlineText]
} deriving Eq
imperative_part =
(#choice [
(#exact-list [canon_part_name canon_title])
(#exact-list [canon_part_name canon_title canon_id])
(#exact-list [canon_part_name canon_title canon_id canon_type])
(#exact-list [canon_part_name canon_title canon_type canon_id])
(#exact-list [canon_part_name canon_title canon_type])
])
data ImperativeDocument = ImperativeDocument {
document_type :: Maybe String,
document_id :: Maybe ID.T,
document_title :: [I.InlineText]
} deriving Eq
imperative_document =
(#choice [
(#exact-list [canon_document_name canon_title])
(#exact-list [canon_document_name canon_title canon_id])
(#exact-list [canon_document_name canon_title canon_id canon_type])
(#exact-list [canon_document_name canon_title canon_type canon_id])
(#exact-list [canon_document_name canon_title canon_type])
])
<?xml version="1.0" encoding="UTF-8"?>
<r:grammar
xmlns:s="http://schemas.io7m.com/structural/3.0.0"
xmlns:r="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<r:start combine="choice">
<r:ref name="io7m.structural-3_0_0.block_content"/>
</r:start>
<r:define name="io7m.structural-3_0_0.xml-id">
<r:attribute name="xml:id">
<r:data type="ID"/>
</r:attribute>
</r:define>
<r:define name="io7m.structural-3_0_0.standard-attributes">
<r:optional>
<r:attribute name="xml:base">
<r:text/>
</r:attribute>
</r:optional>
<r:optional>
<r:attribute name="xml:lang">
<r:text/>
</r:attribute>
</r:optional>
<r:optional>
<r:attribute name="s:type">
<r:data type="token"/>
</r:attribute>
</r:optional>
</r:define>
<r:define name="io7m.structural-3_0_0.inline_text">
<r:text/>
</r:define>
<r:define name="io7m.structural-3_0_0.inline_footnote_ref">
<r:element name="s:footnote-ref">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:attribute name="s:target">
<r:data type="IDREF"/>
</r:attribute>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.inline_term">
<r:element name="s:term">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.inline_text"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.inline_verbatim">
<r:element name="s:verbatim">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.inline_text"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.inline_image">
<r:element name="s:image">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:attribute name="s:target">
<r:data type="anyURI"/>
</r:attribute>
<r:optional>
<r:attribute name="s:width">
<r:data type="positiveInteger"/>
</r:attribute>
<r:attribute name="s:height">
<r:data type="positiveInteger"/>
</r:attribute>
</r:optional>
<r:text/>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.list_item">
<r:element name="s:item">
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.inline_content"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.inline_list_ordered">
<r:element name="s:list-ordered">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.list_item"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.inline_list_unordered">
<r:element name="s:list-unordered">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.list_item"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.table_head_column_name">
<r:element name="s:name">
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.inline_text"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.table_head">
<r:element name="s:head">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.table_head_column_name"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.table_body_cell">
<r:element name="s:cell">
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.inline_content"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.table_body_row">
<r:element name="s:row">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.table_body_cell"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.table_body">
<r:element name="s:body">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.table_body_row"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.inline_table">
<r:element name="s:table">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:attribute name="s:summary">
<r:text/>
</r:attribute>
<r:optional>
<r:ref name="io7m.structural-3_0_0.table_head"/>
</r:optional>
<r:ref name="io7m.structural-3_0_0.table_body"/>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.link_content">
<r:choice>
<r:ref name="io7m.structural-3_0_0.inline_text"/>
<r:ref name="io7m.structural-3_0_0.inline_image"/>
</r:choice>
</r:define>
<r:define name="io7m.structural-3_0_0.inline_link">
<r:element name="s:link">
<r:attribute name="s:target">
<r:data type="IDREF"/>
</r:attribute>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.link_content"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.inline_link_external">
<r:element name="s:link-external">
<r:attribute name="s:target">
<r:data type="anyURI"/>
</r:attribute>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.link_content"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.inline_content">
<r:choice>
<r:ref name="io7m.structural-3_0_0.inline_footnote_ref"/>
<r:ref name="io7m.structural-3_0_0.inline_image"/>
<r:ref name="io7m.structural-3_0_0.inline_link"/>
<r:ref name="io7m.structural-3_0_0.inline_link_external"/>
<r:ref name="io7m.structural-3_0_0.inline_list_ordered"/>
<r:ref name="io7m.structural-3_0_0.inline_list_unordered"/>
<r:ref name="io7m.structural-3_0_0.inline_table"/>
<r:ref name="io7m.structural-3_0_0.inline_term"/>
<r:ref name="io7m.structural-3_0_0.inline_text"/>
<r:ref name="io7m.structural-3_0_0.inline_verbatim"/>
</r:choice>
</r:define>
<r:define name="io7m.structural-3_0_0.subsection_content">
<r:choice>
<r:ref name="io7m.structural-3_0_0.footnote"/>
<r:ref name="io7m.structural-3_0_0.formal_item"/>
<r:ref name="io7m.structural-3_0_0.paragraph"/>
</r:choice>
</r:define>
<r:define name="io7m.structural-3_0_0.paragraph">
<r:element name="s:paragraph">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:optional>
<r:ref name="io7m.structural-3_0_0.xml-id"/>
</r:optional>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.inline_content"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.formal_item">
<r:element name="s:formal-item">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:optional>
<r:ref name="io7m.structural-3_0_0.xml-id"/>
</r:optional>
<r:attribute name="s:title">
<r:text/>
</r:attribute>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.inline_content"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.footnote">
<r:element name="s:footnote">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:ref name="io7m.structural-3_0_0.xml-id"/>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.inline_content"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.document">
<r:element name="s:document">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:optional>
<r:ref name="io7m.structural-3_0_0.xml-id"/>
</r:optional>
<r:attribute name="s:title">
<r:text/>
</r:attribute>
<r:choice>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.part"/>
</r:zeroOrMore>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.section"/>
</r:zeroOrMore>
</r:choice>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.part">
<r:element name="s:part">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:optional>
<r:ref name="io7m.structural-3_0_0.xml-id"/>
</r:optional>
<r:attribute name="s:title">
<r:text/>
</r:attribute>
<r:choice>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.section"/>
</r:zeroOrMore>
</r:choice>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.section">
<r:element name="s:section">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:optional>
<r:ref name="io7m.structural-3_0_0.xml-id"/>
</r:optional>
<r:attribute name="s:title">
<r:text/>
</r:attribute>
<r:choice>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.subsection"/>
</r:zeroOrMore>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.subsection_content"/>
</r:zeroOrMore>
</r:choice>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.subsection">
<r:element name="s:subsection">
<r:ref name="io7m.structural-3_0_0.standard-attributes"/>
<r:optional>
<r:ref name="io7m.structural-3_0_0.xml-id"/>
</r:optional>
<r:attribute name="s:title">
<r:text/>
</r:attribute>
<r:zeroOrMore>
<r:ref name="io7m.structural-3_0_0.subsection_content"/>
</r:zeroOrMore>
</r:element>
</r:define>
<r:define name="io7m.structural-3_0_0.block_content">
<r:choice>
<r:ref name="io7m.structural-3_0_0.document"/>
<r:ref name="io7m.structural-3_0_0.paragraph"/>
<r:ref name="io7m.structural-3_0_0.part"/>
<r:ref name="io7m.structural-3_0_0.subsection"/>
<r:ref name="io7m.structural-3_0_0.section"/>
<r:ref name="io7m.structural-3_0_0.footnote"/>
<r:ref name="io7m.structural-3_0_0.formal_item"/>
</r:choice>
</r:define>
</r:grammar>