summaryrefslogtreecommitdiff
path: root/pycparser/c_parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'pycparser/c_parser.py')
-rw-r--r--pycparser/c_parser.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/pycparser/c_parser.py b/pycparser/c_parser.py
index f4f7453..494f501 100644
--- a/pycparser/c_parser.py
+++ b/pycparser/c_parser.py
@@ -537,8 +537,9 @@ class CParser(PLYParser):
def p_external_declaration_3(self, p):
""" external_declaration : pp_directive
+ | pppragma_directive
"""
- p[0] = p[1]
+ p[0] = [p[1]]
def p_external_declaration_4(self, p):
""" external_declaration : SEMI
@@ -549,7 +550,16 @@ class CParser(PLYParser):
""" pp_directive : PPHASH
"""
self._parse_error('Directives not supported yet',
- self._coord(p.lineno(1)))
+ self._coord(p.lineno(1)))
+
+ def p_pppragma_directive(self, p):
+ """ pppragma_directive : PPPRAGMA
+ | PPPRAGMA PPPRAGMASTR
+ """
+ if len(p) == 3:
+ p[0] = c_ast.Pragma(p[2])
+ else:
+ p[0] = c_ast.Pragma("")
# In function definitions, the declarator can be followed by
# a declaration list, for old "K&R style" function definitios.
@@ -589,6 +599,7 @@ class CParser(PLYParser):
| selection_statement
| iteration_statement
| jump_statement
+ | pppragma_directive
"""
p[0] = p[1]