MCPcopy
hub / github.com/rocky/python-uncompyle6 / add_unique_rule

Method add_unique_rule

uncompyle6/parser.py:122–135  ·  view source on GitHub ↗

Add rule to grammar, but only if it hasn't been added previously opname and stack_count are used in the customize() semantic the actions to add the semantic action rule. Stack_count is used in custom opcodes like MAKE_FUNCTION to indicate how many arguments it has. Of

(self, rule, opname, arg_count, customize)

Source from the content-addressed store, hash-verified

120 return self.ast_first_offset(ast[0])
121
122 def add_unique_rule(self, rule, opname, arg_count, customize):
123 """Add rule to grammar, but only if it hasn't been added previously
124 opname and stack_count are used in the customize() semantic
125 the actions to add the semantic action rule. Stack_count is
126 used in custom opcodes like MAKE_FUNCTION to indicate how
127 many arguments it has. Often it is not used.
128 """
129 if rule not in self.new_rules:
130 # print("XXX ", rule) # debug
131 self.new_rules.add(rule)
132 self.addRule(rule, nop_func)
133 customize[opname] = arg_count
134 pass
135 return
136
137 def add_unique_rules(self, rules, customize):
138 """Add rules (a list of string) to grammar. Note that

Callers 13

add_unique_rulesMethod · 0.95
custom_classfunc_ruleMethod · 0.80
custom_classfunc_ruleMethod · 0.80
custom_classfunc_ruleMethod · 0.80
custom_classfunc_ruleMethod · 0.80

Calls 1

addMethod · 0.80

Tested by

no test coverage detected