diff options
Diffstat (limited to 'python/src/grammar.pxi')
| -rw-r--r-- | python/src/grammar.pxi | 12 | 
1 files changed, 12 insertions, 0 deletions
diff --git a/python/src/grammar.pxi b/python/src/grammar.pxi index 59266238..a9a5ea14 100644 --- a/python/src/grammar.pxi +++ b/python/src/grammar.pxi @@ -166,6 +166,18 @@ cdef class TRule:          return '%s ||| %s ||| %s ||| %s' % (self.lhs,                  _phrase(self.f), _phrase(self.e), scores) +cdef class MRule(TRule): +    def __init__(self, lhs, rhs, scores, a=None): +        cdef unsigned i = 1 +        e = [] +        for s in rhs: +            if isinstance(s, NT): +                e.append(NTRef(i)) +                i += 1 +            else: +                e.append(s) +        super(MRule, self).__init__(lhs, rhs, e, scores, a) +  cdef class Grammar:      cdef shared_ptr[grammar.Grammar]* grammar  | 
