0% found this document useful (0 votes)
36 views2 pages

Sci: Csc326: Assignment 1 Due 1 March 2013: Tokenco de Tokenid Tokenlex

This document outlines an assignment to analyze and develop grammars for a hypothetical programming language. Students are asked to: 1) Develop a Context Free Grammar (CFG) to define the language of the Function construct in the language. 2) Develop a left linear regular grammar to define the language, modifying it slightly if needed. 3) Develop a lexical analyzer (scanner) to tokenize the symbols and constructs in a Function.

Uploaded by

johnzipper
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Sci: Csc326: Assignment 1 Due 1 March 2013: Tokenco de Tokenid Tokenlex

This document outlines an assignment to analyze and develop grammars for a hypothetical programming language. Students are asked to: 1) Develop a Context Free Grammar (CFG) to define the language of the Function construct in the language. 2) Develop a left linear regular grammar to define the language, modifying it slightly if needed. 3) Develop a lexical analyzer (scanner) to tokenize the symbols and constructs in a Function.

Uploaded by

johnzipper
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

SCI: CSC326: Assignment 1

Due 1 march 2013

In some hypothetical programming language a Function assumes the following form:

Identifier ( ) { Statement; Statement; . ; Statement };

A statement can assume any of the following two possible forms: if (Expr Lop Expr) then { assignmentStatement; assignmentStatement; } if (Expr Lop Expr) then { AssignStatement; AssignStatement; } else { AssignStatement; AssignStatement; } Identifier = Expr

Lop is a logical operator such as:

==, <, <=, >=, >

An Identifier: a string of lower-case letters. Expr is an algebraic expression such as: Identifier /( Identifier - Identifier ) Identifier - Identifier * Identifier +

AssignStatement: Identifier = AlgebraicExpression

The following is example of the (suggested) tokens of the language tokenCo de 1001 1002 tokenID ifTok Lparen tokenLex if (

1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016

Rparen equalsTok gtTok ltTok thenTok lBrace rBrace semicTok assignTok elseTok plusTok minusTok multTok divTok geTok leTok idTok

) == > < then { } ; = else + * / >= <= a string of lower-case letters

a) Develop a CFG grammar for the language of Function b) Develop a left linear regular grammar for the language (if not possible, you may modify the language slightly to make it possible). c) Develop a scanner (lexical analyzer) for a Function.

You might also like