Test whether empty EXPAND1 lists behave as expected

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Prevent `IndexError`s when building empty EXPAND/EXPAND1 lists

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Add test cases for the expected structure of FLATTEN rules

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Add test-case for resursive FLATTENing rules

Specifically verifies that #rules marked for FLATTENing don't produce
unboundedly deep trees, causing stack overflows when PLY debugging is
enabled.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Flatten recursive #rules in-place to significantly reduce tree-depth

Same solution as 8d4860b5bd (that was for in-place expansion of @rules
and ?rules).

In short: without this change recursive #rules marked for FLATTENing can
cause ASTs with unbounded depth. Due to a recursive `repr()`
implementation this can cause stack overflows when running with
`debug=True`. This commit prevents this problem.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
refactor parser-rule actions to use same definition for all rules

I.e. use the same action when matching a parser-rule with flags (?#@) as
without. Due to previous changes the rule for EXPAND/EXPAND1/FLATTEN was
already suitable to be used for the non-flag case. As a result the only
changes are indentation and comments along with the removal of the
non-flag-only action.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Merge tag 'bugfixes' of git://github.com/muggenhor/plyplus

AST: add test cases, fix bugs, refactor

 * More thoroughly document expected AST in form of test cases
 * Fix a bug causing `IndexError`s on empty EXPAND/EXPAND1 [@?]rules
 * Prevent unbounded tree-depth on FLATTEN #rules
 * Merge parser-rule-action code to be the same for all rules