Code Monkey home page Code Monkey logo

nix-parsec's Introduction

nix-parsec

Parser combinators in Nix. Nix isn't meant to be a general purpose programming language, so using parser combinators like this should really be avoided, unless:

  • Nix's built-in regex tools won't work for your use case
    • You usually don't need to parse things in Nix, and when you do, you usually don't need anything more powerful than regex
  • Parsing performance will not be a bottleneck for the build
    • If it is, consider implementing your parser in your language of choice and using nix to invoke it
  • It's difficult to pass results of parsing in another language back to Nix

Don't ask what I actually needed this for.

Usage

Include by fetching via usual means (fetchTarball, fetchFromGitHub, etc.):

let
  version = "v0.1.0";
  sha256 = "...";

  nix-parsec = import (builtins.fetchTarball {
    url = "https://github.com/nprindle/nix-parsec/archive/${version}.tar.gz";
    inherit sha256;
  });

  inherit (nix-parsec) parsec lexer;
in ...

At the top level, two attribute sets are exported:

  • parsec: Parser combinators and functions to run parsers
  • lexer: Combinators for parsing token-related things

The parsing/lexing APIs roughly corresponds to those of Haskell's megaparsec library. See examples/ for some example parsers.

nix-parsec's People

Contributors

kanwren avatar seppeljordan avatar

Watchers

 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.