deepfold.runner package

Submodules

deepfold.runner.config_utils module

deepfold.runner.config_utils.load(path: str | bytes | PathLike)[source]

Load yaml-format configuration.

deepfold.runner.interpreter module

deepfold.runner.main module

deepfold.runner.parser module

class deepfold.runner.parser.Lexer(debug=False, **kwargs)[source]

Bases: object

states = (('iterable', 'inclusive'), ('string', 'exclusive'), ('escaped', 'exclusive'), ('graph', 'inclusive'), ('stoi', 'exclusive'))
t_ANY_error(t)[source]
t_BEGIN_ARRAY(t)[source]

x5B

t_BEGIN_OBJECT(t)[source]

x7B

t_DECIMAL_POINT = '\\x2E'
t_DIGITS = '[\\x30-\\x39]+'
t_E = '[\\x45\\x65]'
t_FALSE = '\\x66\\x61\\x6c\\x73\\x65'
t_ID(t)[source]
t_MINUS = '\\x2D'
t_NAME_SEPARATOR = '\\x3A'
t_NEWLINE(t)[source]

n+

t_NULL = '\\x6e\\x75\\x6c\\x6c'
t_PLUS = '\\x2B'
t_QUOTATION_MARK(t)[source]

x22

t_SEMICOLON = '\\x3B'
t_TRUE = '\\x74\\x72\\x75\\x65'
t_VALUE_SEPARATOR = '\\x2C'
t_ZERO = '\\x30'
t_escaped_BACKSPACE_CHAR(t)[source]

x62

t_escaped_CARRIAGE_RETURN_CHAR(t)[source]

x72

t_escaped_FORM_FEED_CHAR(t)[source]

x66

t_escaped_LINE_FEED_CHAR(t)[source]

x6E

t_escaped_QUOTATION_MARK(t)[source]

x22

t_escaped_REVERSE_SOLIDUS(t)[source]

x5C

t_escaped_SOLIDUS(t)[source]

x2F

t_escaped_TAB_CHAR(t)[source]

x74

t_escaped_UNICODE_HEX(t)[source]

x75[x30-x39,x41-x46,x61-x66]{4}

t_escaped_ignore = ''
t_graph_BEGIN_EDGE_LIST(t)[source]

x5Bx5B

t_graph_EDGE_SEP(t)[source]

x2D

t_graph_END_EDGE_LIST(t)[source]

x5Dx5D

t_graph_ID(t)[source]
t_graph_NEWLINE(t)[source]

n+

t_graph_VALUE_SEPARATOR = ','
t_graph_ignore = ' \t\r'
t_ignore = ' \t\r'
t_ignore_COMMENT(t)[source]

#.*

t_iterable_END_ARRAY(t)[source]

x5D

t_iterable_END_OBJECT(t)[source]

x7D

t_iterable_NEWLINE(t)[source]

n+

t_stoi_DIGITS(t)[source]
t_stoi_ID(t)[source]
t_stoi_NUM_SYM_SEP(t)[source]

x3A

t_stoi_STOI_SEP(t)[source]

x2F

t_stoi_ignore = ' \t\r'
t_string_ESCAPE(t)[source]

x5C

t_string_QUOTATION_MARK(t)[source]

x22

t_string_UNESCAPED(t)[source]

[x20-x21,x23-x5B,x5D-xFF]+

t_string_ignore = ''
tokenize(data, *args, **kwargs)[source]

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)[source]

Bases: object

p_array(p)[source]

array : begin_array values end_array

p_begin_array(p)[source]

begin_array : BEGIN_ARRAY

p_begin_dict(p)[source]

begin_dict : BEGIN_OBJECT

p_begin_edge(p)[source]

begin_edge : BEGIN_EDGE_LIST

p_char(p)[source]

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)[source]

char : ESCAPE UNICODE_HEX

p_chars(p)[source]
chars :
chars char
p_command(p)[source]
command :
model
entity
predict
graph
def
p_dict(p)[source]

dict : begin_dict members end_dict

p_edge(p)[source]

edge : id EDGE_SEP id

p_edge_list(p)[source]

edge_list : begin_edge edges end_edge

p_edges(p)[source]
edges :
edges edge value_separator
edges edge
p_end_array(p)[source]

end_array : END_ARRAY

p_end_dict(p)[source]

end_dict : END_OBJECT

p_end_edge(p)[source]

end_edge : END_EDGE_LIST

p_entity(p)[source]
entityENTITY id dict
ENTITY id string
p_error(p)[source]
p_exp(p)[source]

exp : E DIGITS

p_exp_negative(p)[source]

exp : E MINUS DIGITS

p_exp_positive(p)[source]

exp : E PLUS DIGITS

p_frac(p)[source]

frac : DECIMAL_POINT DIGITS

p_graph(p)[source]

graph : GRAPH id edge_list

p_id(p)[source]

id : ID

p_int_non_zero(p)[source]

int : DIGITS

p_int_zero(p)[source]

int : ZERO

p_integer(p)[source]

integer : int

p_integer_exp(p)[source]

integer : int exp

p_member(p)[source]

member : string NAME_SEPARATOR value

p_members(p)[source]
members :
members member value_separator
members member
p_model_definition(p)[source]

model : MODEL id object

p_number_float(p)[source]

float : int frac

p_number_float_exp(p)[source]

float : int frac exp

p_number_negative(p)[source]

number : MINUS integer | MINUS float

p_number_positive(p)[source]
numberinteger
float
p_object(p)[source]
object :
value
p_pred_opt(p)[source]
pred_optionPAIR string object
SAMPLE string object
IN object
p_pred_opts(p)[source]
pred_optionspred_option
pred_options pred_option
p_predict(p)[source]
predictPREDICT string STOI stoi_list USING id
PREDICT string STOI stoi_list USING id pred_options
PREDICT id STOI stoi_list USING id
PREDICT id STOI stoi_list USING id pred_options
p_script(p)[source]

script : statements

p_statement(p)[source]

statement : command

p_statements(p)[source]
statementsstatement
statements NEWLINE statement
statements SEMICOLON statement
p_stoi_entry(p)[source]

stoi_entry : id NUM_SYM_SEP integer

p_stoi_list(p)[source]
stoi_list :
stoi_list stoi_entry STOI_SEP
stoi_list stoi_entry
p_string(p)[source]

string : QUOTATION_MARK chars QUOTATION_MARK

p_value(p)[source]
valuedict
array
number
string
id
p_value_false(p)[source]

value : FALSE

p_value_null(p)[source]

value : NULL

p_value_seperator(p)[source]

value_separator : VALUE_SEPARATOR

p_value_true(p)[source]

value : TRUE

p_values(p)[source]
values :
values value value_separator
values value
p_variable_let(p)[source]

def : LET id object

parse(data, lexer=None, *args, **kwargs)[source]
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[source]

Module contents