Parser implementation and supporting tools for the fault-text format.
The parser is hand rolled in order to easily accommodate for grammar violations, and as an attempt to display the format's simplicity. While the tokenizer enjoys an easily understood implementation, syntactic analysis (Parser.structure) is hacked and nearly unreadable demanding a replacement.
Types
- Tree
The element tree produced by Parser processing operations.
Engineering
The current implementation of the parser failed to achieve a desired level of simplicity. While it usually produces the desired result, the lack of implementation coherency should result in a rewrite.
Sequence
Mapping
builtins0
itertools0
string0
tools0
Tree0
Tree = tuple[str, Sequence['Tree'], Mapping]
parse_section_selector746%tuple[int, Sequence[str]]
parse_section_selector(string)
Given the contents of a section command or reference, return the depth and the section path specified within the given string.
Tokens0
Iterator that allows events to be replayed in order for them to be processed by the appropriate context.
Tokens__slots__0
__slots__ = ('iterators',)
Tokens__init__0
__init__(self, iterator)
Tokensreplay0
replay(self, *events)
Tokens__iter__0
__iter__(self)
Tokens__next__0
__next__(self)
Parser0
Configuration and state class for parsing kleptic text.
ParserProperties
- prefix
The designated bottom of the path. Used to allow subchapter tokens to be introduced as an extension of the root chapter.
Parser__init__0
__init__(self)
Create a new parser instance initializing the stack with the default_commands, and process_paragraph_line as the means to process lines.
Parsercommands0
Return the set of commands for the current working processor.
Parserreference381%
reference(self, string)
Split the string at the reference's boundary. The string is presumed to be the start of a reference with the indicator removed.
&<...>
&[Parameters(...)]
(int *)`3928+23192-203`
Parserprocessor20%
The current processing method, command set, and indentation level. Top of the stack.
Parserpush0
push(self, proc, il, command_set)
Parserpop0
pop(self)
Parseris_decoration0
is_decoration(self, stripped)
Determine if the line is a decoration.
Parseremphasis388%
emphasis(text)
Return a sequence of paragraph events noting the emphasis areas versus regular text.
Parserstyles0
styles(self, string, edge)
Identify the styles and references for the given string.
ParserstylesParameters
Parserstructure_paragraph_line0
structure_paragraph_line(self, line)
Structure the paragraph line revealing emphasis, references, and inline literals.
Parserprocess_paragraph_line190%
process_paragraph_line(self, lineno, code, il, line)
Process a paragraph line identifying inline literals, references and emphasis.
Parserprocess_literal_line0
process_literal_line(self, lineno, code, il, line)
Parserselect_section283%
select_section(self, lineno, code, il, line)
Parsercreate_admonition0
create_admonition(self, lineno, code, il, line)
Lines that begin with "!":
" ! NOTE:
" Paragraphs.
Parsercreate_block0
create_block(self, lineno, code, il, line)
Code block of literal lines.
Parsercreate_variable_item850%
create_variable_item(self, lineno, code, il, line)
Parsercreate_enumerated_item175%
create_enumerated_item(self, lineno, code, il, line)
Parsercreate_unordered_item175%
create_unordered_item(self, lineno, code, il, line)
Parserprocess3280%
process(self, lineno, code, il, line)
process(self, sections, root, element, indentation, iterator)
Parserdefault_commands0
default_commands = {
'[': select_section,
'!': create_admonition,
'/': create_variable_item,
'-': create_unordered_item,
'#': {
# Sequence Item
None: create_enumerated_item,
# Syntax Area / Block Quote
'!': create_block,
},
None: process,
}
Parsertokenize196%
tokenize(self, lines)
Tokenize the given source returning an iterator producing text events. source presumed to be is newline separated string.
Parserstructure0Tree
structure(self, lines)
Structure the given lines into an element tree.
Parserparse233%Tree
parse(self, source)
Parse the source source into a tree structure.