diff options
Diffstat (limited to 'core/src/Text/Edifact/Common.hs')
-rw-r--r-- | core/src/Text/Edifact/Common.hs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/core/src/Text/Edifact/Common.hs b/core/src/Text/Edifact/Common.hs new file mode 100644 index 0000000..c938d48 --- /dev/null +++ b/core/src/Text/Edifact/Common.hs | |||
@@ -0,0 +1,39 @@ | |||
1 | {-| | ||
2 | Module : Text.Edifact.Common | ||
3 | Description : Common syntax | ||
4 | |||
5 | This module should handle the main revision of the Edifact specification, which | ||
6 | covers UN* segments. | ||
7 | |||
8 | Currently it barely covers the revision 3 and this has not been scaffolded. | ||
9 | |||
10 | One future evolution will be to scaffold the various revisions from a more | ||
11 | general specification. | ||
12 | -} | ||
13 | module Text.Edifact.Common | ||
14 | ( | ||
15 | -- * Routine | ||
16 | parseFull | ||
17 | |||
18 | -- * Reexports | ||
19 | , ParseError | ||
20 | , Parser | ||
21 | , Text | ||
22 | ) where | ||
23 | |||
24 | import Text.Edifact.Parsing | ||
25 | import Text.Edifact.Parsing.Commons | ||
26 | |||
27 | import Text.Edifact.Common.Segments | ||
28 | |||
29 | import Data.Text (Text) | ||
30 | |||
31 | parseFull :: Parser value -> Text -> Either ParseError value | ||
32 | parseFull = parse . fullSyntaxParser | ||
33 | |||
34 | fullSyntaxParser :: Parser a -> Parser a | ||
35 | fullSyntaxParser messageParser = | ||
36 | segmentUNA >> | ||
37 | tries [ segmentUNB *> messageParser <* segmentUNZ | ||
38 | , messageParser | ||
39 | ] | ||