Given the following EBNF declarations (based on Modula-2) <simple expression> ::
ID: 668667 • Letter: G
Question
Given the following EBNF declarations (based on Modula-2)
<simple expression> ::= [ + | - ] <term> { + <term> | - <term> | OR <term> }*
<term> ::= <factor> { * <factor> | / <factor> | DIV <factor> | MOD <factor> | AND <factor> | & <factor> }*
<factor> ::= <number> | <ident> | (<simple expression>) | NOT<factor>
<ident> ::= <letter> { <letter> | <digit> }*
simplify the expressions for <simple expression> and <term> by adding other nonterminal definitions so that you can reduce the number of options in the braces.
Explanation / Answer
<simple expression> ::= N <term> { N1}
N:= + | - |
N1 ::= + <term> | - <term> | OR <term>
<term> ::= <factor> {N2}
N2 ::= <factor> | / <factor> | DIV <factor> | MOD <factor> | AND <factor> | & <factor> |
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.