1

I'm having trouble on how to express something recursive in BNF. A 'term' in my case can be formed by a value, multiply and divide (shown in image), I came up with the following:

<term> ::= <value>
              | <value> “*”
              | <value> “/”

2
  • I think it should be t := v | t * t | t / t
    – karakfa
    Oct 19, 2015 at 18:15
  • That makes more sense, thanks for that. Oct 19, 2015 at 18:34

1 Answer 1

5

Recursive specification is a specification in which the non terminal appears recursively in the production rules. Take a look at following grammar which is a recursive specification that contains +, *, $(exponentiation) and uses BNF notation:

 <exp>     := <exp> + <term> | <term>
 <term>    := <term> * <factor> | <factor>
 <factor>  := <factor> $ <primary> | <primary>
 <primary> := id

As you can see all non terminal which are in LHS of := are also in production (RHS) so it is called Recursive BNF notation.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.