endplay.parsers.dealer
Parser for Dealer scripts
Classes:
Exceptions:
|
Exception thrown when a parse expression doesn't match the input string |
- class endplay.parsers.dealer.DealerParser
Bases:
objectMethods:
_build_tree(parseResults)parse_expr(s)Parse an expression string into a syntax tree, for instance to compute the tree of a particular condition
parse_file(f)Parse a file into a syntax tree
parse_string(s)Parse a strimg into a syntax tree
- _build_tree(parseResults: ParseResults) Node
- parse_expr(s: str) Node
Parse an expression string into a syntax tree, for instance to compute the tree of a particular condition
- Parameters:
s – The condition string, e.g. “hcp(n) == 10 && shape(s) == 4432”
- Returns:
The root node of the syntax tree
- parse_file(f: TextIO) Node
Parse a file into a syntax tree
- Parameters:
f – A handle to a file or TextIO stream to be parsed
- Returns:
The root node of the syntax tree
- parse_string(s: str) Node
Parse a strimg into a syntax tree
- Parameters:
s – The string to parse
- Returns:
The root node of the syntax tree
- exception endplay.parsers.dealer.ParseException(pstr: str, loc: int = 0, msg: str | None = None, elem=None)
Bases:
ParseBaseExceptionException thrown when a parse expression doesn’t match the input string
Example:
integer = Word(nums).set_name("integer") try: integer.parse_string("ABC") except ParseException as pe: print(pe) print(f"column: {pe.column}")
prints:
Expected integer (at char 0), (line:1, col:1) column: 1
Attributes:
- args: tuple[str, int, str | None]
- loc: int
- msg: str
- parser_element: Any
- pstr: str