Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need answers to 2-4 I already have 1 Compiler Theory Ch4 Syntax Analysis 1. Design grammars for the following languages: 1) The set of all

image text in transcribedNeed answers to 2-4 I already have 1
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 Os 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-> XIVJZ 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 a + for union, to avoid conflict with the use of vertical bar as a meta-symbol in grammars: nd b only, using rexpr -rexpr rtern I rterm rterm - rterm rfactor I rfactor rfactor - rfactor I rprimary rprimary >alb 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 grammar. Is the resulting grammar suitable for top-down parsing? d) 4. Repeat above exercise 3 for the following grammars: 1) S->SS+ISS 1a

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

Step: 3

blur-text-image

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

Navigating The Supply Chain Maze A Comprehensive Guide To Optimize Operations And Drive Success

Authors: Michael E Kirshteyn Ph D

1st Edition

B0CPQ2RBYC, 979-8870727585

More Books

Students also viewed these Databases questions