Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Examples for Pinchot are in this hierarchy. Start out with
Pinchot.Examples.Postal, which contains a sample grammar.
Next, Pinchot.Examples.SyntaxTrees shows you how to convert
your grammar to data types, and Pinchot.Examples.AllRulesRecord
shows how to make a product type holding an Earley
Prod
for every Rule
in your grammar. Then,
Pinchot.Earley shows how to generate the Earley
Grammar
you need to actually parse strings.
Pinchot.Examples.Terminalize shows you how to generate data
types that will reduce any Rule
to the sequence of terminal
tokens from which it came. This can be useful not only for
reconstructing the source text, but also for determining where in
the source text a production was found.
Pinchot.Examples.RulesToOptics shows how to generate lenses and isos, which are valuable for navigating and manipulating large trees.
Finally, Pinchot.Examples.Newman shows how to actually run the
Earley parsers, find the locations of various productions, and
show the results on-screen. You can play with
address
and
addressFromFile
in GHCi. Or, if you
compile the Pinchot package using the executables
flag, you
will get an executable named newman
that you can play with from
the command line.