Larry Knain wrote:
I inserted the code change you suggested and it picks up the 2 but there is no indication of the "missing" list element. I'll do some more reading and see what I can come up with. (I have a number of CSV files created by various spreadsheets and DB programs that I need to read that have "missing" list items and was trying for a more elegant solution in Spirit. I have done this with the tokenizer by keeping the delimiter tokens.)
Honestly, I've already thought, that you'll bring up this issue :-) It's simply a matter of operator precedence in C++. If you write: list_csv = list_p( !list_csv_item[append(vec_item)], ',' )[append(vec_list)] ; you make the whole item construct optional: !(list_csv_item[append(vec_item)]), i.e. the attached semantic action is optional too and will be executed only, if/when the parser matches. But if you'd write: list_csv = list_p( (!list_csv_item)[append(vec_item)], ',' )[append(vec_list)] ; (please note the additional parenthesis pair), you'd make optional the parser part only. The action is executed always (even if the parser does not match). HTH Regards Hartmut