Parser combinators in Nix for no-nixpkgs parsing.
Nix isn't meant to be a general purpose programming language, so using parser combinators like this should generally be avoided. Here are some reasons to prefer a pure-Nix parser over other approaches:
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 ...
If you are using Nix Flakes, you can add nix-parsec as an input:
{
inputs = {
nix-parsec.url = "github:nprindle/nix-parsec";
};
outputs = { self, nix-parsec, ... }: {
# ...
};
}
At the top level, two attribute sets are exported:
parsec: Parser combinators and functions to run parserslexer: Combinators for parsing token-related thingsThe parsing/lexing APIs roughly correspond to those of Haskell's megaparsec
library. See examples/ for some example parsers.
49 commits
1 commits
Nix
100.0%
Parser combinators in Nix for no-nixpkgs parsing.
Nix isn't meant to be a general purpose programming language, so using parser combinators like this should generally be avoided. Here are some reasons to prefer a pure-Nix parser over other approaches:
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 ...
If you are using Nix Flakes, you can add nix-parsec as an input:
{
inputs = {
nix-parsec.url = "github:nprindle/nix-parsec";
};
outputs = { self, nix-parsec, ... }: {
# ...
};
}
At the top level, two attribute sets are exported:
parsec: Parser combinators and functions to run parserslexer: Combinators for parsing token-related thingsThe parsing/lexing APIs roughly correspond to those of Haskell's megaparsec
library. See examples/ for some example parsers.
49 commits
1 commits
Nix
100.0%