format6383%python.module
fault.text

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
import

Mapping
import

builtins0
import

itertools0
import

string0
import

tools0
import

Tree0
data

Tree = tuple[str, Sequence['Tree'], Mapping]

parse_section_selector746%
function
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
class

Iterator that allows events to be replayed in order for them to be processed by the appropriate context.

Tokens__slots__0
data

__slots__ = ('iterators',)

Tokens__init__0
method

__init__(self, iterator)

Tokensreplay0
method

replay(self, *events)

Tokens__iter__0
method

__iter__(self)

Tokens__next__0
method

__next__(self)

Parser0
class

Configuration and state class for parsing kleptic text.

ParserProperties

stack

The stack of line processing callbacks for the given context.

paragraph

A sequence representing the current working paragraph.

indentation

The current indentation level.

path

The current section path.

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
method

__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
property

Return the set of commands for the current working processor.

Parserreference381%
method

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%
property

The current processing method, command set, and indentation level. Top of the stack.

Parserpush0
method

push(self, proc, il, command_set)

Parserpop0
method

pop(self)

Parseris_decoration0
method

is_decoration(self, stripped)

Determine if the line is a decoration.

Parseremphasis388%
staticmethod

emphasis(text)

Return a sequence of paragraph events noting the emphasis areas versus regular text.

Parserstyles0
method

styles(self, string, edge)

Identify the styles and references for the given string.

ParserstylesParameters

self

Undocumented.

string

The text between a literal area.

edge

Whether the string was on the edge of a literal.

reference_indicator

Undocumented.

chain

Undocumented.

Parserstructure_paragraph_line0
method

structure_paragraph_line(self, line)

Structure the paragraph line revealing emphasis, references, and inline literals.

Parserprocess_paragraph_line190%
method

process_paragraph_line(self, lineno, code, il, line)

Process a paragraph line identifying inline literals, references and emphasis.

Parserprocess_literal_line0
method

process_literal_line(self, lineno, code, il, line)

Parserselect_section283%
method

select_section(self, lineno, code, il, line)

Parsercreate_admonition0
method

create_admonition(self, lineno, code, il, line)

Lines that begin with "!":

" ! NOTE:
	" Paragraphs.

Parsercreate_block0
method

create_block(self, lineno, code, il, line)

Code block of literal lines.

Parsercreate_variable_item850%
method

create_variable_item(self, lineno, code, il, line)

Parsercreate_enumerated_item175%
method

create_enumerated_item(self, lineno, code, il, line)

Parsercreate_unordered_item175%
method

create_unordered_item(self, lineno, code, il, line)

Parserprocess3280%
method

process(self, lineno, code, il, line)

process(self, sections, root, element, indentation, iterator)

Parserdefault_commands0
data

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%
method

tokenize(self, lines)

Tokenize the given source returning an iterator producing text events. source presumed to be is newline separated string.

Parserstructure0
method
Tree

structure(self, lines)

Structure the given lines into an element tree.

Parserparse233%
method
Tree

parse(self, source)

Parse the source source into a tree structure.