1 ''' @file examples/ini_file/ast_callbacks.py
2 @brief The AST call back functions for the ini file class.
9 sys.path.append(os.getcwd())
15 if(state == id.SEM_PRE):
16 name = utils.tuple_to_string(input[index:index + length])
17 if(name != data[
'current_section']):
18 data[
'current_section'] = name
19 if(
not data[
'sections'].get(name)):
20 data[
'sections'][name] = {}
23 def key_name(state, input, index, length, data):
24 if(state == id.SEM_PRE):
25 name = utils.tuple_to_string(input[index:index + length])
26 if(data[
'current_section']):
27 section = data[
'sections'][data[
'current_section']]
29 section = data[
'global']
30 key = section.get(name)
33 data[
'current_key'] = name
36 def value(state, input, index, length, data):
37 if(state == id.SEM_POST):
38 if(data[
'current_section']):
39 section = data[
'sections'][data[
'current_section']]
41 section = data[
'global']
42 section[data[
'current_key']].append(data[
'value'])
46 if(d >= 48
and d <= 57):
48 if(d >= 65
and d <= 72):
50 if(d >= 97
and d <= 104):
52 raise Exception(
'bad hex digit', d)
58 for i
in range(
len(input)):
63 if(input[i + 1] == 120):
68 elif(input[i + 1] == 117):
76 if(input[i + 1] == 116):
78 elif(input[i + 1] == 114):
80 elif(input[i + 1] == 110):
82 elif(input[i + 1] == 98):
85 value += chr(input[i + 1])
88 value += chr(input[i])
92 def d_value(state, input, index, length, data):
93 if(state == id.SEM_PRE):
94 data[
'value'] =
string_eval(input[index:index + length])
97 def s_value(state, input, index, length, data):
98 if(state == id.SEM_PRE):
99 data[
'value'] =
string_eval(input[index:index + length])
103 if(state == id.SEM_PRE):
104 data[
'value'] =
string_eval(input[index:index + length])
108 if(state == id.SEM_PRE):
109 value = utils.tuple_to_string(input[index:index + length])
110 data[
'value'] = int(value)
114 if(state == id.SEM_PRE):
119 if(state == id.SEM_PRE):
120 data[
'value'] =
False
124 if(state == id.SEM_PRE):
def d_value(state, input, index, length, data)
def key_name(state, input, index, length, data)
def null_value(state, input, index, length, data)
def true_value(state, input, index, length, data)
def number_value(state, input, index, length, data)
def string_value(state, input, index, length, data)
def section_name(state, input, index, length, data)
def s_value(state, input, index, length, data)
def false_value(state, input, index, length, data)
def value(state, input, index, length, data)