Skip to content

Text blocks - #113

Open
laerreal wants to merge 12 commits into
masterfrom
txt_blocks
Open

Text blocks#113
laerreal wants to merge 12 commits into
masterfrom
txt_blocks

Conversation

@laerreal

@laerreal laerreal commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Introduces a parser for text.
The parser returns a tree of blocks.
A block is sequence of lines with same indent.
A line with new indent initiates a new block.
The new block is child of previous line.
There is a stack of indents.
The stack corresponds to a tree path from the root to a current block.
Repeated indent removes top items of the stack till same indent.
And corresponding block becomes current again and continues
gathering lines.

This is very similar to Python's code block structure.
Except, a child may has any unique indent.
Uniqueness is relative to its ancestors, not entire text.
I.e. blocks with same depth may have different indents.
And an indent may be a prefix of blocks with different depth.

This parser is base for short instruction semantic format (see devel branch).

Most of patches were not squashed for a historical reason.
They are to be considered one big patch.
Last patch adds misc/parse_blocks.py script.
It is just an example of the parser usage.

laerreal added 12 commits July 25, 2026 00:01
Signed-off-by: Efimov Vasily <real@ispras.ru>
Signed-off-by: Efimov Vasily <real@ispras.ru>
Signed-off-by: Efimov Vasily <real@ispras.ru>
Signed-off-by: Efimov Vasily <real@ispras.ru>
Signed-off-by: Efimov Vasily <real@ispras.ru>
Signed-off-by: Efimov Vasily <real@ispras.ru>
Signed-off-by: Efimov Vasily <real@ispras.ru>
Signed-off-by: Efimov Vasily <real@ispras.ru>
Signed-off-by: Efimov Vasily <real@ispras.ru>
Signed-off-by: Efimov Vasily <real@ispras.ru>
Signed-off-by: Efimov Vasily <real@ispras.ru>
Signed-off-by: Efimov Vasily <real@ispras.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants