Skip to content

dzchoi/Parser-Combinator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

A Parser Combinator in C++

Parsers provided in this library

  • character parsers:

    • chr('c')
    • any_chr() - /./
    • one_of("abc") - /[abc]/
    • none_of("abc") - /[^abc]/
    • blank() - space or tab
    • letter()
    • alphanum()
    • digit()
  • void parsers:

    • eof()
    • skip(p) - generic void parser
    • skip('c')
    • skip("abc")
    • blanks() - optionally consume blanks
  • string parsers:

    • +p - convert a character parser into a string parser
    • p + q - concatenate string parsers
  • parser combinators:

    • p >> f - parse p, and if p succeeds apply T f(U) to the result U from p; p can be a void parser (and f is of type T f())
    • p >> f - for custom parsering function f of type T f(istream &, U) or T f(istream &)
    • many<C>(p) - parse /p*/ and return the collection of results from p's in a container of type C
    • many(p) - string parser when p is a character parser
    • many(p) - void parser when p is a void parser
    • many1(p, f) - parse /p+/ and return the collection of results from p's using T f(T, T) such as foldl1() in Haskell
    • many1(p) - void parser when p is a void parser
    • p > q - return result from q if p and q are parsed successfully; p can be a void parser; return result from p if q is a void parser
    • sep_by<C>(p, q) - parse /(p (q p)*)?/ and return the collection of results from p's in a container of type C
    • sep_by(p, q) - string parser when p is a character parser
    • sep_by(p, q) - void parser when p is a void parser
    • sep_by1(p, q, f) - parse /p (q p)*/ and return the collection of results from p's using T f(T, T)
    • sep_by1(p, q) - void parser when p is a void parser
    • p | q - parse p first, and if p fails and consumes nothing parse q
    • try_(p) - parse p, and backtrack the istream if "error failure" (but istream remains marked as failure)

About

A Parser Combinator in C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages