Skip to content

steven-mathew/glarser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

glarser

A WIP parser combinator library in Gleam without any dependencies. You can just copy-paste it into your project and use it.

In future, this will be added as a package to hex.pm.

Example usage

let is_space = fn(c) { c == " " }
let non = fn(f, x) { !f(x) }
let is_not_space = non(is_space, _)

let parser =
  succeed2(string.append)
  |> keep(parse_while(is_not_space))
  |> drop(parse_while(is_space))
  |> keep(parse_while(is_not_space))

run(make_input("Hello   world"), parser)
  |> result.unwrap("")

Development

Use in devShell for nix develop

Running nix develop will create a shell with gleam and erlang installed.

Acknowledgements

A huge thanks to Tsoding's parcoom library and Hayleigh's gleam-string-parser whose libraries this one is based on.

References

About

Monadic Parser Combinator library in Gleam

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published