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)
| 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 |
no test coverage detected