Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Assignment 01

Compiler Construction CS-305


Due Date: Thursday, 13th April, 2023.

Question # 1:

Compare the speed of execution of computer program in various languages to which you
have access.

Question # 2:

Try to find out which of the compilers you have used are single-pass, and which are multi-
pass, and for the latter, find out how many passes are involved. Which produce relocatable
code needing further processing by linkers or linkage editors?

Question # 3:

Identify the lexemes that make up the tokens in the following program. Give
reasonable attribute values for the tokens.

int max ( i , j ) int i , j;


/*return maximum of integers i and j */
{
return i > j ? i: j;
}

Question # 4:
Write regular definitions for the following languages:
a) All strings of letters that contain the five vowels in order.
b) Comments consisting of a string surrounded by /* and */ without an intervening */
unless it appears inside the quotes “and”.
c) All strings of digits with at most one repeated digit
d) All formats of integer constant used in C language

Question # 5: Java Integer Literals


This is the definition of Java integer literals taken literally from the language
reference manual. Some additions have been added in brackets:

Write down RE and Draw TD:

An integer literal may be expressed in decimal (base 10), hexadecimal (base16), or


octal (base 8). An integer literal [decimal, hexadecimal or octal] is of type long if it
is suffixed with an ASCII letter L or l (ell); otherwise it is of type int. The suffix L is
preferred, because the letter l (ell) is often hard to distinguish from the digit 1.

A decimal numeral is either the single ASCII character 0, representing the integer
zero, or consists of an ASCII digit from 1 to 9, optionally followed by one or more
ASCII digits from 0 to 9, representing a positive integer.

A hexadecimal numeral consists of the leading ASCII characters 0x or 0X followed


by one or more ASCII hexadecimal digits and can represent a positive, zero, or
negative integer. Hexadecimal digits with values 10 through 15 are represented by
the ASCII letters a through f or A through F, respectively; each letter used as a
hexadecimal digit may be uppercase or lowercase.

An octal numeral consists of an ASCII digit 0 followed by one or more of the ASCII
digits 0 through 7 and can represent a positive, zero, or negative integer. Note that
octal numerals are always consist of two or more digits; 0 is always considered to be
a decimal numeral—not that it matters much in practice, for the numerals 0,00, and
0x0 all represent exactly the same integer value.

Examples of int literals: 0 2 0372 0xDadaCafe 1996 0x00FF00FF


Examples of long literals: 0l 0777L 0x100000000L 2147483648L 0xC0B0L

NOTE: Write your full name and section on the top right corner of the first page.
Missing any of the above instructions will cost 1 mark.
Only hand written assignments will be accepted (no printed assignments).
Do the assignments individually, copied assignments will get Zero.
2 Mark will be deducted each day on late submissions.

You might also like