Przeglądaj źródła

Fixed bug in lexer. Fixed calc example

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.1
Erez Shinan 7 lat temu
rodzic
commit
a438255193
2 zmienionych plików z 2 dodań i 2 usunięć
  1. +1
    -1
      examples/calc.py
  2. +1
    -1
      lark/lexer.py

+ 1
- 1
examples/calc.py Wyświetl plik

@@ -17,7 +17,7 @@ calc_grammar = """
| NAME -> var | NAME -> var
| "(" sum ")" | "(" sum ")"


NAME: /\w+/
NAME: /[a-zA-Z]\w*/
WS.ignore: /\s+/ WS.ignore: /\s+/
""" """




+ 1
- 1
lark/lexer.py Wyświetl plik

@@ -79,7 +79,7 @@ class Lexer(object):
try: try:
mre = re.compile(u'|'.join(u'(?P<%s>%s)'%t for t in tokens[:max_size])) mre = re.compile(u'|'.join(u'(?P<%s>%s)'%t for t in tokens[:max_size]))
except AssertionError: # Yes, this is what Python provides us.. :/ except AssertionError: # Yes, this is what Python provides us.. :/
return self._build_mres(tokens, max_size/2)
return self._build_mres(tokens, max_size//2)


mres.append((mre, {i:self.type_index[n] for n,i in mre.groupindex.items()} )) mres.append((mre, {i:self.type_index[n] for n,i in mre.groupindex.items()} ))
tokens = tokens[max_size:] tokens = tokens[max_size:]


Ładowanie…
Anuluj
Zapisz