dollar_lambda.parsers#

Defines parsing functions and the Parser class that they instantiate.

Functions

apply(f, description)

A shortcut for item(description).apply(f).

argument(dest[, nesting, help, type])

Parses a single word and binds it to dest.

binary_usage(a, op, b[, add_brackets])

Utility for generating usage strings for binary operators.

defaults(**kwargs)

Useful for assigning default values to arguments.

flag(dest[, default, help, nesting, regex, ...])

Binds a boolean value to a variable.

item(name[, usage_name])

Parses a single word and binds it to dest.

matches(s[, peak, regex])

Checks if the next word is s.

nonpositional(*parsers[, max, repeated])

nonpositional() takes a sequence of parsers as arguments and attempts all permutations of them, returning the first permutations that is successful:

option(dest[, choices, default, flag, help, ...])

Parses two words, binding the second to the first.

peak(name[, description])

Bind the next word to a variable but keep that word in the input (so that other parsers can still see it).

sat(predicate, on_fail, name)

A wrapper around Parser.sat() that uses item() to parse the argument and just applies predicate to the value output by item().

sat_peak(predicate, on_fail, name)

A convenience function that peaks at the next word using peak() and then checks if it satisfies the predicate.

Classes

Parse(parsed, unparsed)

A Parse is the output of parsing.

Parser(f, usage, helps[, nonoptional])

Main class powering the argument parser.

Exceptions

SuccessError(usage, input, output)