Question

10. Draw and decorate the parse tree for the following Attribute Grammar for the following statement:...

10. Draw and decorate the parse tree for the following Attribute Grammar for the following

statement:

word = 2.0 ∗ (5 − 10)

*** Assign is your STARTING SYMBOL

Assign =: identifier = Expr

Expr =: Expr + Term | Expr - Term | Term

Term =: Term * Factor | Term / Factor | Factor

Factor =: "(" Expr ")" | integer | float | identifier

Assign =: identifier = Expr [ identifier.value <= Expr.value ]

Assign =: identifier = Expr [ identifier.actual_type ==> Expr.expected_type ]

Expr1 =: Expr2 + Term [ Expr1.value = Expr2.value * Term.value ]

Expr1 =: Expr2 + Term [ Expr1.type <==

if (Expr2.type == Term.type == integer) then integer else float ]

Expr1 =: Expr2 - Term [ Expr1.value = Expr2.value + Term.value ]

Expr1 =: Expr2 - Term [ Expr1.type <==

if (Expr2.type == Term.type == integer) then integer else float ]

Expr =: Term [ Expr.value = Term.value ]

Expr =: Term [ Expr.type = Term.type ]

Term1 =: Term2 * Factor [ Term1.value = Term2.value / Factor.value ]

Term1 =: Term2 * Factor [ Term1.type <==

if (Term2.type == Factor.type == integer) - then integer else float ]

Term1 =: Term2 / Factor [ Term1.value = Term2.value Factor.value ]

Term1 =: Term2 / Factor [ Term1.type <==

if (Term2.type == Factor.type == integer) then integer else float ]

Term =: Factor [ Term.value = Factor.value ]

Term =: Factor [ Term.type = Factor.type ]

Factor =: "(" Expr ")" [ Factor.value = Expr.value ]

Factor =: integer [ Factor.value = strToInt(integer.str) ]

Factor =: float [ Factor.value = strToFloat(float.str) ]

Factor =: identifier [ Factor.value = VARMAP(identifier.str) ]

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))
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that will provide the same function. Char grade; String tstmsg; if (grade == ‘A’) {   tstmsg = “Excellent”; } else if (grade == ‘B’) {   tstmsg = “Good”; } else if (grade == ‘C’) {   tstmsg = “OK”; } else {   tstmsg = “Study More”; } 2.Write the following for statement as a while statement. for (k = 0; k < 3; k++) {   System.out.println...
4. The _____ case is performed by the switch statement if a match is not found...
4. The _____ case is performed by the switch statement if a match is not found default first second otherwise Answer: 5. When three relational expressions are joined by OR (||) operators, there must be at least _____ of the relational expressions that evaluate to true for the logical expression to evaluate to true. one two three none of the relational expressions evaluate to true Answer: 6. Which of the following items is an acceptable first character in a Java...
1) Consider the following Java program. Which statement updates the appearance of a button? import java.awt.event.*;...
1) Consider the following Java program. Which statement updates the appearance of a button? import java.awt.event.*; import javax.swing.*; public class Clicker extends JFrame implements ActionListener {     int count;     JButton button;     Clicker() {         super("Click Me");         button = new JButton(String.valueOf(count));         add(button);         button.addActionListener(this);         setSize(200,100);         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         setVisible(true);     }     public void actionPerformed(ActionEvent e) {         count++;         button.setText(String.valueOf(count));     }     public static void main(String[] args) { new Clicker(); } } a. add(button);...
Forecasting and Estimating Share Value Using the DCF Model Following are the income statement and balance...
Forecasting and Estimating Share Value Using the DCF Model Following are the income statement and balance sheet for Intel Corporation. INTEL CORPORATION Consolidated Statements of Income Year Ended (In millions) Dec. 25, 2010 Dec. 26, 2009 Dec. 27, 2008 Net revenue $ 43,623 $ 35,127 $ 37,586 Cost of sales 15,132 15,566 16,742 Gross margin 28,491 19,561 20,844 Research and development 6,576 5,653 5,722 Marketing, general and administrative 6,309 7,931 5,452 Restructuring and asset impairment charges -- 231 710 Amortization...
Following are the income statement and balance sheet for Cisco Sytems for the year ended July...
Following are the income statement and balance sheet for Cisco Sytems for the year ended July 30, 2016. Cisco Sytems Consolidated Statements of Income Years Ended December ($ millions) July 30, 2016 July 25, 2015 Revenue Product $37,254 $37,750 Service 11,993 11,411 Total revenue 49,247 49,161 Cost of sales Product 14,161 15,377 Service 4,126 4,103 Total cost of sales 18,287 19,480 Gross margin 30,960 29,681 Operating expenses Research and development 6,296 6,207 Sales and marketing 9,619 9,821 General and administrative...
Following are the income statement and balance sheet for Cisco Sytems for the year ended July...
Following are the income statement and balance sheet for Cisco Sytems for the year ended July 30, 2016. Cisco Sytems Consolidated Statements of Income Years Ended December ($ millions) July 30, 2016 July 25, 2015 Revenue Product $37,254 $37,750 Service 11,993 11,411 Total revenue 49,247 49,161 Cost of sales Product 14,161 15,377 Service 4,126 4,103 Total cost of sales 18,287 19,480 Gross margin 30,960 29,681 Operating expenses Research and development 6,296 6,207 Sales and marketing 9,619 9,821 General and administrative...
  The following balance sheet and income statement should be used for questions #1 through #6: Kuipers,...
  The following balance sheet and income statement should be used for questions #1 through #6: Kuipers, Inc. 2001 Income Statement (OMR in millions) Net sales 9,625 Less: Cost of goods sold 5,225 Less: Depreciation 1,890 Earnings before interest and taxes 2,510 Less: Interest paid 850 Taxable income 1,660 Less: Taxes 581 Net income 1,079 Addition to retained earnings 679 Dividends paid 400 Kuipers, Inc. 12/31/00 and 12/31/01 Balance Sheet (in OMR, in millions) 2000 2001 2000 2001 Cash 1,455 260...
Which of the following best describes a project management plan? The project charter, WBS, and project...
Which of the following best describes a project management plan? The project charter, WBS, and project scope statement The schedule, management plans, and budget A formal, approved document used to control the project The project manager's plan for managing and controlling the work The engineering department wants the project objective to be a 10 percent improvement in throughput. The information technology department wants no more than 5 percent of its resources to be used on the project. Management, who is...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT