Ejemplo n.º 1
0
 def rule_set(self):
     rs = RuleSet()
     rs.add_rule('L', self.prod)
     if self.prod is 'l33t':
         for c, d in zip(self.l, self.r):
             rs.add_rule('L_%s' % c, d)
     return rs
Ejemplo n.º 2
0
 def rule_set(self):
     rs = RuleSet()
     rs.add_rule('L', self.prod)
     if self.prod is 'l33t':
         for c,d in zip(self.l, self.r):
             rs.add_rule('L_%s'%c,d)
     return rs
Ejemplo n.º 3
0
 def rule_set(self):
     rs = RuleSet()
     if isinstance(self, NonT):
         rs.add_rule('G', self.sym)
     if isinstance(self.prod, basestring):
         rs.add_rule(self.sym, self.prod)
     elif isinstance(self.prod, list):
         for p in self.prod:
             rs.update_set(p.rule_set())
     else:
         return self.prod.rule_set()
     return rs
Ejemplo n.º 4
0
 def rule_set(self):  # 添加规则
     rs = RuleSet()
     if isinstance(self, NonT):  # 基础规则  即没有任何规则
         rs.add_rule('G', self.sym)
     if isinstance(self.prod, str):
         rs.add_rule(self.sym, self.prod)
     elif isinstance(self.prod, list):
         for p in self.prod:
             rs.update_set(p.rule_set())
     else:
         return self.prod.rule_set()
     return rs
Ejemplo n.º 5
0
 def rule_set(self):
     rs = RuleSet()
     if isinstance(self, NonT):
         rs.add_rule('G', self.sym)
     if isinstance(self.prod, basestring):
         rs.add_rule(self.sym, self.prod)
     elif isinstance(self.prod, list):
         for p in self.prod:
             rs.update_set(p.rule_set())
     else:
         return self.prod.rule_set()
     return rs
Ejemplo n.º 6
0
 def rule_set(self):
     rs = RuleSet()
     rs.add_rule(self.sym, self.prod)
     rs.update_set(self.L.rule_set())
     return rs
Ejemplo n.º 7
0
 def rule_set(self, word):
     rs = RuleSet()
     pt = self.l_parse_tree(word)
     for p in pt.tree:
         rs.add_rule(*p)
     return rs
Ejemplo n.º 8
0
 def rule_set(self, word):
     rs = RuleSet()
     pt = self.l_parse_tree(word)
     for p in pt.tree:
         rs.add_rule(*p)
     return rs
Ejemplo n.º 9
0
 def rule_set(self):
     rs = RuleSet()
     rs.add_rule(self.sym, self.prod)
     rs.update_set(self.L.rule_set())
     return rs