endplay.parsers.dealer

Parser for Dealer scripts

Classes:

DealerParser()

Exceptions:

ParseException(pstr[, loc, msg, elem])

Exception thrown when a parse expression doesn't match the input string

class endplay.parsers.dealer.DealerParser

Bases: object

Methods:

_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: Optional[str] = None, elem=None)

Bases: ParseBaseException

Exception thrown when a parse expression doesn’t match the input string

Example:

try:
    Word(nums).set_name("integer").parse_string("ABC")
except ParseException as pe:
    print(pe)
    print("column: {}".format(pe.column))

prints:

Expected integer (at char 0), (line:1, col:1)
 column: 1