-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
When working with punctuated list, I usually don't interested in the separator. Most of the time, simple list would be enough. Also capturing separator require memory allocation for their storage, which usually unnecessary.
Describe the solution you'd like
I propose that punctuated rules, can match with two types.
[Rule("name_list : Lparen (Identifier (',' Identifier)*)? Rparen")]
private static List<string> NameList(
IToken<TokenType> _lp,
Punctuated<IToken<TokenType>, IToken<TokenType>> elements,
IToken<TokenType> _rp) => elements.Values.Select(t => t.Text).ToList();
and to list types.
[Rule("name_list : Lparen (Identifier (',' Identifier)*)? Rparen")]
private static List<string> NameList(
IToken<TokenType> _lp,
IReadOnlyList<IToken<TokenType>> elements,
IToken<TokenType> _rp) => elements.Values.Select(t => t.Text).ToList();
Describe alternatives you've considered
I think maybe #77 can work as well, but I believe this is much simpler to implement without too much generalizations.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request