speechmarkdown.parser#

Classes#

ASTNode

Node for the Abstract Syntax Tree generated by the syntax parser.

SpeechMarkdownParser

Parser for Speech Markdown syntax utilizing pyparsing.

Functions#

ast(→ pyparsing.ParserElement)

Wrap a parser element to produce an ASTNode as its parsed action result.

parenthesized(→ pyparsing.ParserElement)

Module Contents#

class speechmarkdown.parser.ASTNode(name: str, allText: str, children: List[Any])[source]#

Node for the Abstract Syntax Tree generated by the syntax parser.

name[source]#
allText[source]#
children[source]#
__repr__() str[source]#
to_dict() Dict[str, Any][source]#

Convert the AST node into a dictionary representation.

Returns:

Basic dictionary tree.

Return type:

Dict[str, Any]

speechmarkdown.parser.ast(name: str, expr: pyparsing.ParserElement) pyparsing.ParserElement[source]#

Wrap a parser element to produce an ASTNode as its parsed action result.

Parameters:
  • name (str) – Name parameter for the ASTNode.

  • expr (pp.ParserElement) – The PyParsing expression to apply.

Returns:

The wrapped sequence.

Return type:

pp.ParserElement

speechmarkdown.parser.parenthesized(rule: pyparsing.ParserElement) pyparsing.ParserElement[source]#
class speechmarkdown.parser.SpeechMarkdownParser[source]#

Parser for Speech Markdown syntax utilizing pyparsing.

grammar[source]#
parse(text: str) ASTNode[source]#

Parse raw Speech Markdown text to an AST.

Parameters:

text (str) – Speech Markdown string.

Returns:

The root of the generated syntax tree.

Return type:

ASTNode

Raises:

ValueError – If an unexpected syntax element fails during parse limit logic.