DOCX - Department of Computer Science

advertisement
RYERSON UNIVERSITY
DEPARTMENT OF COMPUTER SCIENCE
CPS506 – Comparative Programming Language
Winter 2010
Assignment 1 – Due: Friday January 29, 2010
1- Using two programming languages, of your choice, compare two criteria
or characteristics mentioned in the class in those languages. For each
one, bring examples from each language you have chosen.
2- Give one advantage and one disadvantage for each of the following
language characteristics:
a.
b.
c.
d.
Generality
Aliasing
Type Checking
Binding
i. Early
ii. Late
3- Bring two examples in C to show the lack of Orthogonality in the
language.
4- Using two programming languages, of your choice, discuss about
advantages and disadvantages of compilers and interpreters.
5- There is a feature in C, by which we can define macros to use inside the
program, #define. Show, by two examples, how this feature might cause
troubles, such as side effect, and wrong computation.
6- Name one important characteristic or feature of each of the following
application domains, and explain how an appropriate programming
language paradigm could address this feature.
1
a.
b.
c.
d.
e.
Scientific
Artificial Intelligence
Systems
Information Management Systems
Web-centric
7- Using the simple BNF in page 12 and example in page 13 of the second
lecture note file first convert that BNF to EBNF and then write the
derivation and parse tree of the following expression.
x + (y * 1) / (z – w – v)
8- Using the examples in pages 20 and 21, write a Java class for abstract
syntax of the following abstract syntax.
Binary = Operator op ; Expression term1, term2;
9- Using the examples in pages 20 and 21 and above syntax for Binary
expression, draw the abstract syntax tree of the following Assignment
Expression.
x=y+1
10- By an example, show that the following BNF is ambiguous. Show at
least two different parse trees of your example using the BNF.
<exp>  <exp> <op> <exp> | <term>
<term>  <id>
<op>  + | -
2
Download