Show HN: Parsby – Parser combinator library for Ruby
github.com
github.com
The biggest difference to Haskell's Parsec is probably the automatic labeling and error messages[1]:
pry(main)> Parsby::Example::LispParser.sexp.parse "(foo `(foo ,bar) 2.3 . . nil)"
Parsby::ExpectationFailed: line 1:
(foo `(foo ,bar) 2.3 . . nil)
| * failure: char_in("([")
| * failure: list
| *| failure: symbol
| *|| failure: nil
| *||| failure: string
| *|||| failure: number
\\\||
| *| failure: atom
| *|| failure: abbrev
\\|
| * failure: sexp
V *| success: lit(".")
\-/ *|| success: sexp
\---------/ *||| success: sexp
\-/ *|||| success: sexp
V *||||| success: char_in("([")
\\\\\|
| * failure: list
| * failure: sexp
[1] https://github.com/jolmg/parsby#expectationfailed