summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2016-10-10 06:56:25 -0700
committerEli Bendersky <eliben@gmail.com>2016-10-10 06:56:25 -0700
commit6db253a4715846a407ce17f9da7df44db475ac84 (patch)
tree205aee5ab8420482c26b603d51a2d75e53fe0a76
parent991436042342c4b1ac52c0ea2d6c9d6874bd1927 (diff)
downloadpycparser-6db253a4715846a407ce17f9da7df44db475ac84.tar.gz
Adding test for exercising issue #61
The test shows that on a simple lexer level the issue doesn't manifest. It does, however, manifest if parsing a file.
-rw-r--r--pycparser/c_lexer.py2
-rw-r--r--tests/test_c_lexer.py17
2 files changed, 11 insertions, 8 deletions
diff --git a/pycparser/c_lexer.py b/pycparser/c_lexer.py
index 95e3971..b5a636c 100644
--- a/pycparser/c_lexer.py
+++ b/pycparser/c_lexer.py
@@ -102,7 +102,7 @@ class CLexer(object):
keywords = (
'_BOOL', '_COMPLEX', 'AUTO', 'BREAK', 'CASE', 'CHAR', 'CONST',
'CONTINUE', 'DEFAULT', 'DO', 'DOUBLE', 'ELSE', 'ENUM', 'EXTERN',
- 'FLOAT', 'FOR', 'GOTO', 'IF', 'INLINE', 'INT', 'LONG',
+ 'FLOAT', 'FOR', 'GOTO', 'IF', 'INLINE', 'INT', 'LONG',
'REGISTER', 'OFFSETOF',
'RESTRICT', 'RETURN', 'SHORT', 'SIGNED', 'SIZEOF', 'STATIC', 'STRUCT',
'SWITCH', 'TYPEDEF', 'UNION', 'UNSIGNED', 'VOID',
diff --git a/tests/test_c_lexer.py b/tests/test_c_lexer.py
index 6a15276..f965b24 100644
--- a/tests/test_c_lexer.py
+++ b/tests/test_c_lexer.py
@@ -146,6 +146,9 @@ class TestCLexerNoErrors(unittest.TestCase):
self.assertTokensTypes(
r'''"hello 'joe' wanna give it a \"go\"?"''',
['STRING_LITERAL'])
+ self.assertTokensTypes(
+ '"\123\123\123\123\123\123\123\123\123\123\123\123\123\123\123\123"',
+ ['STRING_LITERAL'])
def test_mess(self):
self.assertTokensTypes(
@@ -328,30 +331,30 @@ class TestCLexerNoErrors(unittest.TestCase):
t1 = self.clex.token()
self.assertEqual(t1.type, 'INT_CONST_DEC')
-
+
t2 = self.clex.token()
self.assertEqual(t2.type, 'PPPRAGMA')
-
+
t3 = self.clex.token()
self.assertEqual(t3.type, 'PPPRAGMA')
-
+
t4 = self.clex.token()
self.assertEqual(t4.type, 'PPPRAGMASTR')
self.assertEqual(t4.value, 'helo me')
-
+
for i in range(3):
t = self.clex.token()
-
+
t5 = self.clex.token()
self.assertEqual(t5.type, 'PPPRAGMASTR')
self.assertEqual(t5.value, 'omp parallel private(th_id)')
-
+
for i in range(5):
ta = self.clex.token()
self.assertEqual(ta.type, 'PPPRAGMA')
tb = self.clex.token()
self.assertEqual(tb.type, 'PPPRAGMASTR')
-
+
t6 = self.clex.token()
self.assertEqual(t6.type, 'INT_CONST_DEC')
self.assertEqual(t6.lineno, 12)