summaryrefslogtreecommitdiff
path: root/pycparser
diff options
context:
space:
mode:
Diffstat (limited to 'pycparser')
-rw-r--r--pycparser/c_lexer.py1
-rw-r--r--pycparser/c_parser.py10
2 files changed, 10 insertions, 1 deletions
diff --git a/pycparser/c_lexer.py b/pycparser/c_lexer.py
index d68d8eb..22c64bc 100644
--- a/pycparser/c_lexer.py
+++ b/pycparser/c_lexer.py
@@ -112,6 +112,7 @@ class CLexer(object):
'_BOOL', '_COMPLEX',
'_NORETURN', '_THREAD_LOCAL', '_STATIC_ASSERT',
'_ATOMIC', '_ALIGNOF', '_ALIGNAS',
+ '_PRAGMA',
)
keyword_map = {}
diff --git a/pycparser/c_parser.py b/pycparser/c_parser.py
index c9782e0..d31574a 100644
--- a/pycparser/c_parser.py
+++ b/pycparser/c_parser.py
@@ -571,11 +571,19 @@ class CParser(PLYParser):
self._parse_error('Directives not supported yet',
self._token_coord(p, 1))
+ # This encompasses two types of C99-compatible pragmas:
+ # - The #pragma directive:
+ # # pragma character_sequence
+ # - The _Pragma unary operator:
+ # _Pragma ( " string_literal " )
def p_pppragma_directive(self, p):
""" pppragma_directive : PPPRAGMA
| PPPRAGMA PPPRAGMASTR
+ | _PRAGMA LPAREN unified_string_literal RPAREN
"""
- if len(p) == 3:
+ if len(p) == 5:
+ p[0] = c_ast.Pragma(p[3], self._token_coord(p, 2))
+ elif len(p) == 3:
p[0] = c_ast.Pragma(p[2], self._token_coord(p, 2))
else:
p[0] = c_ast.Pragma("", self._token_coord(p, 1))