Question

(6 pts.) Using the grammar below: <assign> -> <id> = <expr> <expr> -> <expr> + <term>...

  1. (6 pts.) Using the grammar below:

    <assign> -> <id> = <expr>
    <expr> -> <expr> + <term> | <term>
    <term> -> <term> * <factor> | <factor>
    <factor> -> (<expr>) | <id>
    <id> -> A | B | C

    Show a parse tree, leftmost, and rightmost derivation for each of the following statements:
    1. A = ( A + B ) * C
    2. A = B * (C * (A + B))
  2. (5 pts.) Consider the following grammar:

    <S> -> <A> a <B> b
    <A> -> <A> b | b
    <B> -> a <B> | a

    Which of the following sentences are in the language generated by this grammar?
    1. baab
    2. abbaab
    3. bbbab
    4. bbaaaaa
    5. bbaab
  3. (4 pts.) Compute the weakest precondition for each of the following assignment statements and postconditions:
    1. a = 2 * (a - 1) - 1 {a > 7}
    2. a = b + 2 * b - 1 {a > 2}

Homework Answers

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Ex#5: Given the following grammar for a simple assignment statements. <assign> --> <id> = <expr> <id>...
Ex#5: Given the following grammar for a simple assignment statements. <assign> --> <id> = <expr> <id> --> A | B | C <exp> --> <id> + <expr> | <id> * <expr> | (<expr>) | <id> Show a leftmost derivation and a parse tree of the following statement: A = A *(B + (C * A))
Given the grammar <expr> -> <term> {( + | - ) <term>} <term> -> <factor> {(...
Given the grammar <expr> -> <term> {( + | - ) <term>} <term> -> <factor> {( * | / ) <factor>} <factor> -> <exp> { ** <exp>} <exp> -> (<expr>) | <id> <id> = (A | B | C | D | E) leftmost derivation of A**B + (B * C)
1. Given the Grammar <expr> --> <expr> + <term> | <term> <term> --> <term> * <factor>...
1. Given the Grammar <expr> --> <expr> + <term> | <term> <term> --> <term> * <factor> | <factor> <factor> --> ( <expr> ) | number For the given string 3 * ( 2 + 5 * 6), perform the following: 1. Left-most derivation 2. Draw a parse tree 3. Draw an abstract syntax tree Note: number as a terminal has multiple values
can someone please answer these in the correct format: Assignment #2 Total 43 pts (12pts) List...
can someone please answer these in the correct format: Assignment #2 Total 43 pts (12pts) List at least 3 words in the language and write regular expressions for the following: S = {a,b,c} L = {all words that have only one letter c in them} S = {a,b,c} L = {all words in which c’s appear in groups of two} S = {a,b,c} L = { all words that begin and end with the same letter} S = {a,b,c} L...
Write a Java program that implements a lexical analyzer, lex, a recursive-descent parser, parse, an error...
Write a Java program that implements a lexical analyzer, lex, a recursive-descent parser, parse, an error handling program, error, and a code generator, codegen, for the following EBNF description of a simple assignment statement using an arithmetic expression language. Implement a symbol table by modifying Evaluate class. Modify the stmt() method, Provide an insert() and retrieve() method and store values in symbol table.   Video Help to get started:  https://www.youtube.com/watch?v=-C_S7Lb4kRk&feature=youtu.be import java.io.*; import java.util.*; public class parser { static String inString =...
Question 1 0.5 pts Where should accounts receivable should entered? on the income statement, just below...
Question 1 0.5 pts Where should accounts receivable should entered? on the income statement, just below sales revenues on the balance sheet as a short-term liability on the balance sheet as a long-term asset None of the above are correct. Question 2 0.5 pts Sam purchased a new ice-cream machine for $45,000 for his Frozen Delights store. Which of the following options reflects how his purchase should be recorded? $45,000 expense as part of cost of goods sold on the...
step by step solution for the below question please Flag this Question Question 11 pts What...
step by step solution for the below question please Flag this Question Question 11 pts What is the difference between positive economics and normative economics? Group of answer choices Positive economics deals with dynamic systems, while normative economics focuses on static systems. Normative economics deals with how the world actually works, whereas positive economics focuses on what people ought to do. Positive economics requires making value judgments, while normative economics relies solely on factual statements. Normative economics applies in cases...