Code Monkey home page Code Monkey logo

elixirparslet's Introduction

Parslet

A port of Ruby's Parslet library to Erlang

Done

I have something similar to Parslet's "Parser" classes working. I have a JSON parser working (without whitespace) as a proof of completeness.

See the tests for examples on how to use this module.

Missing

Parslet has a concept of Transformers. These take your parsed structure and using a depth first approach allow you to apply transformations from leaves to the top of the tree. This lets you split your parsing problem into "collect all the data from the file" then "translate it to a format I want to consume".

This approach is what I love about Parslet, so would not be a complete solution without it.

The error handling is woeful. To be of use, this parser needs to pass around line numbers etc from the source document so you know at what point in your document and grammer the parser failed. This is something that Parslet does quite well.

Future

Primarily I am working on this to learn Elixir.

I want to learn OTP next, so I'm going to experiment with an OTP version next. I have been warned that this is a terrible idea for a real PEG parser generator due to the slow communications overhead. Given this is a toy for learning; sounds like I should learn a lot.

I haven't got my head around OTP yet, so here's my initial plan...

I forsee rules each build an actor, so the document gets passed around and gradually consumed.

Something that is missing from the original ... is the ability to run the parser in several modes. One mode is the production parser.. which just parses the document to data, so you can transform it, and should be really fast.. Another is for grammer development ... the feedback should be around where the parser failed.. not where text was wrong... and it should detect endless loops in your grammer.

Installation

If available in Hex, the package can be installed by adding parslet to your list of dependencies in mix.exs:

def deps do
  [
    {:parslet, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/parslet.

elixirparslet's People

Contributors

nigelthorne avatar dependabot-preview[bot] avatar

Stargazers

Patrick Smith avatar Armin Sadeghi avatar  avatar Chris Keathley avatar  avatar

Watchers

 avatar James Cloos avatar

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.