This repository contains a fixed-point parsing framework and a collection of personal parsers built using it. The framework is designed to support left-recursive and ambiguous parsing through memoization, making it suitable for complex grammars. The repository also includes example parsers and test cases to demonstrate its capabilities.
- Fixed-Point Parsing Framework: A modular and extensible framework for building parsers with support for memoization and recursive grammars.
- Example Parsers:
- Expression Parser: Parses mathematical expressions with support for addition, subtraction, multiplication, and division.
- Tego Parser: Parses a custom language called Tego, which includes constructs like functions, conditionals, and pattern matching.
- Test Suite: Comprehensive test cases for the framework and parsers using OUnit2.
- OCaml (>= 4.12.0)
- Dune (>= 3.17)
- OPAM for dependency management
-
Clone the repository:
git clone https://github.com/pixilcode/fpp_personal_parsers.git cd fpp_personal_parsers -
Install dependencies:
opam install . --deps-only -
Build the project:
dune build
The repository includes a command-line interface for parsing input strings using the available parsers.
dune exec parse -- <parser> <input><parser>: The parser to use (exprfor the expression parser,tegofor the Tego parser).<input>: The input string to parse.
Example:
dune exec parse expr "1+2*3"To run the test suite:
dune testThe expression parser supports basic arithmetic operations:
dune exec parse expr "3+5*(2-1)"The Tego parser can parse and analyze programs written in the Tego language:
dune exec parse tego "def main = addOne 1"- The framework uses memoization to handle recursive grammars efficiently.
- The notes.md file contains insights and challenges encountered during development.
This project is licensed under the MIT License. See the LICENSE file for details.