Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Compiler Theory Ch4 Syntax Analysis 1. Design grammars for the following languages: 1) The set of all strings of Os and 1s such that every

image text in transcribed
Compiler Theory Ch4 Syntax Analysis 1. Design grammars for the following languages: 1) The set of all strings of Os and 1s such that every 1 is immediately followed by at least one 0. 2) The set of all strings of Os and 1s that are palindromes; that is, the string reads the same backward as forward 3) The set of all strings of 0s and 1s with an equal number of Os and 1s. 4) The set of all strings of Os and 1s with an unequal number of Os and 1s. 5) The set of all strings of Os and 1s in which 011 does not appear as a substring. 2. Square braces around a grammar symbol or symbols denotes that these constructs are optional. Thus, production A->XIYJZ has the same effect as the two productions A-> XYZ and A->XZ Now, use the braces described above to simplify the following grammar for statement blocks and conditional statements: stmt -if expr then stmt else stmt if expr then stmt begin stmtlist end stmtlist - stmt; stmtList | stmt 3. The following is a grammar for regular expressions over symbols a and b only, using + for union, to avoid conflict with the use of vertical bar as a meta-symbol in grammars: rexpr rexprrterm I rterm rterm - rterm rfactor | rfactor rfactor - rfactorI rprimary rprimary - b a) Left factor this grammar b) Does left factoring make the grammar suitable for top-down parsing? c) In addition to left factoring, eliminate left recursion from the original gramma d) Is the resulting grammar suitable for top-down parsing? Repeat above exercise 3 for the following grammars

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics Of A Networked World Semantics For Grid Databases First International Ifip Conference Icsnw 2004 Paris France June 2004 Revised Selected Papers Lncs 3226

Authors: Mokrane Bouzeghoub ,Carole Goble ,Vipul Kashyap ,Stefano Spaccapietra

2004 Edition

3540236090, 978-3540236092

More Books

Students also viewed these Databases questions

Question

What do you think of the MBO program developed by Drucker?

Answered: 1 week ago