diff options
author | Jordy Ruiz <56157703+jordr@users.noreply.github.com> | 2023-01-08 12:14:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-08 03:14:46 -0800 |
commit | 4e16079578377c215c7c387eaa2948252e54b108 (patch) | |
tree | fc6b11d9134db1731c88670067a9f974d672ec2d /tests/test_c_lexer.py | |
parent | 5382e3119b84eabcb2369f70978e1b803cbd185a (diff) | |
download | pycparser-4e16079578377c215c7c387eaa2948252e54b108.tar.gz |
Feature/add pragma support (#487)
* Support _Pragma, a C99 alternative to #pragma
See https://gcc.gnu.org/onlinedocs/cpp/Pragmas.html
* Test cases for _Pragma
* Add explanatory comment for _PRAGMA and PPPRAGMA
Diffstat (limited to 'tests/test_c_lexer.py')
-rw-r--r-- | tests/test_c_lexer.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/test_c_lexer.py b/tests/test_c_lexer.py index 03fd838..2975b80 100644 --- a/tests/test_c_lexer.py +++ b/tests/test_c_lexer.py @@ -357,6 +357,7 @@ class TestCLexerNoErrors(unittest.TestCase): #pragma "string" #pragma somestring="some_other_string" #pragma id 124124 and numbers 0235495 + _Pragma("something else") 59 ''' # Check that pragmas are tokenized, including trailing string @@ -389,9 +390,19 @@ class TestCLexerNoErrors(unittest.TestCase): 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) + t6a = self.clex.token() + t6l = self.clex.token() + t6b = self.clex.token() + t6r = self.clex.token() + self.assertEqual(t6a.type, '_PRAGMA') + self.assertEqual(t6l.type, 'LPAREN') + self.assertEqual(t6b.type, 'STRING_LITERAL') + self.assertEqual(t6b.value, '"something else"') + self.assertEqual(t6r.type, 'RPAREN') + + t7 = self.clex.token() + self.assertEqual(t7.type, 'INT_CONST_DEC') + self.assertEqual(t7.lineno, 13) |