diff options
author | Frédéric Menou <frederic.menou@fretlink.com> | 2016-12-08 10:19:15 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@fretlink.com> | 2022-05-17 18:01:51 +0200 |
commit | a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7 (patch) | |
tree | adf3186fdccaeef19151026cdfbd38a530cf9ecb /core/src/Text/Edifact/Parsing.hs | |
download | edi-parser-master.tar.gz edi-parser-master.tar.zst edi-parser-master.zip |
Diffstat (limited to 'core/src/Text/Edifact/Parsing.hs')
-rw-r--r-- | core/src/Text/Edifact/Parsing.hs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/core/src/Text/Edifact/Parsing.hs b/core/src/Text/Edifact/Parsing.hs new file mode 100644 index 0000000..0b1ece8 --- /dev/null +++ b/core/src/Text/Edifact/Parsing.hs | |||
@@ -0,0 +1,72 @@ | |||
1 | {-| | ||
2 | Module : Text.Edifact.Parsing | ||
3 | Description : Parsing routines and combinators | ||
4 | |||
5 | This module is there to reexport most of the combinators and helpers required | ||
6 | to parse an Edifact payload. | ||
7 | |||
8 | For high level combinators, have a look at "Text.Edifact.Parsing.Combinators". | ||
9 | |||
10 | For low level combinators, have a look at "Text.Edifact.Parsing.Primitives". | ||
11 | -} | ||
12 | module Text.Edifact.Parsing | ||
13 | ( | ||
14 | -- * Parsing routines | ||
15 | parse | ||
16 | |||
17 | -- * Combinators | ||
18 | -- | See "Text.Edifact.Parsing.Combinators" for more details | ||
19 | |||
20 | -- ** Values parsers | ||
21 | , message | ||
22 | , segment | ||
23 | , segmentGroup | ||
24 | , composite | ||
25 | , simple | ||
26 | |||
27 | -- ** Position and strictness | ||
28 | , position | ||
29 | , (.@) | ||
30 | , (@.) | ||
31 | , mandatory | ||
32 | , optional | ||
33 | |||
34 | -- ** Repetition of segments and segment groups | ||
35 | , repeated | ||
36 | , repeatedAtLeastOnce | ||
37 | , once | ||
38 | , maybeOnce | ||
39 | |||
40 | -- * Primitives | ||
41 | -- | See "Text.Edifact.Parsing.Primitives" for more details and known limitations. | ||
42 | |||
43 | -- ** Simple elements definition | ||
44 | , alphaNumeric | ||
45 | , alpha | ||
46 | , numeric | ||
47 | -- ** Cardinality | ||
48 | , exactly | ||
49 | , upTo | ||
50 | , many | ||
51 | |||
52 | -- * Types | ||
53 | , Parser | ||
54 | -- ** Reexported | ||
55 | , ParseError | ||
56 | ) where | ||
57 | |||
58 | import Text.Edifact.Parsing.Combinators (composite, mandatory, | ||
59 | maybeOnce, message, once, | ||
60 | optional, position, repeated, | ||
61 | repeatedAtLeastOnce, segment, | ||
62 | segmentGroup, simple, (.@), | ||
63 | (@.)) | ||
64 | import Text.Edifact.Parsing.Commons (Parser, defaultContext) | ||
65 | import Text.Edifact.Parsing.Primitives (alpha, alphaNumeric, exactly, | ||
66 | many, numeric, upTo) | ||
67 | |||
68 | import Data.Text (Text) | ||
69 | import Text.Parsec (ParseError, runParser) | ||
70 | |||
71 | parse :: Parser value -> Text -> Either ParseError value | ||
72 | parse p = runParser p defaultContext "" | ||