Safe Haskell | None |
---|---|
Language | Haskell2010 |
- label :: Rule t -> String -> Rule t
- (<?>) :: Rule t -> String -> Rule t
- rule :: RuleName -> RuleType t -> Rule t
- terminal :: RuleName -> Intervals t -> Rule t
- nonTerminal :: RuleName -> Seq (BranchName, Seq (Rule t)) -> Rule t
- union :: RuleName -> Seq (Rule t) -> Rule t
- terminals :: RuleName -> String -> Rule Char
- wrap :: RuleName -> Rule t -> Rule t
- record :: RuleName -> Seq (Rule t) -> Rule t
- opt :: Rule t -> Rule t
- star :: Rule t -> Rule t
- plus :: Rule t -> Rule t
- getAncestors :: Rule t -> State (Set RuleName) (Seq (Rule t))
- family :: Rule t -> Seq (Rule t)
- families :: Seq (Rule t) -> Seq (Rule t)
Documentation
label :: Rule t -> String -> Rule t Source
Name a Rule
for use in error messages. If you do not name a
rule using this combinator, the rule's type name will be used in
error messages.
Creates a terminal production rule. Example:
rLetter
.
:: RuleName | Will be used for the name of the resulting type |
-> Seq (BranchName, Seq (Rule t)) | Branches of the non-terminal production rule. This |
-> Rule t |
Creates a non-terminal production rule. This is the most
flexible way to create non-terminals. You can even create a
non-terminal that depends on itself. Example:
rLetters
.
:: RuleName | Will be used for the name of the resulting type |
-> Seq (Rule t) | List of branches. There must be at least one branch; otherwise a compile-time error will occur. |
-> Rule t |
Creates a non-terminal production rule where each branch has
only one production. This function ultimately uses
nonTerminal
. Each branch is assigned a BranchName
that is
RULE_NAME'PRODUCTION_NAME
where RULE_NAME
is the name of the rule itself, and
PRODUCTION_NAME
is the rule name for what is being produced.
Example: rDirection
.
:: RuleName | Will be used for the name of the resulting type, and for the name of the sole data constructor |
-> String | |
-> Rule Char |
Creates a production for a sequence of terminals. Useful for
parsing specific words. Ultimately this is simply a function
that creates a Rule
using the record
function.
In terminals n s
, For each Char
in the String
, a Rule
is
created whose RuleName
is n
followed by an apostrophe
followed by the index of the position of the Char
.
Examples: rBoulevard
.
:: RuleName | Will be used for the name of the resulting data type, and for the name of the sole data constructor |
-> Rule t | |
-> Rule t |
Creates a newtype wrapper. Example:
rCity
.
:: RuleName | The name of this rule, which is used both as the type name and for the name of the sole data constructor |
-> Seq (Rule t) | The right-hand side of this rule. This sequence can be empty, which results in an epsilon production. |
-> Rule t |
Creates a new non-terminal production rule with only one alternative where each field has a record name. The name of each record is:
_r'RULE_NAME'INDEX'FIELD_TYPE
where RULE_NAME
is the name of this rule, INDEX
is the index number
for this field (starting with 0), and FIELD_TYPE
is the type of the
field itself.
Currently there is no way to change the names of the record fields.
Example: rAddress
.
opt :: Rule t -> Rule t Source
Creates a rule for a production that optionally produces another
rule. The name for the created Rule
is the name of the Rule
to
which this function is applied, with 'Opt
appended to the end.
Example: rOptNewline
.
star :: Rule t -> Rule t Source
Creates a rule for the production of a sequence of other rules.
The name for the created Rule
is the name of the Rule
to which
this function is applied, with 'Star
appended.
Example: rPreSpacedWord
.
getAncestors :: Rule t -> State (Set RuleName) (Seq (Rule t)) Source
Gets all ancestor rules to this Rule
. Includes the current
rule if it has not already been seen.