2021年4月1日星期四

Is this conversion from BNF to EBNF correct?

As context, my textbook uses this style for EBNF:

Text

Sebesta, Robert W. Concepts of Programming Languages 11th ed., Pearson, 2016, 150.

The problem: Convert the following BNF rule with three RHSs to an EBNF rule with a single RHS.

Note: Conversion to EBNF should remove all explicit recursion and yield a single RHS EBNF rule.

A ⟶ B + A | B – A | B

My solution:

A ⟶ B [ (+ | –) A ]

My professor tells me:

"First, you should use { } instead of [ ], Second, according to the BNF rule, <"term"> is B." (He is referring the the style guide posted above)

Is he correct? I assume so but have read other EBNF styles and wonder if I am entitled to credit.

https://stackoverflow.com/questions/66912379/is-this-conversion-from-bnf-to-ebnf-correct April 02, 2021 at 06:36AM

没有评论:

发表评论