Skip to content

Commit f52cd79

Browse files
author
whitequark
committedMay 7, 2015
Implement true LL(k) lookahead.
1 parent f671204 commit f52cd79

File tree

4 files changed

+274
-170
lines changed

4 files changed

+274
-170
lines changed
 

‎pyparser/coverage/__init__.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from __future__ import absolute_import, division, print_function, unicode_literals
22
from .. import source, lexer
3-
import os
3+
import os, codecs
44

55
_buf = None
6-
with open(os.path.join(os.path.dirname(__file__), '..', 'parser.py')) as f:
6+
with codecs.open(os.path.join(os.path.dirname(__file__), '..', 'parser.py'),
7+
encoding='utf-8') as f:
78
_buf = source.Buffer(f.read(), f.name)
89

910
# Inject the grammar with locations of rules, because Python's
@@ -54,7 +55,8 @@ def instrument():
5455
if data is not None:
5556
rewriter.insert_before(token.loc, data)
5657

57-
with open(os.path.join(os.path.dirname(__file__), 'parser.py'), 'w') as f:
58+
with codecs.open(os.path.join(os.path.dirname(__file__), 'parser.py'), 'w',
59+
encoding='utf-8') as f:
5860
f.write(rewriter.rewrite().source)
5961

6062
# Produce an HTML report for test coverage of parser rules.
@@ -89,8 +91,8 @@ def report(parser, name='parser'):
8991
lambda x: r"<span id='{0}' class='line'>{1}</span>".format(*x),
9092
enumerate(content.split("\n"), 1)))
9193

92-
with open(os.path.join(os.path.dirname(__file__), '..', '..',
93-
'doc', 'coverage', name + '.html'), 'w') as f:
94+
with codecs.open(os.path.join(os.path.dirname(__file__), '..', '..',
95+
'doc', 'coverage', name + '.html'), 'w', encoding='utf-8') as f:
9496
f.write(r"""
9597
<!DOCTYPE html>
9698
<html>

‎pyparser/lexer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def __init__(self, source_buffer, version, interactive=False):
141141
( # 1
142142
(\\)? # ?2 line continuation
143143
([\n]|[\r][\n]|[\r]) # 3 newline
144-
| (\#.+) # 4 comment
144+
| (\#.*) # 4 comment
145145
| ( # 5 floating point or complex literal
146146
(?: [0-9]* \. [0-9]+
147147
| [0-9]+ \.?

0 commit comments

Comments
 (0)