0

I am working with Flex/Bison and VHDL 93. I have a problem with the following rule:

choices ::= choice { | choice }

If I convert it to BNF:

N1 ::= %empty | choice
N2 ::= %empty | N2 N1
choices ::= choice N2
choices ::= choice | choice N2 N1
choices ::= choice | choices N1
choices ::= choice | choices | choices choice

But choices : choices is unuseful so finally

choices ::= choice | choices choice

So, what is the problem? Well, imagine that the rule to convert is:

choices ::= choice { choice }

And I apply the rules to convert to BNF:

N1 ::= choice
N2 ::= %empty | N2 N1
choices ::= choice N2
choices ::= choice | choice N2 N1
choices ::= choice | choices N1
choices ::= choice | choices choice

Which is the same previous result!!! What is happens? Where is the problem? I had problems with this rule more than a year ago, I am working again in this project and my problems with choices is still here :P

Here what the VHDL 93 standard said about choices:

In the second case, "choices" can be replaced by a list of "choice," separated by vertical bars.

I don't know from where the ',' comes from.

Thanks.

RAM
  • 65
  • 4
  • 11
  • 1
    The comma is just punctuation, and whoever wrote that sentence believed that punctuation must go inside quotation marks. What your grammar is missing is the "separated by vertical bars" part. – rici Mar 02 '19 at 17:51
  • So... Any idea about how to solve the mistake? – RAM Mar 03 '19 at 13:30

1 Answers1

1

The VHDL description is quite clear: you need a list of choice separated by vertical bars. The EBNF is possibly confusing because the vertical bar might be misinterpreted as an EBNF operator. But from the description, it's evident that it is actually a token.

So, in bison/yacc syntax:

choices: choice
       | choices '|' choice
rici
  • 234,347
  • 28
  • 237
  • 341
  • Thanks a lot! My mother tongue is Spanish and was confusing to me. It has sense now :-) – RAM Mar 03 '19 at 19:10