This works!
However, for whatever reason, I want the user to be obligated to add a comma at the end. Like this: (Tralalero, Tralala, Crocodilo, Bombardilo,)
** In state 44, looking ahead at COMMA, reducing production
** separated_nonempty_list(COMMA,use_tree) -> use_tree
** is permitted because of the following sub-derivation:
simple_path_special LBRACE separated_nonempty_list(COMMA,use_tree) option(COMMA) RBRACE // lookahead token appears because option(COMMA) can begin with COMMA
use_tree .
** In state 44, looking ahead at COMMA, shifting is permitted
** because of the following sub-derivation:
simple_path_special LBRACE separated_nonempty_list(COMMA,use_tree) option(COMMA) RBRACE
use_tree . COMMA separated_nonempty_list(COMMA,use_tree)
The problem is that the parser cannot decide upon seeing the last COMMA if it is the comma following an identifier as part of the list or if it is the optional comma. You should try instead with
LBRACE;
trees = separated_nonempty_list(COMMA, use_tree);
option(COMMA);
RBRACE
** Conflict (shift/reduce) in state 44.
** Token involved: COMMA
** This state is reached from program after reading:
outer_attrs USE simple_path_special LBRACE use_tree
** The derivations that appear below have the following common factor:
** (The question mark symbol (?) represents the spot where the derivations begin to differ.)
program
items EOF
item items
outer_attrs vis_item
use_declaration
USE use_tree SEMI
(?)
** In state 44, looking ahead at COMMA, reducing production
** separated_nonempty_list(COMMA,use_tree) -> use_tree
** is permitted because of the following sub-derivation:
simple_path_special LBRACE separated_nonempty_list(COMMA,use_tree) option(COMMA) RBRACE // lookahead token appears because option(COMMA) can begin with COMMA
use_tree .
** In state 44, looking ahead at COMMA, shifting is permitted
** because of the following sub-derivation:
simple_path_special LBRACE separated_nonempty_list(COMMA,use_tree) option(COMMA) RBRACE
use_tree . COMMA separated_nonempty_list(COMMA,use_tree)
@grayswandyr gave me the idea of using left recursion, so the first thing that I check is that there is a comma at the end.
Just keep in mind that with this technique, the computed list is in reverse order. Depending on your application, you may want to massage it through List.rev.