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

CMSC 330 Fall 2007 Homework 2: Grammars and OCaml, Assignments of Programming Languages

Information about homework 2 for the cmsc 330 fall 2007 course, focusing on grammars and ocaml. Students are required to write unambiguous grammars for specific languages, prove ambiguity of a given grammar, and define ocaml functions with specific types. The document also includes instructions for submission and important deadlines.

Typology: Assignments

Pre 2010

Uploaded on 07/29/2009

koofers-user-wvb
koofers-user-wvb 🇺🇸

3

(1)

10 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download CMSC 330 Fall 2007 Homework 2: Grammars and OCaml and more Assignments Programming Languages in PDF only on Docsity! CMSC 330 Fall 2007 Homework 2: Grammars, OCAML Posted on: Saturday, Oct. 20, 2007 Due: Tuesday, Oct. 30 9:20AM, 2007 Homework should be submitted in my office (4115 AVW) BEFORE 9:20AM (slip them under my door if it is closed). Homework will not be accepted after 9:20AM as the homework problems may be reviewed in class that day. No late homework is accepted. Late home- work will receive no credit. Be sure to label the problem you are solving clearly with the problem number and subsection. Typing your homework is not required, but homework should be legible. Illegible solutions will receive no credit. Be sure to put your name on the homework. Remember, you must do this homework on your own, without any external sources. If you are unsure what is allowed, please contact the instructor. 1. Creating Grammars Write unambiguous grammars for the following languages: (a) {anbn|n ≥ 0 and n is odd} (b) All valid OCaml lists created using ::. Make sure your construction correctly shows the right association of this operator. Use v(′a) to indicate a value of type ′a. Examples of valid strings in this language: 1 :: [], [], “hi” :: “there” :: [] (c) All valid OCaml guards for if statements in the abbreviated language containing terminals: (, ), ||, &&, <, >, =. Parenthesis must be appropriately matched with every open- ing left parenthesis followed by a closing right parenthesis. ( and ) have the highest precedence, followed by && and || and the lowest precedence is given to <, >, = etc. Use v(′a) to indicate a value of type of type ′a. Note: You don’t need to worry about type compatibility. Assume that this is done separately. 2. Ambiguity Proofs Prove that the following grammar is ambiguous. Note: In class, we did not construct formal “proofs” for unambiguous grammars; however, for ambiguous grammars, we used example strings and the definition of ambiguity. 1
Docsity logo



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