Commit 632a5b76 authored by di68kap's avatar di68kap

- parser.py: faster Regex: m.group(0) instead of text[:end]

parent bff61c50
......@@ -1150,7 +1150,7 @@ class RegExp(Parser):
match = text.match(self.regexp)
if match:
end = text.index(match.end())
return Node(self, text[:end], True), text[end:]
return Node(self, match.group(0), True), text[end:]
return None, text
def __repr__(self):
......
......@@ -52,6 +52,8 @@ def fail_on_error(src, result):
def tst_func():
with toolkit.logging(False):
if not os.path.exists('REPORT'):
os.mkdir('REPORT')
files = os.listdir('testdata')
files.sort()
for file in files:
......@@ -60,10 +62,10 @@ def tst_func():
doc = f.read()
print('\n\nParsing document: "%s"\n' % file)
result = parser(doc)
with open('results/' + file[:-4]+'.cst', 'w', encoding='utf-8') as f:
with open('REPORT/' + file[:-4]+'.cst', 'w', encoding='utf-8') as f:
f.write(result.as_sxpr(compact=False))
transformer(result)
with open('results/' + file[:-4]+'.ast', 'w', encoding='utf-8') as f:
with open('REPORT/' + file[:-4]+'.ast', 'w', encoding='utf-8') as f:
f.write(result.as_sxpr(compact=False))
parser.log_parsing_history__()
fail_on_error(doc, result)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment