Compiler design problem

Assignment Help Theory of Computation
Reference no: EM13336574

Compiler Design

Q1. Sometimes it is necessary to modify the syntax of a programming language. This is done by changing the CFG that the language uses. What changes would have to be made to ac's CFG (Figure) to implement the following changes?

29_Compiler Design.png

(a) All ac programs must contain at least one statement.
(b) All integer declarations must precede all float declarations.
(c) The first statement in any ac program must be an assignment statement.

Q2. Extend the ac scanner (Figure) in the following ways:

801_Compiler Design1.png

(a) A floatdcl can be represented as either f or float, allowing a more Java-like syntax for declarations.
(b) A intdcl can be represented as eitheri or int.
(c) A num may be entered in exponential (scientific) form. That is, an ac num may be suffixed with an optionally signed exponent (1.0e10, 123e-22 or 0.31415926535e1).

Q3. Figure scans an input stream for an inum or fnum based on the regular expressions for those patterns shown in Figure. The code in Figure does not check for errors.

465_Compiler Design2.png

(a) Where could errors occur in Figure?
(b) For each error, what action would you take should the error occur?

Reference no: EM13336574

Questions Cloud

Compare and contrast giotto arena chapel to duccio maest : Compare and contrast Giotto's Arena Chapel to Duccio's Maestà
Modify the syntax of a programming language : Sometimes it is necessary to modify the syntax of a programming language. This is done by changing the CFG that the language uses. What changes would have to be made to ac's CFG (Figure) to implement the following changes?
Briefly explain the aries recovery algorithm : Briefly explain the ARIES recovery algorithm, including the main phases, main principles and key ideas behind the algorithm such as WAL protocol and checkpointing etc.
How many revolutions does the drum make during the fall : You are the technical consultant for an action-adventure film in which a stunt calls for the hero to drop off a 23.7-m tall building and land on the ground safely at a final vertical speed of 3.85 m/s. How many revolutions does the drum make during..
Compiler design problem : This is done by changing the CFG that the language uses and what changes would have to be made to ac's CFG
Identify a relational algebra tree : Identify a relational algebra tree (or a relational algebra expression if you prefer) that reflects the order of operations a decent query optimizer would choose.
Compute the magnitude of the magnetic flux through the loop : A solenoid with 1200 turns per meter has a diameter of 9.00 cm. A current I = 2.57 A flows in the clockwise direction, Find the magnitude of the magnetic flux through the loop
What is the cost of joining r and s using a sort-merge join : What is the cost of joining R and S using a page-oriented simple nested loops join? What is the minimum number of buffer pages required for this cost to remain unchanged?
What is the total i/o cost for sorting this file : How many sorted subfiles will there be after the initial pass of the sort, and how long will each subfile be?

Reviews

Write a Review

Theory of Computation Questions & Answers

  Create a mealy machine which produces the output

Create a Mealy Machine which produces the output of 1 whenever discrepancy in above pattern is detected, and produces the output of 0 otherwise. Write states meaningful names.

  Create mealy type state machine with input and output

Create the Mealy type state machine with input X and output Y. Y must be 1 whenever sequence 110 or 101 has been detected on X on last 3 consecutive rising clock edges.

  How to construct an nfa

Give a construction that assumes you are given a DFA for L and show how to construct an NFA (with or without ε-moves) to recognize sort(L).

  Rice-s theorem for enumerable or non-re

We know by rice's theorem that none of the following problems are decidable. However,are they recursively enumerable,or non-RE? IS L(M) infinite?

  Ssb has an advantage over am

SSB has an advantage over AM with respect to efficiency and power gain. Why, then, is AM commercial broadcast being replaced with SSB transmission?

  Create and dfa or lr items for grammar

Create and DFA or LR(0) items for this grammar. Is this grammar LR(0) parsing table? If not, explain LR(0) conflict. If so create LR(0) parsing table.

  Create standard 1-tape turing machine to calculate function

Create a standard 1-tape Turing machine M to calculate the function sub3. Specifically, calculate sub3 of a natural number represented in binary.

  Write algorithm for finding useless-productive nonterminals

Write down the algorithm for finding useless/productive nonterminals. Describe how this gives you the algorithm for whether language generated by grammar is empty.

  Design unambiguous grammar to parse expressions

Write a program would read two numbers and then print all numbers between the first and the second, inclusive. Design unambiguous grammar to parse expressions

  Write grammar for language consisting of strings

Write a grammar for the language consisting of strings that have n copies of the letter a followed by same number of copies of the letter b, where n>0

  Write problems which have no solutions

What does the term solvable mean to you? What does it mean to say that "you solved a problem"? Determine examples of problems for which you believe there are no solutions.

  Why every nonempty propositional clause itself satisfiable

Describe why every nonempty propositional clause, by itself, is satisfiable. Prove rigorously that every set of five 3-SAT clause is satisfiable, given that each clause mentions exactly three distinct variables.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd