titus.prettypfa.Parser

class titus.prettypfa.Parser(wholeDocument)[source]

Bases: object

Parser for the “ply” package, specialized for PrettyPFA (whole document or expression).

Includes both the tokenizer and the parser.

__init__(wholeDocument)

Creates the Parser, but it is only ready to use after calling initialize.

Parameters:wholeDocument (bool) – if True, this parser expects a whole PFA document and parse returns a titus.pfaast.EngineConfig; otherwise, this parser expects a PFA expression and parse returns a titus.pfaast.Expression
initialize(lex, yacc)

Initialize the Parser by passing it the appropriate ply modules.

Parameters:
  • lex (Python module) – ply.lex after import ply.lex
  • yacc (Python module) – ply.yacc after import ply.yacc
Return type:

None

Returns:

nothing

parse(text, subs)

Parse the given text, returning a PFA abstract syntax tree.

Parameters:
  • text (string) – command line to parse
  • subs (dict of substitutions) – substitutions to apply to any strings in <<French quotes>>
Return type:

titus.pfaast.EngineConfig or titus.pfaast.Expression

Returns:

parsed text as an abstract syntax tree