Esempio n. 1
0
def parse_body(s, nont_reader=lambda x: x, elem_reader=lambda x: x):
    body = rule_body()
    s = s.split()
    for e in s:
        if e[0] == '@':
            code = nont_reader(int(e[1:]))
            body.append(True, code)
        else:
            code = elem_reader(e)
            body.append(False, code)
    return body
Esempio n. 2
0
 def get_G(self):
     G = self.ctx.grammar
     G.clear()
     for path in self.paths:
         p = path.get_path()
         body = rule_body(self.ctx.alphabet)
         for s in p:
             if s < 0:
                 body.append(True, -s)
             else:
                 body.append(False, s)
         G.add_body(body)
     G.set_S(0)
     return G