deepfold.runner package¶
Submodules¶
deepfold.runner.config_utils module¶
- deepfold.runner.config_utils.load(path: str | bytes | PathLike)¶
Load yaml-format configuration.
deepfold.runner.interpreter module¶
deepfold.runner.main module¶
deepfold.runner.parser module¶
- class deepfold.runner.parser.Lexer(debug=False, **kwargs)¶
Bases:
object
- states = (('iterable', 'inclusive'), ('string', 'exclusive'), ('escaped', 'exclusive'), ('graph', 'inclusive'), ('stoi', 'exclusive'))¶
- t_ANY_error(t)¶
- t_BEGIN_ARRAY(t)¶
x5B
- t_BEGIN_OBJECT(t)¶
x7B
- t_DECIMAL_POINT = '\\x2E'¶
- t_DIGITS = '[\\x30-\\x39]+'¶
- t_E = '[\\x45\\x65]'¶
- t_FALSE = '\\x66\\x61\\x6c\\x73\\x65'¶
- t_ID(t)¶
- t_MINUS = '\\x2D'¶
- t_NAME_SEPARATOR = '\\x3A'¶
- t_NEWLINE(t)¶
n+
- t_NULL = '\\x6e\\x75\\x6c\\x6c'¶
- t_PLUS = '\\x2B'¶
- t_QUOTATION_MARK(t)¶
x22
- t_SEMICOLON = '\\x3B'¶
- t_TRUE = '\\x74\\x72\\x75\\x65'¶
- t_VALUE_SEPARATOR = '\\x2C'¶
- t_ZERO = '\\x30'¶
- t_escaped_BACKSPACE_CHAR(t)¶
x62
- t_escaped_CARRIAGE_RETURN_CHAR(t)¶
x72
- t_escaped_FORM_FEED_CHAR(t)¶
x66
- t_escaped_LINE_FEED_CHAR(t)¶
x6E
- t_escaped_QUOTATION_MARK(t)¶
x22
- t_escaped_REVERSE_SOLIDUS(t)¶
x5C
- t_escaped_SOLIDUS(t)¶
x2F
- t_escaped_TAB_CHAR(t)¶
x74
- t_escaped_UNICODE_HEX(t)¶
x75[x30-x39,x41-x46,x61-x66]{4}
- t_escaped_ignore = ''¶
- t_graph_BEGIN_EDGE_LIST(t)¶
x5Bx5B
- t_graph_EDGE_SEP(t)¶
x2D
- t_graph_END_EDGE_LIST(t)¶
x5Dx5D
- t_graph_ID(t)¶
- t_graph_NEWLINE(t)¶
n+
- t_graph_VALUE_SEPARATOR = ','¶
- t_graph_ignore = ' \t\r'¶
- t_ignore = ' \t\r'¶
- t_ignore_COMMENT(t)¶
#.*
- t_iterable_END_ARRAY(t)¶
x5D
- t_iterable_END_OBJECT(t)¶
x7D
- t_iterable_NEWLINE(t)¶
n+
- t_stoi_DIGITS(t)¶
- t_stoi_ID(t)¶
- t_stoi_NUM_SYM_SEP(t)¶
x3A
- t_stoi_STOI_SEP(t)¶
x2F
- t_stoi_ignore = ' \t\r'¶
- t_string_ESCAPE(t)¶
x5C
- t_string_QUOTATION_MARK(t)¶
x22
- t_string_UNESCAPED(t)¶
[x20-x21,x23-x5B,x5D-xFF]+
- t_string_ignore = ''¶
- tokenize(data, *args, **kwargs)¶
Invoke the lexer on an input string an return the list of tokens.
This is relatively inefficient and should only be used for testing/debugging as it slurps up all tokens into one list.
- Parameters:
data – The input to be tokenized.
- Returns:
A list of LexTokens
- tokens = ['BEGIN_ARRAY', 'BEGIN_OBJECT', 'END_ARRAY', 'END_OBJECT', 'NAME_SEPARATOR', 'VALUE_SEPARATOR', 'QUOTATION_MARK', 'FALSE', 'TRUE', 'NULL', 'DECIMAL_POINT', 'DIGITS', 'E', 'MINUS', 'PLUS', 'ZERO', 'UNESCAPED', 'ESCAPE', 'REVERSE_SOLIDUS', 'SOLIDUS', 'BACKSPACE_CHAR', 'FORM_FEED_CHAR', 'LINE_FEED_CHAR', 'CARRIAGE_RETURN_CHAR', 'TAB_CHAR', 'UNICODE_HEX', 'BEGIN_EDGE_LIST', 'END_EDGE_LIST', 'EDGE_SEP', 'STOI_SEP', 'NUM_SYM_SEP', 'ID', 'SEMICOLON', 'NEWLINE', 'MODEL', 'ENTITY', 'PREDICT', 'USING', 'STOI', 'PAIR', 'SAMPLE', 'GRAPH', 'LET', 'IN']¶
- class deepfold.runner.parser.Parser(lexer=None, debug=False, **kwargs)¶
Bases:
object
- p_array(p)¶
array : begin_array values end_array
- p_begin_array(p)¶
begin_array : BEGIN_ARRAY
- p_begin_dict(p)¶
begin_dict : BEGIN_OBJECT
- p_begin_edge(p)¶
begin_edge : BEGIN_EDGE_LIST
- p_char(p)¶
char : UNESCAPED | ESCAPE QUOTATION_MARK | ESCAPE REVERSE_SOLIDUS | ESCAPE SOLIDUS | ESCAPE BACKSPACE_CHAR | ESCAPE FORM_FEED_CHAR | ESCAPE LINE_FEED_CHAR | ESCAPE CARRIAGE_RETURN_CHAR | ESCAPE TAB_CHAR
- p_char_unicode_hex(p)¶
char : ESCAPE UNICODE_HEX
- p_chars(p)¶
- chars :
- chars char
- p_command(p)¶
- command :
- modelentitypredictgraphdef
- p_dict(p)¶
dict : begin_dict members end_dict
- p_edge(p)¶
edge : id EDGE_SEP id
- p_edge_list(p)¶
edge_list : begin_edge edges end_edge
- p_edges(p)¶
- edges :
- edges edge value_separatoredges edge
- p_end_array(p)¶
end_array : END_ARRAY
- p_end_dict(p)¶
end_dict : END_OBJECT
- p_end_edge(p)¶
end_edge : END_EDGE_LIST
- p_entity(p)¶
- entityENTITY id dict
- ENTITY id string
- p_error(p)¶
- p_exp(p)¶
exp : E DIGITS
- p_exp_negative(p)¶
exp : E MINUS DIGITS
- p_exp_positive(p)¶
exp : E PLUS DIGITS
- p_frac(p)¶
frac : DECIMAL_POINT DIGITS
- p_graph(p)¶
graph : GRAPH id edge_list
- p_id(p)¶
id : ID
- p_int_non_zero(p)¶
int : DIGITS
- p_int_zero(p)¶
int : ZERO
- p_integer(p)¶
integer : int
- p_integer_exp(p)¶
integer : int exp
- p_member(p)¶
member : string NAME_SEPARATOR value
- p_members(p)¶
- members :
- members member value_separatormembers member
- p_model_definition(p)¶
model : MODEL id object
- p_number_float(p)¶
float : int frac
- p_number_float_exp(p)¶
float : int frac exp
- p_number_negative(p)¶
number : MINUS integer | MINUS float
- p_number_positive(p)¶
- numberinteger
- float
- p_object(p)¶
- object :
- value
- p_pred_opt(p)¶
- pred_optionPAIR string object
- SAMPLE string objectIN object
- p_pred_opts(p)¶
- pred_optionspred_option
- pred_options pred_option
- p_predict(p)¶
- predictPREDICT string STOI stoi_list USING id
- PREDICT string STOI stoi_list USING id pred_optionsPREDICT id STOI stoi_list USING idPREDICT id STOI stoi_list USING id pred_options
- p_script(p)¶
script : statements
- p_statement(p)¶
statement : command
- p_statements(p)¶
- statementsstatement
- statements NEWLINE statementstatements SEMICOLON statement
- p_stoi_entry(p)¶
stoi_entry : id NUM_SYM_SEP integer
- p_stoi_list(p)¶
- stoi_list :
- stoi_list stoi_entry STOI_SEPstoi_list stoi_entry
- p_string(p)¶
string : QUOTATION_MARK chars QUOTATION_MARK
- p_value(p)¶
- valuedict
- arraynumberstringid
- p_value_false(p)¶
value : FALSE
- p_value_null(p)¶
value : NULL
- p_value_seperator(p)¶
value_separator : VALUE_SEPARATOR
- p_value_true(p)¶
value : TRUE
- p_values(p)¶
- values :
- values value value_separatorvalues value
- p_variable_let(p)¶
def : LET id object
- parse(data, lexer=None, *args, **kwargs)¶
- tokens = ['BEGIN_ARRAY', 'BEGIN_OBJECT', 'END_ARRAY', 'END_OBJECT', 'NAME_SEPARATOR', 'VALUE_SEPARATOR', 'QUOTATION_MARK', 'FALSE', 'TRUE', 'NULL', 'DECIMAL_POINT', 'DIGITS', 'E', 'MINUS', 'PLUS', 'ZERO', 'UNESCAPED', 'ESCAPE', 'REVERSE_SOLIDUS', 'SOLIDUS', 'BACKSPACE_CHAR', 'FORM_FEED_CHAR', 'LINE_FEED_CHAR', 'CARRIAGE_RETURN_CHAR', 'TAB_CHAR', 'UNICODE_HEX', 'BEGIN_EDGE_LIST', 'END_EDGE_LIST', 'EDGE_SEP', 'STOI_SEP', 'NUM_SYM_SEP', 'ID', 'SEMICOLON', 'NEWLINE', 'MODEL', 'ENTITY', 'PREDICT', 'USING', 'STOI', 'PAIR', 'SAMPLE', 'GRAPH', 'LET', 'IN']¶
deepfold.runner.utils module¶
- deepfold.runner.utils.safe_filename(name: str) str ¶