hydra.parsing module

Parser combinator types for text parsing.

class hydra.parsing.ParseError(message: Annotated[str, 'An error message'], remainder: Annotated[Sequence[int], 'The remaining input (as codepoints) at the point of failure'])

Bases: object

An error which occurred while parsing.

class Builder(_message: 'str' = None, _remainder: 'Sequence[int]' = None)

Bases: object

build()
message(message)
remainder(remainder)
MESSAGE = Name(value='message')
REMAINDER = Name(value='remainder')
TYPE_ = Name(value='hydra.parsing.ParseError')
static builder()
message: Annotated[str, 'An error message']
remainder: Annotated[Sequence[int], 'The remaining input (as codepoints) at the point of failure']
with_message(message)
with_remainder(remainder)
class hydra.parsing.ParseResult

Bases: object

ParseResultSuccess[A] | ParseResultFailure

FAILURE = Name(value='failure')
SUCCESS = Name(value='success')
TYPE_ = Name(value='hydra.parsing.ParseResult')
class hydra.parsing.ParseResultFailure(value: T)

Bases: Node[ParseError]

A failed parse, with an error message and the remaining input

class hydra.parsing.ParseResultSuccess(value: T)

Bases: Node[ParseSuccess[A]]

A successful parse, with a value and the remaining unparsed input

class hydra.parsing.ParseSuccess(value: Annotated[A, 'The parsed value'], remainder: Annotated[Sequence[int], 'The remaining unparsed input, as codepoints. Represented as a list rather than a string'])

Bases: Generic[A]

A successful parse result.

class Builder(_value: 'A' = None, _remainder: 'Sequence[int]' = None)

Bases: Generic[A]

build()
remainder(remainder)
value(value)
REMAINDER = Name(value='remainder')
TYPE_ = Name(value='hydra.parsing.ParseSuccess')
VALUE = Name(value='value')
static builder()
remainder: Annotated[Sequence[int], 'The remaining unparsed input, as codepoints. Represented as a list rather than a string']
value: Annotated[A, 'The parsed value']
with_remainder(remainder)
with_value(value)
class hydra.parsing.Parser(value: T)

Bases: Node[Callable[[Sequence[int]], ParseResult[A]]], Generic[A]

A parser which consumes characters from a codepoint list and produces a value. The input is a list, rather than a string, so that consuming one character is a constant-time operation rather than a linear-time string copy.

TYPE_ = Name(value='hydra.parsing.Parser')