Skip to content
Permalink
Browse files

learn to count newlines correctly in multiline comments

  • Loading branch information
alex committed Jun 23, 2013
1 parent f16470a commit 497953f0cbeacc14c09e0a9bf69c7de89458da1a
Showing with 13 additions and 0 deletions.
  1. +12 −0 tests/test_parser.py
  2. +1 −0 topaz/lexer.py
@@ -2751,3 +2751,15 @@ def test_multiline_comments(self, space):

with self.raises(space, 'SyntaxError'):
space.parse("=begin\nbar\n=foo")

def test_multiline_comments_lineno(self, space):
r = space.parse("""
=begin
some
lines
=end
1 + 1
""")
assert r == ast.Main(ast.Block([
ast.Statement(ast.Send(ast.ConstantInt(1), "+", [ast.ConstantInt(1)], None, 6))
]))
@@ -376,6 +376,7 @@ def multiline_comment(self, ch):
if ch == self.EOF:
self.error("embedded document meets end of file")
if ch in "\r\n":
self.newline(ch)
if (self.read() == "=" and
self.read() == "e" and
self.read() == "n" and

0 comments on commit 497953f

Please sign in to comment.
You can’t perform that action at this time.