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

  Argue that the problem is np complete

Argue that the following prob is NP Complete. Given list of positive integers, u1,u2,...un (in binary representation) and asked if there is partition of this set into 3 subsets, each of which has same sum.

  What ambiguity exists in the statement

Suppose f is a function that returns the result of reversing the string of symbols given as its input, and g. What ambiguity exists in the statement x?

  Create a parser to check expression for allowable form

Find out its grammatical structure with respect to given formal grammar. You are needed to create a parser which will check expression for allowable form.

  Question about perfect programming language

I have noticed that there are several languages, is this because no one language has all the main elements needed to be a perfect programming Language?

  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.

  Consider a logic function with three outputs

Consider a logic function with three outputs,  A ,  B , and  C , and three inputs,  D ,  E , and  F . The function is defined as follows:  A  is true if at least one input is true,  B  is true

  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.

  Use undecidability of allcfg to show problem is undecidable

Use undecidability of ALLCFG to illustrate that following problem is also undecidable: Given PDA M1 and FA M2, is L(M1) = L(M2)?

  Design jflap truing machine takes input a tape

Design in JFLAP a Truing machine that takes as input a tape containing a series of n 1s, Where n >= 0, terminated by an = sign.

  Construct a dfa that recognizes languages

Construct a DFA that recognizes each of the following languages. Unless otherwise noted we are assuming that ω ∈ {0,1}*. (A drawing of a state diagram is sufficient.)

  Prove that l is not regular using pumping theorem

Prove that L is not regular. (Be particularly careful if you use the Pumping Theorem. You must choose a w that is actually in L.)

  Design a syntactic analyzer

Design a syntactic analyzer for the language specified by the grammar

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