Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CS200 Fall 2008 Homework 1: Constructing Grammars and Parsing Expressions - Prof. Adele E., Assignments of Computer Science

Instructions for completing homework assignments in a cs200 course during the fall 2008 semester. The assignments involve constructing grammars for java switch statements and bit strings, determining the legality of sentences and expressions, and analyzing the execution of a recursive descent parser. Essential for university students enrolled in the cs200 course during the fall 2008 semester.

Typology: Assignments

Pre 2010

Uploaded on 03/10/2009

koofers-user-sgy-1
koofers-user-sgy-1 🇺🇸

10 documents

1 / 1

Toggle sidebar

Related documents


Partial preview of the text

Download CS200 Fall 2008 Homework 1: Constructing Grammars and Parsing Expressions - Prof. Adele E. and more Assignments Computer Science in PDF only on Docsity! CS200 Fall 2008 HW 1 due 9/9/08 at 9:30AM Hand-in before start of lecture 1. Construct a grammar for the Java switch statement. Use <expr> (which denotes arbitrary Java expressions) as the starting non-terminal. You may also assume that some non-terminals have already been defined (i.e., <var> for variables, <expr>, and non-terminals for legal values of all basic types). [Note: your grammar is not responsible for checking type consistency.] 2. Construct a grammar for any length bit strings (alphabet is {0,1}) that start with 00 and end with one or more 1s. 3. Given the following grammar: <S> = ab<S> | bc<S>| bb<S> | a | cb 1. Is “bcbba” a legal sentence? 2. List all legal sentences of 5 characters or less. 4. Is “+ * 5 – 3 / 2 + + 6 1 – 8 7” a legal prefix expression? If yes, to what does it evaluate? If no, fix it, with as little change as possible, so that it is. 5. For the recursive descent parser provided in class (and on the website), a. will the code conclude that “* + a b – c / a b” is a legal expression? b. show how the execution stack will change as the code runs for the expression “* a + b c”. Every time a method is invoked, show a stack snapshot that includes the name of that method and its argument(s) at the top. [Note: The execution stack keeps track during program execution of what methods have been invoked from where in the code so that the program can return to the calling method when the called method returns.]
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved