
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Programming Languages; Subject: Computer Science; University: University of Alabama - Birmingham; Term: Spring 2005;
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Due Thursday, January 20, 2005
Consider the following extended BNF grammar for a subset of the Haskell functional programming language, called MicroHaskell.
program ::= dec-list exp ::= Boolean-exp | let dec-list in exp | if ( Boolean-exp ) then ( exp ) else ( exp ) atomic-exp ::= integer | ( exp ) | identifier {parameter-exp} parameter-exp ::= integer | ( exp ) | identifier dec-list ::= dec { dec } dec ::= identifier = exp | identifier argument-list = exp argument-list ::= identifier {identifier} Boolean-exp ::= relational-exp {Boolean-operator relational-exp} Boolean-operator ::= && | || relational-exp ::= list-exp [relational-operator list-exp] relational-operator ::= == | / = | < | <= | > | >= list-exp ::= primary-exp : list-exp | tail atomic-exp | [ ] | primary-exp primary-exp ::= term {adding-operator term} adding-operator ::= + | − term ::= factor {multiplying-operator factor} multiplying-operator ::= * | / factor ::= [head] atomic-exp
Syntactic and Semantic Conventions
The keywords and the token symbols in MicroHaskell are in bold. Note that all operators are left associative except for : which is right associative. Assume that an identifier can only contain letters (only alphabetic characters), digits, and underscores ( ) with the restrictions that it must begin with a letter, cannot end with an underscore and cannot have two consecutive underscores. For example, give 2 Joe, tell me and A45Asm are valid identifiers, but 6gh, two bad, and no end are not. integer is an unsigned integer. Keywords are reserved and hence cannot be used as identifiers. Comments are indicated by being enclosed in {- and - }, possibly spanning multiple lines.
Suggestions: