Write regular expressions

Assignment Help Theory of Computation
Reference no: EM13801462

Question 1- Write regular expressions to capture the following.

(a) Strings in C. These are delimited by double quotes ("), and may not contain newline characters. They may contain double-quote or backslash characters if and only if those characters are "escaped" by a preceding backslash. You may find it helpful to introduce shorthand notation to represent any character that is not a member of a small specified set.

(b) Comments in Pascal. These are delimited by (* and *) or by { and }.

Question 2- Show(as"circles-and-arrows"diagrams)the finite automata for question 1.

Question 3- (a) Show the NFA that results from applying the construction of Figure to the regular expression letter ( letter | digit )*.

2481_figure 2.7.png

(b) Apply the transformation illustrated by Example 2.14 to create an equivalent DFA.

Question 4- (a) Describe in English the language defined by the regular expression a* (b a* b a* )* . Your description should be a high-level characterization-one that would still make sense if we were using a different regular expression for the same language.

(b) Write an unambiguous context-free grammar that generates the same language.

(c) Using your grammar from part (b), give a canonical (rightmost) derivation of the string baabaaabb.

Question 5- Give an example of a grammar that captures right associativity for an exponentiation operator (e.g., ** in Fortran).

Question 6- Consider the following grammar:

G → S $$

S → A M

M → S |ε 

A → a E | b A A

E → a B | b A|ε

B → b E | a B B

(a) Describe in English the language that the grammar generates.

(b) Show a parse tree for the string abaa.

(c) Is the grammar LL(1)? If so, show the parse table; if not, identify a prediction conflict.

Question 7-Consider the following CFG for floating-point constants, without exponential notation. (Note that this exercise is somewhat artificial: the language in question is regular, and would be handled by the scanner of a typical compiler.)

C → digits . digits

digits → digit more_digits

more_digits → digits|ε

digit → 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

Augment this grammar with attribute rules that will accumulate the value of the constant into a val attribute of the root of the parse tree. Your answer should be S-attributed.

Reference no: EM13801462

Questions Cloud

Problems based on the use statistics for inference : Write a 90% confidence interval for the mean daily income this parking garage will generate.
Describe some of the main services of public organization : Create, describe, and explain the type of fictional public organization. Describe some of the main services, products, and activities the organization provides to the public.
What would someone who is a terrorist do : What would someone who is a terrorist do? What would a terrorist refrain from doing? Is there anything you can think of that people who are terrorists would HAVE to do? (If they didn't they wouldn't be terrorists).
Describe how terrorist groups use social media : Describe how terrorist groups use social media. Analyze how future technology trends may help terrorist groups support their agendas.
Write regular expressions : Write regular expressions to capture the following-Strings in C. These are delimited by double quotes ("), and may not contain newline characters. They may contain double-quote or backslash characters if and only if those characters are "escaped" b..
Interval estimate of the population slope issues : At the 0.05 level of significance, is there a significant linear relationship between two variables?
Examine the overall roles of the non-state participants : From the second e-Activity, examine the overall roles of the Non-State participants within a current event that requires a foreign policy on terrorism to be developed. Provide a rationale for your response.
General discussion of online course design and development : General Discussion of Online Course Design and Development
Advances in technology-responsibilities of global : Examine the relationship between advances in technology and the responsibilities of global citizenship. Describe how technology has changed the way in which people pursue knowledge and how they address social concerns.

Reviews

Write a Review

Theory of Computation Questions & Answers

  Question 1 given the productionss-gt sa aaa absa-gt acaa

question 1. given the productions.s-gt sa aaa absa-gt acaa list the parse table. is the grammar ll1 in this form? if

  Find the chomsky normal

Show that if G is a CFG in Chomsky normal form, then for any string w in L(G) of length n >= 1, exactly 2n - 1 steps are required for any derivation of w.

  Construct a dfa for the two simpler languages

Construct a DFA for the two simpler languages, then combine them using the construction discussed in footnote 3 to give the state diagram of a DFA for the language given.

  Write set of token types returned by lexical analyzer

Write down the set of token types to be returned by your lexical analyzer. Describe regular expressions for this set of token types.

  Create a program that reads integers

Create a program that reads integers in range 0 .. 9999. The event stops reading if -99 is entered. Your event should use Stack to store those numbers then it used Priority Queue to print out those numbers in ascending order.

  Write a research paper excluding the title page on logical

write a research paper excluding the title page on logical circular and arithmetic shift operations. use an example not

  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?

  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.

  Write an unambiguous grammar

Write an unambiguous grammar for the given languages- You have to prepare unambiguous grammar for the above languages. Please help! I am stuck on this question

  What is the focal length of the lens

If the speed of the gas relative to the rocket is 40m/s, and the mass of rocket is 4 kg, what is the initial acceleration of the rocket and what is the focal length of the lens when it is completely immersed in water of RI 4/3?

  Show that the grammar is unambiguous

What does it compute? Prove it, showing how you derive the loop invariant - Show that the grammar is unambiguous

  1 discuss which university has the more effective strategyi

1. discuss which university has the more effective strategy?i. provide example of effective hr planning.ii. what are

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