buildingmotif.label_parsing.combinators#

Functions

as_identifier(parser)

If the parser matches, add a new Identifier token after every Constant token in the result.

Classes

abbreviations(*args, **kwargs)

Constructs a choice combinator of string matching based on a dictionary.

choice(*args, **kwargs)

Constructs a choice combinator of parsers.

constant(*args, **kwargs)

Matches a constant token.

extend_if_match(*args, **kwargs)

Adds the type to the token result.

many(*args, **kwargs)

Applies the given sequence parser repeatedly until it stops matching.

maybe(*args, **kwargs)

Applies the given parser, but does not fail if it does not match.

regex(*args, **kwargs)

Constructs a parser that matches a regular expression.

rest(*args, **kwargs)

Constructs a parser that matches the rest of the string.

sequence(*args, **kwargs)

Applies parsers in sequence.

string(*args, **kwargs)

Constructs a parser that matches a string.

substring_n(*args, **kwargs)

Constructs a parser that matches a substring of length n.

until(*args, **kwargs)

Constructs a parser that matches everything until the given parser matches.

class string(*args, **kwargs)[source]#

Constructs a parser that matches a string.

class rest(*args, **kwargs)[source]#

Constructs a parser that matches the rest of the string.

class substring_n(*args, **kwargs)[source]#

Constructs a parser that matches a substring of length n.

class regex(*args, **kwargs)[source]#

Constructs a parser that matches a regular expression.

class choice(*args, **kwargs)[source]#

Constructs a choice combinator of parsers.

class constant(*args, **kwargs)[source]#

Matches a constant token.

class abbreviations(*args, **kwargs)[source]#

Constructs a choice combinator of string matching based on a dictionary.

class sequence(*args, **kwargs)[source]#

Applies parsers in sequence. All parsers must match consecutively.

class many(*args, **kwargs)[source]#

Applies the given sequence parser repeatedly until it stops matching.

class maybe(*args, **kwargs)[source]#

Applies the given parser, but does not fail if it does not match.

class until(*args, **kwargs)[source]#

Constructs a parser that matches everything until the given parser matches. STarts with a string length of 1 and increments it until the parser matches.

class extend_if_match(*args, **kwargs)[source]#

Adds the type to the token result.

as_identifier(parser)[source]#

If the parser matches, add a new Identifier token after every Constant token in the result. The Identifier token has the same string value as the Constant token.