Assessment 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

CD Repeat Lab Assessment 1

NOTE : Write Roll No, Name, Regn No in the answer sheet.

Duration 1 hour for write-up and 30 mins for uploading.

Class ‘B‘ has


 One attribute named ‘s’ of type string is initialized.
 Two methods
o ‘g’ which takes ‘y‘ as argument which is of type “string“ and has return type “int“
o ‘f‘ which takes ‘x‘ as argument which is integer type and returns an integer
Write the entire lexical analyzer with symbol table.
Write code for displaying list of tokens in token structure and symbol table entries for all identifiers.
Symbol table has following columns
class B { Serial Lexeme Type Arguments rtype
s : String <- "Hello"; number Name
g (y:String) : Int { ### g Method id,# int
y.concat(s) …
};
--Any characters between two dashes “--” and
--the next newline are treated as comments.
f (x:Int) : Int {
x+1
};
};

Write the getnexttoken() to recognize all lexemes. Wite insert(), search() and display() functions for
symbol table.

You might also like