Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type RuleName = String
- type BranchName = String
- data Rule t = Rule {}
- ruleName :: Lens' (Rule t) RuleName
- ruleDescription :: Lens' (Rule t) (Maybe String)
- ruleType :: Lens' (Rule t) (RuleType t)
- data Branch t = Branch {
- _branchName :: BranchName
- _branches :: Seq (Rule t)
- branchName :: Lens' (Branch t) BranchName
- branches :: Lens' (Branch t) (Seq (Rule t))
- data RuleType t
- _Terminal :: Prism' (RuleType t) (Intervals t)
- _NonTerminal :: Prism' (RuleType t) (NonEmptySeq (Branch t))
- _Wrap :: Prism' (RuleType t) (Rule t)
- _Record :: Prism' (RuleType t) (Seq (Rule t))
- _Opt :: Prism' (RuleType t) (Rule t)
- _Star :: Prism' (RuleType t) (Rule t)
- _Plus :: Prism' (RuleType t) (Rule t)
- recordFieldName :: Int -> String -> String -> String
- type Qualifier = String
- quald :: Qualifier -> String -> Name
- data Loc = Loc {}
- line :: Lens' Loc Int
- col :: Lens' Loc Int
- pos :: Lens' Loc Int
Documentation
type RuleName = String Source #
Type synonym for the name of a production rule. This will be the
name of the type constructor for the corresponding type that will
be created, so this must be a valid Haskell type constructor name.
Typically each context-free grammar that you write will have
several production rules; you will want to make sure that every
RuleName
that you create for a single context-free grammar is
unique. However, Pinchot currently does not check for
uniqueness. If you use names that are not unique, GHC will give
an error message when you try to splice the resulting code, as
the data types will not have unique names.
type BranchName = String Source #
Type synonym the the name of an alternative in a nonTerminal
.
This name must not conflict with any other data constructor in
your grammar.
A single production rule.
A branch in a sum rule. In Branch s ls
, s
is the name of the
data constructor, and ls
is the list of rules that this branch
produces.
Branch | |
|
branchName :: Lens' (Branch t) BranchName Source #
The type of a particular rule.
_NonTerminal :: Prism' (RuleType t) (NonEmptySeq (Branch t)) Source #
The name of a field in a record, without the leading underscore.
type Qualifier = String Source #
Many functions take an argument that holds the name qualifier
for the module that contains the data types created by applying a
function such as syntaxTrees
or
earleyProduct
.
You will have to make sure that these data types are in scope.
The spliced Template Haskell code has to know where to
look for these data types. If you did an unqualified import
or
if the types are in the same module as the function that takes a
Qualifier
argument, just pass the empty string here. If you did a
qualified import, use the appropriate qualifier here.
For example, if you used import qualified MyAst
, pass
"MyAst"
here. If you used import qualified
Data.MyLibrary.MyAst as MyLibrary.MyAst
, pass
"MyLibrary.MyAst"
here.
I recommend that you always create a new module and that all you
do in that module is apply syntaxTrees
or
earleyProduct
, and that you then perform an import
qualified
to bring those names into scope in the module in which
you use a function that takes a Qualifier
argument. This
avoids unlikely, but possible, issues that could otherwise arise
due to naming conflicts.
Prepends a qualifier to a string, and returns the resulting Name.
A location.