Give a BNF grammar of the descriptions below. Also show that you can derive a nu
ID: 3665190 • Letter: G
Question
Give a BNF grammar of the descriptions below. Also show that you can derive a number of positive examples of the language in the constructed grammar and also show that you are not able to derive a set of negative examples in the grammar.
c) The set of all strings consisting of one or more instances of the letter a.
g) The set of all strings consisting of one or more instances of the letter a with a semicolon after each one.
j) The set of all strings consisting of an open bracket (the symbol ‘[‘) followed by a list of one or more digits separated by commas, followed by a closing bracket (the symbol ‘]’).
k) The set of all strings consisting of zero or more instances of the letter a, with a comma between each a and next. There should be no comma before the first or after the last.
Explanation / Answer
BNF rules define grammar elements, notation used is Backus-Naur Form (BNF).
<expr> ::= <term> | <expr> <op1> <expr>
<term> ::= <decimal arg> | <term> <op2> <decimal arg>
<decimal arg> ::= <digit> |<decimal arg> <digit>
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<op1> ::= + | -
<op2> ::= * | /
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.