Explorar el Código

Allow using | on terminals with flags, as long as their flags match

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.1
Erez Shinan hace 6 años
padre
commit
59825260f6
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. +3
    -2
      lark/load_grammar.py

+ 3
- 2
lark/load_grammar.py Ver fichero

@@ -368,8 +368,9 @@ class TokenTreeToPattern(Transformer):
def expansions(self, exps):
if len(exps) == 1:
return exps[0]
assert all(not i.flags for i in exps)
return PatternRE('(?:%s)' % ('|'.join(i.to_regexp() for i in exps)))
if len({i.flags for i in exps}) > 1:
raise GrammarError("Lark doesn't support joining tokens with conflicting flags!")
return PatternRE('(?:%s)' % ('|'.join(i.to_regexp() for i in exps)), exps[0].flags)

def expr(self, args):
inner, op = args


Cargando…
Cancelar
Guardar