srcML / srcML

srcML Toolkit
srcml.org
GNU General Public License v3.0
105 stars 26 forks source link

For loops with empty controls should have empty inits #1978

Open Joshua2000B opened 7 months ago

Joshua2000B commented 7 months ago

Currently, running for () {} within srcML yields:

<for>for<control>(<init><expr/></init>)</control> <block>{<block_content/>}</block></for>

This causes some issues for srcQL, and in general is confusing, as we are assuming an empty control contains an init with an expression.

Instead, the output should be:

<for>for<control>(<init/>)</control> <block>{<block_content/>}</block></for>

In this, the init is empty, which means it matches as a wildcard to ANY for, not just fors with an expression init.