parsingbisonebnflalr

Bison/EBNF parse list with at least two elements


I am currently trying to parse a comma seperated list with at least two elements using bison. I know how to parse a list using this:

list : list "," element
     | element

but how can I make sure that the list has at least two elements?


Solution

  • At the risk of being two obvious:

    list : list "," element
         | element "," element