In: Computer Science
Can following BNF convert to CFG (Context Free Grammar)
<Boolean_expr> →
<Boolean_expr>||<Boolean_term>|<Boolean_term>
<Boolean _term> → <Boolean _term> &&
<Boolean _factor>| <Boolean _factor>
<Boolean _factor> →ID | !<Boolean _factor>|
(<Boolean _factor>) |<relation_expr>
<relation_expr> → ID==ID | ID !=ID | ID < ID | ID≤ID |
ID>ID | ID>=ID
The above BNF is for Boolean Expression and Relational Expression.
I have completed this problem Please give thumbs up if you like it
Step 1 what is CFG
Step 2
Given BNF grammar is
<Boolean_expr> →
<Boolean_expr>||<Boolean_term>|<Boolean_term>
<Boolean _term> → <Boolean _term> &&
<Boolean _factor>| <Boolean _factor>
<Boolean _factor> →ID | !<Boolean _factor>|
(<Boolean _factor>) |<relation_expr>
<relation_expr> → ID==ID | ID !=ID | ID < ID | ID≤ID |
ID>ID | ID>=ID
The above BNF is for Boolean Expression and Relational Expression.
Step 3
Now convert this BNF into CNF form
This grammar is for both
boolean expression and relational expression