Пример #1
0
def parse2(text):
  class Rules:
    rootSymbol = 'A'
    def A(self, start):
      m =  rules.B(start)
      return m and x(p.cur()) and m+'x' or m or a(start)
      #return m.set(rules.B(start)) and x(p.cur()) and m+'x' or m or a(start)
    def B(self, start): return memoA(start) or b(start)
  rules = Rules()
  initialize(rules)
  addRecursiveCircles(rules, ['A', 'B'])
  computeLeftRecursives(rules)
  return parse(text,  rules)
Пример #2
0
def parse1(text):
  class Rules:
    rootSymbol = 'A'
    parentToChildren = {}
    def A(self, start):
      m = memoA(start)
      return m and x(p.cur()) and m+'x' or m or a(start)
      #return let(m, memoA(start)) and x(p.cur()) and m+'x' or m or a(start)
  rules = Rules()
  initialize(rules)
  addRecursiveCircles(rules, ['A'])
  computeLeftRecursives(rules)
  return parse(text, rules)