Question

In: Computer Science

Q1)   Convert the following set of BNF rules to a single EBNF rule. <E> --> <E>...

Q1)   Convert the following set of BNF rules to a single EBNF rule.

<E> --> <E> + <T>
     |  <E> - <T>
     |  <T>

Q2)   Briefly explain how the expected type and actual type of <expr>

            in the following two BNF rules are determined:

<assign> --> <var> = <expr>  (Rule 1)
<expr>   --> <var> + <var>   (Rule 2)

Solutions

Expert Solution

Answer 1.

BNF:

<E> --> <E> + <T>

     | <E> - <T>

     | <T>

Conversion to EBNF:

<E> --> <E> <O> <T> +

<O> --> ‘+’ | ‘-‘

E equals to ‘E’ ‘O’ ‘T’

Where

E is expression

O is operator which can be ‘+’ or ‘-‘

T is term which is one or more.

Answer 2.

actual-type: a synthesized attribute which stores the actual type of a <VAR> or an <EXPRESSION>. In the case of an <EXPRESSION> , the type is computed given the types of the component <VAR>s.

expected-type: an inherited attribute which stores the expected type of <EXPRESSION> . It is determined by the type of the <VAR> on the left-hand-side of the expression statement.

Answer 1.

BNF:

<E> --> <E> + <T>

     | <E> - <T>

     | <T>

Conversion to EBNF:

<E> --> <E> <O> <T> +

<O> --> ‘+’ | ‘-‘

E equals to ‘E’ ‘O’ ‘T’

Where

E is expression

O is operator which can be ‘+’ or ‘-‘

T is term which is one or more.

Answer 2.

actual-type: a synthesized attribute which stores the actual type of a <VAR> or an <EXPRESSION>. In the case of an <EXPRESSION> , the type is computed given the types of the component <VAR>s.

expected-type: an inherited attribute which stores the expected type of <EXPRESSION> . It is determined by the type of the <VAR> on the left-hand-side of the expression statement.


Related Solutions

Create an E/R diagram for the following business situation and convert the diagram into a set...
Create an E/R diagram for the following business situation and convert the diagram into a set of related tables: A health insurance company sells a number of insurance policies. Employer companies can buy any number of policies including zero and up to 4. A policy must be bought by at least one employer. Employees working for the employers can select at most one insurance policy. A policy can be selected by any number of employees including zero. Employees can add...
5-Write an EBNF rules that describes the following while statement of Java. Then, write the recursive-descent...
5-Write an EBNF rules that describes the following while statement of Java. Then, write the recursive-descent subprogram in Java or C/C++ for the EBNF rule. Please summit your source code and a screen shot of the parsing of the following examples. do { if ( number % 2 == 0 ) even ++; number=number+1; } while (number <= 10)
Rule Based System 1. Given the rule following rules from the class notes on production rules...
Rule Based System 1. Given the rule following rules from the class notes on production rules to convert an Arabic number less than 40 to a roman numeral. USING LOGIC Rule 1: if x is null then prompt the user and read x Rule 2: if x is higher than 999 then print “too Big” and make x null Rule 3: if x is between 10 and 39 then print “X” and reduce x by 10 Rule 4: if x...
Write EBNF descriptions for the following: • a Java For each statement Assume that EBNF descriptions...
Write EBNF descriptions for the following: • a Java For each statement Assume that EBNF descriptions for statement(s), type, array, white space are given. (statmnts, type, array, and whitespace respectively) You have to create EBNF descriptions for For each statement and also variable. Use the following Java variable naming rules to create EBNF description for variable. o All variable names must begin with a letter of the alphabet, an underscore ( _ ) , or a dollar sign ( $...
Q1.Convert C46C000016 into a 32-bit single-precision IEEE floating-point binary number.
Q1.Convert C46C000016 into a 32-bit single-precision IEEE floating-point binary number.
PCAOB Rules Rule 3520—Auditor Independence Rule 3521—Contingent Fees Rule 3522—Tax Transactions Rule 3523—Tax Services for Persons...
PCAOB Rules Rule 3520—Auditor Independence Rule 3521—Contingent Fees Rule 3522—Tax Transactions Rule 3523—Tax Services for Persons in Financial Reporting Oversight Roles Rule 3526 establishes guidelines when an accounting firm should discuss with the audit committee of the client information with respect to any relationships between the firm and the entity that might bear on auditor independence. Under the rule, a registered public accounting firm must do the following: Page 252 Prior to accepting an initial engagement, pursuant to the standards...
Which one of the following terms is the name for a set of rules describing how...
Which one of the following terms is the name for a set of rules describing how the corporation regulates its existence (ex. how directors are elected)? Multiple Choice Articles of incorporation. Corporate breakdown. Legal liability. Bylaws. Agency problem.
Answer the following questions based on HSAB theory. If using Fajans Rules, give the rule number...
Answer the following questions based on HSAB theory. If using Fajans Rules, give the rule number and explain why it applies. 1. Explain why aluminum perchlorate is less soluble than aluminum cyanide. This is unusual since perchorates tend to be very soluble. 2. Explain why the Ksp for FeBr2 is 4.1 x 10–4 and the Ksp for FeF2 is 3.2 x 19–7. 3. Explain why the Ksp for Fe(OH)3 is 1.2 x 10–36 and the Ksp for Fe(OH)2 is 7.8...
please explain the multiplication rule as it applies to the Rules of Probability in at least...
please explain the multiplication rule as it applies to the Rules of Probability in at least 400 words
Construct NFA of following languages and convert it to equivalent DFA. The set of all binary...
Construct NFA of following languages and convert it to equivalent DFA. The set of all binary strings such that 3th symbol from right end is 0.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT