Using the grammar in Example 3.2 [p.117]*, draw a parse tree for each of the three following statements: Attach your parse trees as a single jpg or gif file.

computer science

Description

1Question 1

        Using the grammar in Example 3.2 [p.117]*, draw a parse tree for each of the three following statements:

        Attach your parse trees as a single jpg or gif file.

     A = A * (B + (C * A))

     B = C * (A * C + B)

     A = A * (B + (C))

Question 2

        Using the grammar in Example 3.2 [p.117]*, show a sentential form leftmost derivation for each of the three following statements.

        Write your derivation steps in the answer space below:

        Note: These are the same three statements as the previous questions.

     A = A * (B + (C * A))

     B = C * (A * C + B)

     A = A * (B + (C))

Question 3

        Using the grammar in Example 3.4 [p.120]*, draw a parse tree for each of the four following statements:

        Attach your parse trees as a single jpg or gif file.

         

     A = ( A + B ) * C

     A = B + C + A

     A = A * (B + C)

     A = B * (C * (A + B))

Question 4

        Using the grammar in Example 3.4 [p.120]*, show a sentential form leftmost derivation for each of the four following statements.

        Write your derivations in the answer space below:

        Note: These are the same four statements as the previous questions.

         

     A = ( A + B ) * C

     A = B + C + A

     A = A * (B + C)

     A = B * (C * (A + B))

Question 5

        Prove that the following BNF grammar is ambiguous.

        Attach your parse trees as a single jpg or gif file.

        <S> → <A>

        <A> → <A> + <A> | <id>

        <id> → a | b | c

Question 6

        Describe, in English, the language defined by the following grammar:

        SABC

        AaA | a

        BbB | b
CcC | c

Question 7

        Consider the following grammar:

        <S> → <A> a <B> b

        <A> → <A> b | b

        <B> → a <B> | a

        Which of the following strings are in the language generated by this grammar?

 

 

bbaab

 

 

baab

 

 

bbaaaaa

 

 

bbbab

Question 8

        Consider the following grammar:

        S →  aScB | A | b

        A →  cA | c

        B →  d | A

        Which of the following sentences are in the language generated/recognized by this grammar?

 

 

acccbd

 

 

acd

 

 

acccbcc

 

 

accc

 

 

cd

 

 

abcd

Question 9

        Convert the following EBNF rules to BNF:

        SA{bA}

        Aa[b]A

        Note: These rules are an incomplete grammar. You are responsible only for converting the given rules (partial grammar).

Question 10

        Write EBNF descriptions (i.e. rules) for the a Java class definition header statement.

     Begin with the start symbol <class_header>.

     Use the non-terminal <class_name> for the user-defined name of the class

     You do not have to include a LHS rule which defines valid naming conventions to expand the <class_name> non-terminal


Related Questions in computer science category