parsers/toml/parser

Well tested

A parser for Tom’s Obvious Minimal Language (toml). That’s the language gleam.toml is written on, for instance.

The implementation is heavily inspired by htoml. All valid tests of toml-test pass.

There is a function to parse:

try parsed = parser.parse("[a]")

Given this source code:

name = "parser_gleam"
version = "0.0.6"

licences = ["AGPL-3.0-or-later"]
description = "A porting of parser-ts, purescript-eulalie to Gleam"
repository = { type = "github", user = "lucasavila00", repo = "parser_gleam" }

[dependencies]
gleam_stdlib = "~> 0.22"
fp_gl = "~> 0.0"

[dev-dependencies]
gleeunit = "~> 0.6"
rad = "~> 0.1"

This AST is produced:

[
#("name", VString("parser_gleam")),
#("version", VString("0.0.6")),
#("licences", VArray([VString("AGPL-3.0-or-later")])),
#(
  "description",
  VString("A porting of parser-ts, purescript-eulalie to Gleam"),
),
#(
  "repository",
  VTable([
    #("type", VString("github")),
    #("user", VString("lucasavila00")),
    #("repo", VString("parser_gleam")),
  ]),
),
#(
  "dependencies",
  VTable([
    #("gleam_stdlib", VString("~> 0.22")),
    #("fp_gl", VString("~> 0.0")),
  ]),
),
#(
  "dev-dependencies",
  VTable([#("gleeunit", VString("~> 0.6")), #("rad", VString("~> 0.1"))]),
),
]

Functions

pub fn parse(it: String) -> Result(List(#(String, Node)), String)
pub fn parser() -> fn(Stream(String)) ->
  Result(
    ParseSuccess(String, List(#(String, Node))),
    ParseError(String),
  )
Search Document