1 of 1 people found this helpful
So as it turns out it's the pipes themselves. I simplified the rule down to this:
comment COMMENT $save_as_comment $0
sub_rule VAL PIPE $new_field $0 %sub_rule
record VAL PIPE $new_field $0 %sub_rule $save_record $0
add $write_record $VAR_PIPE
Which does not work, recursion error. However if I replace the pipes in the file and in the grammar with a colon - otherwise entirely identical, it works fine. I'm going to open a support case..
And it's a defect, pipe characters aren't being escaped properly.