Skip to content
/ meg Public

A recursive-descent parser generator written in, and producing, OCaml

License

Notifications You must be signed in to change notification settings

cakemanny/meg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

meg

meg is mostly an OCaml implementation of a PEG based parser generator. It's based heavily on _why's greg

Besides actions being written in OCaml, the primary difference is that actions are expressions rather than statements.

So, with meg one would write

Expression
    : a=Product '+' b=Expression { a + b }
    | a=Product '-' b=Expression { a - b }
    ;

as opposed to, in leg/greg:

Expression
    = a:Product '+' b:Expression { $$ = a + b; }
    | a:Product '-' b:Expression { $$ = a - b; }

See samples/desk_calc.peg for a full translation of the desk calculator example from the peg/leg man page.

Installation

opam install .

Example use

meg samples/desk_calc.peg > samples/desk_calc.ml
ocamlc -o samples/desk_calc samples/desk_calc.ml

Hacking

To install the dependencies and test dependencies without installing meg:

opam install . --deps-only --with-test

Then building and testing can be run with dune:

dune build
dune runtest
dune exec meg ...

Links

License

peg/leg is copyright (c) 2007 by Ian Piumarta released under an MIT license. As is greg. As is meg.

About

A recursive-descent parser generator written in, and producing, OCaml

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages