raesl.compile.parser
#
Parsing the Elephant Specification Language.
Module Contents#
Classes#
Class managing parsing of a line in ESL. |
Functions#
|
Parse a text-line in ESL. |
|
Parse an ESL lexer, storing collected information in the builder. |
|
Parse an ESL specification, storing collected information in the builder. |
|
Collect the set reachable states from 'spec_state' without taking only 'epsilon' |
- class raesl.compile.parser.LineMachineStepper(machine: raesl.compile.machine_files.builder.ProcessingStateMachine, lexer: raesl.compile.scanner.Lexer, dest_loc: raesl.compile.state_machine.Location)#
Class managing parsing of a line in ESL.
- Parameters:
machine – Line matching machine to use for recognizing the line.
lexer – Lexer to use in the matching process.
current_loc – Current location in the line machine.
tags – Relevant data extracted from the text line during the parsing process.
matched_tokens – Tokens used for matching the line thus far.
dest_loc – New specification location if a match was found.
- try_step() bool #
Try to match the next token.
- Returns:
Whether progress was made.
- is_accepting() bool #
Is the machine in an accepting location?
- get_accept_name() str #
Get the acceptance name associated with the accepting location.
- Returns:
Name of the accepted ‘rule’.
- raesl.compile.parser.parse_line(spec_state: raesl.compile.state_machine.Location, lexer: raesl.compile.scanner.Lexer, builder: raesl.compile.typechecking.ast_builder.AstBuilder, diag_store: raesl.compile.diagnostics.DiagnosticStore) Tuple[raesl.compile.state_machine.Location | None, raesl.compile.scanner.Lexer | None] #
Parse a text-line in ESL.
For debugging line selection, set scanner.PARSER_DEBUG to True, which enables printing debug information to the std output. For best results, use a small input specification, output is quite verbose.
- Parameters:
spec_state – Location in the ESL language state machine.
lexer – Lexer pointing at the start of the next line to match.
builder – Class storing extracted parse data.
diag_store – Storage for reported diagnostics.
- Returns:
Next state in the ESL state machine unless successfully finished, next lexer to use if next step can be performed.
- raesl.compile.parser.parse_lexer(lexer: raesl.compile.scanner.Lexer, diag_store: raesl.compile.diagnostics.DiagnosticStore | None, builder: raesl.compile.typechecking.ast_builder.AstBuilder | None, doc_comments: List[raesl.compile.scanner.Token] | None) Tuple[raesl.compile.diagnostics.DiagnosticStore, raesl.compile.typechecking.ast_builder.AstBuilder, List[raesl.compile.scanner.Token], bool] #
Parse an ESL lexer, storing collected information in the builder.
- Parameters:
lexer – Lexer pointing at the start of the specification text.
diag_store – Diagnostic store if one already has been created.
builder – Builder if one already has been created.
doc_comments – Doc comments if any have been found yet.
- Returns:
Diagnostic store instance. Builder instance. Found doc comments. Whether there has been an error.
- raesl.compile.parser.parse_spec(lexers: Iterable[raesl.compile.scanner.Lexer], diag_store: raesl.compile.diagnostics.DiagnosticStore | None = None) Tuple[raesl.compile.diagnostics.DiagnosticStore, raesl.compile.ast.specification.Specification | None] #
Parse an ESL specification, storing collected information in the builder.
- Parameters:
lexers – Lexers pointing at the start of their respective texts (e.g. per-file).
- Returns:
The found diagnostics, and if successful, the type-checked output.
- raesl.compile.parser.collect_locations(spec_state: raesl.compile.state_machine.Location) List[raesl.compile.state_machine.Location] #
Collect the set reachable states from ‘spec_state’ without taking only ‘epsilon’ transitions.