

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Due Tuesday, February 3, 2009
Consider the following extended BNF grammar for a subset of the Fortress programming language, called MicroFortress.
program ::= component component-identifier [ import MicroList.{ ... } ] export Executable { function-declaration } run-declaration end function-declaration ::= function-identifier ( [ typed-var {, typed-var } ] ) : type = function-do-expression run-declaration ::= run ( args : String ... ) = do-expression typed-var ::= variable-identifier : type type ::= Int | List[\Int] function-do-expression ::= do block-elems ( add-expr ) end do-expression ::= do block-elems end block-elems ::= block-elem { block-elem } block-elem ::= local-var-decl | expression expression ::= do-expression | variable-identifier := ( add-expr ) | if comparison then block-elems [else block-elems] end | while comparison do-expression | println ( add-expr ) local-var-decl ::= var typed-var comparison ::= add-expr comp-operator add-expr | isEmpty ( primary ) comp-operator ::= < | > | = | >= | <= |! = add-expr ::= mult-expr { add-operator mult-expr } add-operator ::= + | − mult-expr ::= primary { mult-operator primary } mult-operator ::= ǫ | / primary ::= variable-identifier | integer | ( add-expr ) | function-identifier ( [ add-expr-list ] ) | list-expr | cons ( add-expr , primary ) | head ( primary ) | tail ( primary ) list-expr ::= < | [ add-expr-list ] | > add-expr-list ::= add-expr {, add-expr }
Syntactic and Semantic Conventions The keywords and the token symbols in MicroFortress are in bold. Note that MicroFortress has symbols { and }, which are distinguished from grammar metasymbols { and }, respectively, by underlining. MicroFortress also has symbol combinations [, ], < |, and | > which should be treated as individual tokens. A MicroFortress identifier consists of 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 A45Asm3 are valid bare names, but 6gh, two bad, and no end are not. integer is an unsigned integer. MicroFortress comments are indicated by being preceded by (*) and terminated by the end of the line.
Suggestions: