Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while parsing multidimensional array function argument #34

Open
Gualor opened this issue Nov 5, 2024 · 1 comment
Open

Error while parsing multidimensional array function argument #34

Gualor opened this issue Nov 5, 2024 · 1 comment

Comments

@Gualor
Copy link

Gualor commented Nov 5, 2024

I was playing around using this tool on a C++ codebase and I encountered a parsing issue of the line:

class device_iio_utils {
private:
    ...

public:
    ...
    static int get_selftest_available(const char *device_dir, char list[][20]); // <-- this line causes the issue
    ...
};

Here is the traceback:

Traceback (most recent call last):
  File "C:\msys64\home\gualniel\miniconda3\envs\mlc\Lib\site-packages\CppHeaderParser\CppHeaderParser.py", line 3107, in __init__
    self._evaluate_stack(tok.type)
  File "C:\msys64\home\gualniel\miniconda3\envs\mlc\Lib\site-packages\CppHeaderParser\CppHeaderParser.py", line 3456, in _evaluate_stack
    self._evaluate_method_stack()
  File "C:\msys64\home\gualniel\miniconda3\envs\mlc\Lib\site-packages\CppHeaderParser\CppHeaderParser.py", line 2350, in _evaluate_method_stack
    newMethod = CppMethod(
                ^^^^^^^^^^
  File "C:\msys64\home\gualniel\miniconda3\envs\mlc\Lib\site-packages\CppHeaderParser\CppHeaderParser.py", line 1136, in __init__
    param = CppVariable(
            ^^^^^^^^^^^^
  File "C:\msys64\home\gualniel\miniconda3\envs\mlc\Lib\site-packages\CppHeaderParser\CppHeaderParser.py", line 1257, in __init__
    self["multi_dimensional_array_size"] += "x" + n
                                                  ^
UnboundLocalError: cannot access local variable 'n' where it is not associated with a value

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

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\msys64\home\gualniel\miniconda3\envs\mlc\Scripts\hpp2plantuml.exe\__main__.py", line 7, in <module>
  File "C:\msys64\home\gualniel\miniconda3\envs\mlc\Lib\site-packages\hpp2plantuml\hpp2plantuml.py", line 1554, in main
    CreatePlantUMLFile(args.input_files, args.output_file,
  File "C:\msys64\home\gualniel\miniconda3\envs\mlc\Lib\site-packages\hpp2plantuml\hpp2plantuml.py", line 1515, in CreatePlantUMLFile
    diag.create_from_file_list(list(set(expand_file_list(file_list_c))))
  File "C:\msys64\home\gualniel\miniconda3\envs\mlc\Lib\site-packages\hpp2plantuml\hpp2plantuml.py", line 952, in create_from_file_list
    self._build_helper(file_list, build_from='file_list',
  File "C:\msys64\home\gualniel\miniconda3\envs\mlc\Lib\site-packages\hpp2plantuml\hpp2plantuml.py", line 932, in _build_helper
    self.parse_objects(single_input, build_from_single)
  File "C:\msys64\home\gualniel\miniconda3\envs\mlc\Lib\site-packages\hpp2plantuml\hpp2plantuml.py", line 1042, in parse_objects
    parsed_header = CppHeaderParser.CppHeader(header_file,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\msys64\home\gualniel\miniconda3\envs\mlc\Lib\site-packages\CppHeaderParser\CppHeaderParser.py", line 3148, in __init__
    raise_exc(
  File "<string>", line 1, in raise_exc
CppHeaderParser.CppHeaderParser.CppParseError: Not able to parse core/utils.h on line 128 evaluating ';'
Error around: static int get_selftest_available ( const char * device_dir , char list [ ] [ 20 ] )

I am using the tool on MSYS2 environment on Windows11 using Miniconda (Anaconda) with Python 3.12.7.

@thibaultmarin
Copy link
Owner

hpp2plantuml relies on the robotpy-cppheaderparser package to parse the header files. Your example seemed to work for me with robotpy-cppheaderparser v5.1.1 but fails with v5.1.2.

Since robotpy-cppheaderparser is deprecated, hpp2plantuml should eventually move to cxxheaderparser, it is on my list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants