[hawkmoth] Re: [PATCH] parser: simplify macro arguments extraction
- From: Bruno Santos <brunomanuelsantos@xxxxxxxxxxxxxxxxxx>
- To: hawkmoth@xxxxxxxxxxxxx
- Date: Sat, 12 Oct 2019 17:28:02 +0200
On 08:30:51 2019-10-11, Jani Nikula wrote:
On Tue, 24 Sep 2019, Bruno Santos <brunomanuelsantos@xxxxxxxxxxxxxxxxxx>
1) #define FOO
If the macro has no value, the second next() will throw
StopIteration. This is the len(x) != 2 check in the original.
Good catch! I adapted this from another project where this problem was
guarded against differently. I think a default value will be enough
2) #define FOO (arg)
If the macro value starts with "(" the macro gets incorrectly identified
as a function-like macro. This is the x.extent.end !=
x.extent.start check in the original.
Hm, I had considered this one actually, but only limited cases like
"#define FOO ('c', 12)" which would be fine falling through the for loop
below. You're right though, anything goes within a macro body.
Despite the blunders, I still think the code will look nicer without the
itertools business. I'll add the extent comparisons back as well as test
cases for these scenarios.
Other related posts: