robotpy / robotpy-cppheaderparser

DEPRECATED: use cxxheaderparser instead
Other
123 stars 39 forks source link

Regression in 3.3.0 #39

Closed tpaviot closed 4 years ago

tpaviot commented 4 years ago

I use to work with 3.2.0 release, but I have a regression when trying to update to latest revision. It seems a regression was introduced in the 3.3.0 release. Indeed, let header.hxx be the following header file:

class A
{
public:
  A();

private:
  class A : public B<int,int>::C
  {
  };
};

Trying to parse with CppHeaderParser 3.3.0, I get the following issue:

$ python ess.py 
Traceback (most recent call last):
  File "/home/thomas/miniconda3/envs/bindgen/lib/python3.7/site-packages/CppHeaderParser/CppHeaderParser.py", line 2859, in __init__
    self._evaluate_stack()
  File "/home/thomas/miniconda3/envs/bindgen/lib/python3.7/site-packages/CppHeaderParser/CppHeaderParser.py", line 3329, in _evaluate_stack
    self._evaluate_class_stack()
  File "/home/thomas/miniconda3/envs/bindgen/lib/python3.7/site-packages/CppHeaderParser/CppHeaderParser.py", line 2488, in _evaluate_class_stack
    self.curAccessSpecifier,
  File "/home/thomas/miniconda3/envs/bindgen/lib/python3.7/site-packages/CppHeaderParser/CppHeaderParser.py", line 709, in __init__
    self["inherits"] = _parse_cpp_base(baseStack, defaultAccess)
  File "/home/thomas/miniconda3/envs/bindgen/lib/python3.7/site-packages/CppHeaderParser/CppHeaderParser.py", line 567, in _parse_cpp_base
    raise CppParseError("expected comma, found '%s'" % t)
CppHeaderParser.CppHeaderParser.CppParseError: expected comma, found '::'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "ess.py", line 3, in <module>
    CppHeaderParser.CppHeader('test.hxx')
  File "/home/thomas/miniconda3/envs/bindgen/lib/python3.7/site-packages/CppHeaderParser/CppHeaderParser.py", line 2994, in __init__
    CppParseError(msg), e,
  File "<string>", line 1, in raise_exc
CppHeaderParser.CppHeaderParser.CppParseError: Not able to parse test.hxx on line 8 evaluating '{': expected comma, found '::'
Error around: class A : public B < int , int > :: C

With 3.2.0, I have no exception raised, the output dict is:

{'classes': {'A': {'nested_classes': [{'nested_classes': [], 'parent': 'A', 'abstract': False, 'namespace': '::A', 'final': False, 'name': 'A', 'filename': 'test.hxx', 'line_number': 7, 'inherits': [{'access': 'public', 'virtual': False, 'class': 'B<int'}, {'access': 'int', 'virtual': False, 'class': '>::C'}], 'methods': {'public': [], 'protected': [], 'private': []}, 'properties': {'public': [], 'protected': [], 'private': []}, 'enums': {'public': [], 'protected': [], 'private': []}, 'structs': {'public': [], 'protected': [], 'private': []}, 'typedefs': {'public': [], 'protected': [], 'private': []}, 'forward_declares': {'public': [], 'protected': [], 'private': []}, 'declaration_method': 'class'}], 'parent': None, 'abstract': False, 'namespace': '', 'final': False, 'name': 'A', 'filename': 'test.hxx', 'line_number': 1, 'inherits': [], 'methods': {'public': [{'rtnType': 'void', 'name': 'A', 'noexcept': None, 'const': False, 'final': False, 'override': False, 'debug': 'A ( ) ;', 'class': None, 'namespace': '', 'defined': False, 'pure_virtual': False, 'operator': False, 'constructor': True, 'destructor': False, 'extern': False, 'template': False, 'virtual': False, 'static': False, 'explicit': False, 'inline': False, 'friend': False, 'returns': '', 'returns_pointer': 0, 'returns_fundamental': True, 'returns_class': False, 'default': False, 'returns_reference': False, 'filename': 'test.hxx', 'line_number': 4, 'vararg': False, 'parameters': [], 'parent': {...}, 'path': 'A'}], 'protected': [], 'private': []}, 'properties': {'public': [], 'protected': [], 'private': []}, 'enums': {'public': [], 'protected': [], 'private': []}, 'structs': {'public': [], 'protected': [], 'private': []}, 'typedefs': {'public': [], 'protected': [], 'private': []}, 'forward_declares': {'public': [], 'protected': [], 'private': []}, 'declaration_method': 'class'}, 'A::A': {'nested_classes': [], 'parent': 'A', 'abstract': False, 'namespace': '::A', 'final': False, 'name': 'A', 'filename': 'test.hxx', 'line_number': 7, 'inherits': [{'access': 'public', 'virtual': False, 'class': 'B<int'}, {'access': 'int', 'virtual': False, 'class': '>::C'}], 'methods': {'public': [], 'protected': [], 'private': []}, 'properties': {'public': [], 'protected': [], 'private': []}, 'enums': {'public': [], 'protected': [], 'private': []}, 'structs': {'public': [], 'protected': [], 'private': []}, 'typedefs': {'public': [], 'protected': [], 'private': []}, 'forward_declares': {'public': [], 'protected': [], 'private': []}, 'declaration_method': 'class'}}, 'functions': [], 'enums': [], 'variables': []}

ping @rainman110

tpaviot commented 4 years ago

It's quite hard to debug since 3.3.0 includes a big undocumented code refactoring, in only 3 commits see https://github.com/robotpy/robotpy-cppheaderparser/compare/3.2.0...3.3.0

virtuald commented 4 years ago

Try https://github.com/robotpy/robotpy-cppheaderparser/pull/40 and let me know if that addresses your issue.