Welcome to the PEG-Parser for Racket repository!
The PEG-Parser for Racket is a powerful tool designed to facilitate the creation of parsers for the Racket programming language. It is based on Parsing Expression Grammars (PEG) and incorporates type inference to ensure the termination of all parsing expressions.
- PEG-based Parsing: Leverage the simplicity and expressive power of Parsing Expression Grammars to define your parsers.
- Type Inference: Ensure the termination of parsing expressions by utilizing type inference techniques. No type annotations required !
- Generic Abstract Syntax Tree (AST): A simple, generic AST structure is generated as the result of parsing, making it easy to manipulate and work with the parsed data.
To start using the PEG Parser for Racket, follow these simple steps:
Clone this repository to your local machine.
git clone https://github.com/lives-group/peg-parser.git
Additionally you can also install PEG-Parser from the Racket package repository:
raco pkg install peg-parser
Here is an example of a simple parser for logic expressions involving only the constants True "T" and False "F".
#lang peg-parser
Consts <-- -'T' ~W
/ -'F' ~W;
OR <-- '\|'~W;
AND <-- '^' ~W;
AP <-- '(' ~W;
FP <-- ')' ~W;
Formula <-- Ands ( ~^OR Ands)*;
Ands <-- ^Not ( ~^AND ^Not)*;
Not <-- (~'~' ~W) (^Consts / ~AP Formula ~FP ) / ^Consts;
W <-- [' ', '\n', '\t']*;
start: Formula
Consult the documentation and examples provided to learn how to define and generate parsers using the tool.
Please read the documentation here for more specific details on the usage of library.
This project is licensed under the MIT License.