All Projects → smolkaj → Nice Parser

smolkaj / Nice Parser

Licence: mit
Nice parsers in OCaml without the boilerplate

Programming Languages

ocaml
1615 projects

Projects that are alternatives of or similar to Nice Parser

abnf parsec
ABNF in, parser out
Stars: ✭ 42 (-53.85%)
Mutual labels:  parsing, parser-generator
copper
An integrated context-aware scanner and parser generator
Stars: ✭ 14 (-84.62%)
Mutual labels:  parsing, parser-generator
Antlr4
ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
Stars: ✭ 11,227 (+12237.36%)
Mutual labels:  parser-generator, parsing
Pollinate
Template your base files and generate new projects from Git(Hub).
Stars: ✭ 213 (+134.07%)
Mutual labels:  parsing, boilerplate
Cpp Peglib
A single file C++ header-only PEG (Parsing Expression Grammars) library
Stars: ✭ 435 (+378.02%)
Mutual labels:  parser-generator, parsing
YaccConstructor
Platform for parser generators and other grammarware research and development. GLL, RNGLR, graph parsing algorithms, and many others are included.
Stars: ✭ 36 (-60.44%)
Mutual labels:  parsing, parser-generator
pe
Fastest general-purpose parsing library for Python with a familiar API
Stars: ✭ 21 (-76.92%)
Mutual labels:  parsing, parser-generator
Rust Peg
Parsing Expression Grammar (PEG) parser generator for Rust
Stars: ✭ 836 (+818.68%)
Mutual labels:  parser-generator, parsing
inmemantlr
ANTLR as a libray for JVM based languages
Stars: ✭ 87 (-4.4%)
Mutual labels:  parsing, parser-generator
Covfefe
A parser for nondeterministic context free languages
Stars: ✭ 49 (-46.15%)
Mutual labels:  parsing, parser-generator
Owl
A parser generator for visibly pushdown languages.
Stars: ✭ 645 (+608.79%)
Mutual labels:  parser-generator, parsing
Lug
Parsing expression grammar (PEG) embedded domain specific language and parsing machine for C++17
Stars: ✭ 44 (-51.65%)
Mutual labels:  parser-generator, parsing
Webpack Defaults
Defaults to be shared across webpack projects
Stars: ✭ 88 (-3.3%)
Mutual labels:  boilerplate
Ant Design Pro Plus
✨ 基于 ant-design-pro 做一些微小的工作。
Stars: ✭ 88 (-3.3%)
Mutual labels:  boilerplate
Surveyjs react quickstart
React QuickStart Boilerplate - SurveyJS: Survey Library and Survey Creator
Stars: ✭ 88 (-3.3%)
Mutual labels:  boilerplate
Gatsby Starter Procyon
An opinionated Gatsby starter designed for trash-eating pandas.
Stars: ✭ 88 (-3.3%)
Mutual labels:  boilerplate
Pegtl
Parsing Expression Grammar Template Library
Stars: ✭ 1,295 (+1323.08%)
Mutual labels:  parsing
Buntis
A 100% compliant, self-hosted typescript parser that emits an ESTree-compatible AST
Stars: ✭ 90 (-1.1%)
Mutual labels:  parsing
Expo Boilerplate
React Native/Expo starting boilerplate with basic features (auth, tabs, i18n, redux, validation, notifications)
Stars: ✭ 88 (-3.3%)
Mutual labels:  boilerplate
Android Base
Android Clean Architecture MVP RESTful client template app
Stars: ✭ 87 (-4.4%)
Mutual labels:  boilerplate

For an older version of this repository based on sedlex, refer to the sedlex branch.

Nice Parser Build Status

Writing an OCaml parser with nice error messages should be easy - and now it is! Nice Parser comes in two parts:

  1. lib/: The nice_parser library (API) consolidates boilerplate code and wraps your auto-generated parser in a nice interface with beautiful error messages. In types: Nice_parser.Make : functor(P : RAW_PARSER) -> NICE_PARSER.
  2. example/: The example parser lets you get started on your own parser in seconds. It is based on nice_parser and standard tools:
    • Menhir, a LR(1) parser generator.
    • ocamllex, OCaml's built-in lexer generator.
    • Jane Street's dune and base, the de-facto standard built tool and standard library for OCaml.

Using the library and the skeleton, you can get started on your own parser in seconds:

opam install nice_parser                                # install the nice_parser library
git clone https://github.com/smolkaj/nice-parser.git    # clone this repository
cd nice-parser && rm -r lib && mv example src           # use example as starting point
dune build src/example.a                                # try to build...
dune exec src/bin/main.exe                              # ...and run your parser!

You should see the following output (the error message relies on OCaml >= 4.08's new source highlighting mechanism):

Trying to parse "(a b (c d) e)".
-> (List ((Atom a) (Atom b) (List ((Atom c) (Atom d))) (Atom e)))

Trying to parse "(long_atom_with_0123)".
-> (List ((Atom long_atom_with_0123)))

Trying to parse "
    ( so far so good
          but (this is)) illegal (isnt it?)
    (* parsing will fail ^^^^^^^ here *)
  ".
Fatal error: exception Line 3, characters 25-32:
3 |           but (this is)) illegal (isnt it?)
                             ^^^^^^^
Error: [parser] unexpected token

Documentation

The API is documented here. The example skeleton should be self-explanatory.

How to build

Ideally, use OCaml 4.08 or higher (for beautiful error messages). The project can be built using dune. Consult the dune-project file for the necessary dependencies; all of them can be installed using the opam packet manager.

Suggestions and Improvements

Suggestions and changes are welcome. Please submit pull requests, or open issues.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].