Skip to content

[BUG]: cxxheaderparser.errors.CxxParseError: parse error evaluating '\': unexpected '\' #48

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

Closed
alandtse opened this issue Mar 27, 2023 · 1 comment
Labels
valid-with-preprocessor Example works fine when a C++ preprocessor first processes the text. This is not a bug. wontfix This will not be worked on

Comments

@alandtse
Copy link

alandtse commented Mar 27, 2023

Problem description

Just tried 7d302fd and ran into a parse error on the newline continuation for a #define

➜  cxxheaderparser git:(main) ✗ python3 -m cxxheaderparser --mode=brepr ~/CommonLibVR/include/REL/Relocation.h
Traceback (most recent call last):
  File "~/cxxheaderparser/cxxheaderparser/parser.py", line 331, in parse
    fn(tok, doxygen)
  File "~/cxxheaderparser/cxxheaderparser/parser.py", line 589, in _parse_template
    template = self._parse_template_decl()
  File "~/cxxheaderparser/cxxheaderparser/parser.py", line 574, in _parse_template_decl
    param = self._parse_parameter(tok, TemplateNonTypeParam, ">")
  File "~/cxxheaderparser/cxxheaderparser/parser.py", line 1575, in _parse_parameter
    parsed_type, mods = self._parse_type(tok)
  File "~/cxxheaderparser/cxxheaderparser/parser.py", line 2126, in _parse_type
    raise self._parse_error(tok)
cxxheaderparser.errors.CxxParseError: unexpected '\'

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

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/[email protected]/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Cellar/[email protected]/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "~/cxxheaderparser/cxxheaderparser/__main__.py", line 4, in <module>
    dumpmain()
  File "~/cxxheaderparser/cxxheaderparser/dump.py", line 30, in dumpmain
    data = parse_file(args.header, options=options)
  File "~/cxxheaderparser/cxxheaderparser/simple.py", line 375, in parse_file
    return parse_string(content, filename=filename, options=options)
  File "~/cxxheaderparser/cxxheaderparser/simple.py", line 351, in parse_string
    parser.parse()
  File "~/cxxheaderparser/cxxheaderparser/parser.py", line 355, in parse
    raise CxxParseError(msg) from e
cxxheaderparser.errors.CxxParseError: ../CommonLibVR/include/REL/Relocation.h:6: parse error evaluating '\': unexpected '\'

Operating System

MacOS

Installed Python Packages

Package    Version
---------- -------
docutils   0.19
pip        22.3.1
protobuf   4.21.12
PyYAML     6.0
setuptools 65.6.3
six        1.16.0
wheel      0.38.4

Reproducible example code

#pragma once
#ifdef SKYRIMVR
#	include <csv.h>
#endif
#define REL_MAKE_MEMBER_FUNCTION_POD_TYPE_HELPER_IMPL(a_nopropQual, a_propQual, ...)              \
	template <                                                                                    \
		class R,                                                                                  \
		class Cls,                                                                                \
		class... Args>                                                                            \
	struct member_function_pod_type<R (Cls::*)(Args...) __VA_ARGS__ a_nopropQual a_propQual>      \
	{                                                                                             \
		using type = R(__VA_ARGS__ Cls*, Args...) a_propQual;                                     \
	};                                                                                            \
                                                                                                  \
	template <                                                                                    \
		class R,                                                                                  \
		class Cls,                                                                                \
		class... Args>                                                                            \
	struct member_function_pod_type<R (Cls::*)(Args..., ...) __VA_ARGS__ a_nopropQual a_propQual> \
	{                                                                                             \
		using type = R(__VA_ARGS__ Cls*, Args..., ...) a_propQual;                                \
	};

https://github.com/alandtse/CommonLibVR/blob/95c6de6bbee89d0195fd3e1ba0a469b44928e038/include/REL/Relocation.h#L139-L147

@virtuald
Copy link
Member

virtuald commented Mar 27, 2023

As per the README, cxxheaderparser explicitly does not attempt to work on code that hasn't been ran through a preprocessor (unlike CppHeaderParser), so this is a wontfix.

template <class T>
struct meets_function_req :
	std::conjunction<
		std::is_trivially_constructible<T>,
		std::is_trivially_destructible<T>,
		std::is_trivially_copy_assignable<T>,
		std::negation<
			std::is_polymorphic<T>>>
{};

Does work by itself however.

@virtuald virtuald added the wontfix This will not be worked on label Mar 27, 2023
@auscompgeek auscompgeek closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2023
@virtuald virtuald added the valid-with-preprocessor Example works fine when a C++ preprocessor first processes the text. This is not a bug. label Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
valid-with-preprocessor Example works fine when a C++ preprocessor first processes the text. This is not a bug. wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants