diff options
author | Eli Bendersky <eliben@gmail.com> | 2016-03-19 05:21:59 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2016-03-19 05:21:59 -0700 |
commit | 95e3b761d93ce95f42edccd15b1b2e81f75193a2 (patch) | |
tree | cce44867524e61dfbb7425a1ac2358274fc7798e /pycparser/c_parser.py | |
parent | ad996555659a8b8908358f45ad326d0a26eddcfa (diff) | |
download | pycparser-95e3b761d93ce95f42edccd15b1b2e81f75193a2.tar.gz |
Fix parsing of extra semi-colons inside structure declarations.
Fixes #117
Diffstat (limited to 'pycparser/c_parser.py')
-rw-r--r-- | pycparser/c_parser.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/pycparser/c_parser.py b/pycparser/c_parser.py index c5a9e68..5c17a74 100644 --- a/pycparser/c_parser.py +++ b/pycparser/c_parser.py @@ -836,7 +836,10 @@ class CParser(PLYParser): """ struct_declaration_list : struct_declaration | struct_declaration_list struct_declaration """ - p[0] = p[1] if len(p) == 2 else p[1] + p[2] + if len(p) == 2: + p[0] = p[1] or [] + else: + p[0] = p[1] + (p[2] or []) def p_struct_declaration_1(self, p): """ struct_declaration : specifier_qualifier_list struct_declarator_list_opt SEMI @@ -890,6 +893,11 @@ class CParser(PLYParser): spec=p[1], decls=[dict(decl=p[2], init=None)]) + def p_struct_declaration_3(self, p): + """ struct_declaration : SEMI + """ + p[0] = None + def p_struct_declarator_list(self, p): """ struct_declarator_list : struct_declarator | struct_declarator_list COMMA struct_declarator |