Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Rewrite the following BNF grammar using the form of EBNF described on the bottom

ID: 3791327 • Letter: R

Question

Rewrite the following BNF grammar using the form of EBNF described on the bottom half of page 127 in Sebesta.

<import_decl> import <import_list> ;

<import_list> <package_list>

| <package_list> . *

<package_list> <identifier>

| <package_list> . <identifier>

<identifier> a | b | c

Make the resulting grammar as simple as possible, but keep all four of the original nonterminals, which will now be named ImportDecl, ImportList, PackageList, and Identifier. (Note: There are some typographical errors on page 127. See page 3-21 of the course notes for a better description of this form of EBNF.)

Explanation / Answer

<assign> -> import = <import_list>

<import_list> -> <package_list> {(+ | * ) } '.'

<package_list> -> <identifier> {(+ ) | <package_list>

<identifier> -> ( a | b | c )

The same grammer is shown ebnf in which the

<import_list> <package_list>

| <package_list> . * is converted to <import_list> -> <package_list> {(+ | * ) } '.'

and <identifier> a | b | c is converted to <identifier> -> ( a | b | c ) with parenthesis.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote