Pegger 1.1.8Parsing Expression Grammar (PEG) for when Regular Expressions just aren't enough!
Parsing Expression Grammar (PEG) for when Regular Expressions just aren't enough!
Pegger is a Parsing Expression Grammar (PEG) implementation. It lets you create text parsers by building up a tree of simple matching rules.
Advanced parsing options let you look ahead with predicates, and throw errors to fail fast.
Pegger has been used (by Fantom Factory) to parse HTML, CSS, Markdown, and ANBF - to name but a few. The general strategy is usually:
- Create a structure of Fantom data classes
- Create a grammar to parse text documents into a node tree
- Trim the tree by removing labels and branches, so the tree resembles the structure of the Fantom classes
- Walk the tree, recursively creating corresponding data classes
Pegger was inspired by Mouse, Parboiled for Java, and pegs for NIM.
Install
To install Pegger with Fantom Pod Manager, cut'n'paste the following into a cmd prompt, terminal or shell:
Or to install Pegger with the Fantom Repository Manager (fanr), cut'n'paste the following into a cmd prompt, terminal or shell:
Or to install manually, download the pod file and copy it to the %FAN_HOME%/lib/fan/
directory.
Use
To use Pegger in a Fantom project, add a dependency to the project's build.fan
:
depends = ["sys 1.0", ..., "afPegger 1.1.8 - 1.1"]
Documentation
Information
Meta information on the Pegger pod:
- Published by
- Steve Eynon
- Organisation
- Fantom-Factory Ltd
- Pod file size
- 154.97 kB
- Licence
- ISC
- Built on
- 3rd Sep 2023
- Source code
- via Git at https://github.com/Fantom-Factory/afPegger
- Depends on
- sys
- Referenced by
- afEggbox, afHtmlParser, afMarkdownParser, afSlim
- Javascript Compatible
Dependency Graph
Release History
There have been 9 releases of Pegger: