1. Glue for Rust

Cheat Sheet

Parser Combinators

  1. Parser Combinators

  2. Branches

  3. Matches

  4. Repeaters

  5. Sequences

  6. Structures

  7. Testers

Branches

find_any((Parser, ...))

Run each of the provided parsers and return the first that is successful.

See the API documentation.

take_any((Parser, ...))

Run each of the provided parsers until one is successful and return the input it parsed.

See the API documentation.

if_then(/* predicate: */Parser, /* result: */Parser)

Run a parser, and if it is successful, run another parser and return its results.

See the API documentation.

if_not_then(/* predicate: */Parser, /* result: */Parser)

Run a parser, and if it is not successful, run another parser and return its results.

See the API documentation.

optional(Parser)

Run a parser and return Some on success or None on failure.

See the API documentation.

Matches

empty()

Matches nothing and always succeeds, useful as a placeholder in tuples.

See the API documentation.

eoi()

Matches the end of input.

See the API documentation.

is(Tester)

Match using a string or character literal, callback or implementation of Tester.

See Testers below or the API documentation.

isnt(Tester)

Match negatively using a string or character literal, callback or implementation of Tester.

See Testers below or the API documentation.

Repeaters

find(1.., Parser)

Run a parser a minimum number of times and up to a maximum and capture its results.

See the API documentation.

find_until(/* predicate: */Parser, /* results: */Parser)

Run a parser until a predicate is reached and capture its results.

See the API documentation.

take(1.., Parser)

Run a parser a minimum number of times and up to a maximum and capture the input it parsed.

See the API documentation.

take_until(/* predicate: */Parser, /* results: */Parser)

Run a parser until a predicate is reached and capture the input it parsed.

See the API documentation.

Sequences

find_all((Parser, ...))

Run each of the provided parsers and in the specified order and return all of the results.

See the API documentation.

take_all((Parser, ...))

Run each of the provided parsers and in the specified order and return all of the matched input.

See the API documentation.

Structures

delimited(/* prefix: */Parser, Parser, /* suffix: */Parser)

Parse a structure surrounded by balanced delimiters.

See the API documentation.

fields(/* result: */Parser, /* separator: */Parser)

Parse a structure that consists of multiple parsers separated by another.

See the API documentation.

separated(Parser, /* separator: */Parser, Parser)

Parse a structure that consists of two parsers separated by another.

See the API documentation.

Testers

any

Match any character.

one_of("abc") /* or */ "abc".chars()

Match the next character against one of these characters.

alphabetic

Match any alphabetic character.

alphanumeric

Match any alphanumeric character.

numeric

Match any numeric character.

digit

Match any decimal digit.

hex_digit

Match any hexidecimal digit.

whitespace

Match any whitespace character.