InteractiveParser

InteractiveParser

InteractiveParser gives you advanced control over parsing and error handling when parsing with LALR.

For a simpler interface, see the ``on_error`` argument to ``Lark.parse()``.

Constructor

new InteractiveParser()

Source:

Methods

accepts()

Returns the set of possible tokens that will advance the parser into a new valid state.

Source:

accepts()

Returns the set of possible tokens that will advance the parser into a new valid state.

Source:

as_immutable()

Convert to an ImmutableInteractiveParser.

Source:

as_immutable()

Convert to an ImmutableInteractiveParser.

Source:

choices()

Returns a dictionary of token types, matched to their action in the parser.

    Only returns token types that are accepted by the current state.

    Updated by ``feed_token()``.
Source:

choices()

Returns a dictionary of token types, matched to their action in the parser.

    Only returns token types that are accepted by the current state.

    Updated by ``feed_token()``.
Source:

exhaust_lexer()

Try to feed the rest of the lexer state into the interactive parser.

    Note that this modifies the instance in place and does not feed an '$END' Token
Source:

exhaust_lexer()

Try to feed the rest of the lexer state into the interactive parser.

    Note that this modifies the instance in place and does not feed an '$END' Token
Source:

feed_eof()

Feed a '$END' Token. Borrows from 'last_token' if given.

Source:

feed_eof()

Feed a '$END' Token. Borrows from 'last_token' if given.

Source:

feed_token()

Feed the parser with a token, and advance it to the next state, as if it received it from the lexer.

    Note that ``token`` has to be an instance of ``Token``.
Source:

feed_token()

Feed the parser with a token, and advance it to the next state, as if it received it from the lexer.

    Note that ``token`` has to be an instance of ``Token``.
Source:

(generator) iter_parse()

Step through the different stages of the parse, by reading tokens from the lexer and feeding them to the parser, one per iteration.

    Returns an iterator of the tokens it encounters.

    When the parse is over, the resulting tree can be found in ``InteractiveParser.result``.
Source:

(generator) iter_parse()

Step through the different stages of the parse, by reading tokens from the lexer and feeding them to the parser, one per iteration.

    Returns an iterator of the tokens it encounters.

    When the parse is over, the resulting tree can be found in ``InteractiveParser.result``.
Source:

pretty()

Print the output of choices() in a way that's easier to read.

Source:

pretty()

Print the output of choices() in a way that's easier to read.

Source:

resume_parse()

Resume automated parsing from the current state.

Source:

resume_parse()

Resume automated parsing from the current state.

Source:

InteractiveParser

InteractiveParser gives you advanced control over parsing and error handling when parsing with LALR.

For a simpler interface, see the ``on_error`` argument to ``Lark.parse()``.

Constructor

new InteractiveParser()

Source:

Methods

accepts()

Returns the set of possible tokens that will advance the parser into a new valid state.

Source:

accepts()

Returns the set of possible tokens that will advance the parser into a new valid state.

Source:

as_immutable()

Convert to an ImmutableInteractiveParser.

Source:

as_immutable()

Convert to an ImmutableInteractiveParser.

Source:

choices()

Returns a dictionary of token types, matched to their action in the parser.

    Only returns token types that are accepted by the current state.

    Updated by ``feed_token()``.
Source:

choices()

Returns a dictionary of token types, matched to their action in the parser.

    Only returns token types that are accepted by the current state.

    Updated by ``feed_token()``.
Source:

exhaust_lexer()

Try to feed the rest of the lexer state into the interactive parser.

    Note that this modifies the instance in place and does not feed an '$END' Token
Source:

exhaust_lexer()

Try to feed the rest of the lexer state into the interactive parser.

    Note that this modifies the instance in place and does not feed an '$END' Token
Source:

feed_eof()

Feed a '$END' Token. Borrows from 'last_token' if given.

Source:

feed_eof()

Feed a '$END' Token. Borrows from 'last_token' if given.

Source:

feed_token()

Feed the parser with a token, and advance it to the next state, as if it received it from the lexer.

    Note that ``token`` has to be an instance of ``Token``.
Source:

feed_token()

Feed the parser with a token, and advance it to the next state, as if it received it from the lexer.

    Note that ``token`` has to be an instance of ``Token``.
Source:

(generator) iter_parse()

Step through the different stages of the parse, by reading tokens from the lexer and feeding them to the parser, one per iteration.

    Returns an iterator of the tokens it encounters.

    When the parse is over, the resulting tree can be found in ``InteractiveParser.result``.
Source:

(generator) iter_parse()

Step through the different stages of the parse, by reading tokens from the lexer and feeding them to the parser, one per iteration.

    Returns an iterator of the tokens it encounters.

    When the parse is over, the resulting tree can be found in ``InteractiveParser.result``.
Source:

pretty()

Print the output of choices() in a way that's easier to read.

Source:

pretty()

Print the output of choices() in a way that's easier to read.

Source:

resume_parse()

Resume automated parsing from the current state.

Source:

resume_parse()

Resume automated parsing from the current state.

Source: