Git Product home page Git Product logo

example_grammars's Introduction

example_grammars

Introduction

This repository contains examples to supplement the main parsing libraries I work on.

Quick links

Install

Probably easiest via opam, with something like:

opam install -y dune ocamlfind odoc
opam pin add -y -n p0_lib https://github.com/tomjridge/p0.git#dev
opam pin add -y -n example_grammars https://github.com/tomjridge/example_grammars.git
opam install -y p0_lib example_grammars

P0, ABNF example

At the moment, the main example is a sequence of P0 parsers. The first implements a parser for "Plain BNF". Subsequent parsers culminate in a parser for the IMAP protocol.

Briefly, we parse a specification of ABNF (almost directly from the RFC!), and generate an ABNF parser generator. We then use this to parse the IMAP grammar (directly from the RFC!), and in turn use this to generate an IMAP protocol parser. We can then use this to parse IMAP protocol messages. So, rather convoluted... but this is mainly to demonstrate the flexibility of the underlying techniques. And hopefully, the IMAP parser will conform to the spec "by construction".

See <./src/README.md> for further details.

A fragment of the ABNF specification (adapted from the RFC) is:

2019-07-29.165930

A fragment of the generated ABNF parser is:

1557223111833

A fragment of the IMAP grammar (from the RFC) used to generate the IMAP parser, is:

1557223376198

example_grammars's People

Contributors

tomjridge avatar

Stargazers

Laeeth Isharc avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

ismailkuru laeeth

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.