Sl. No. | Roll No. | Name |
1. | 02CS1009 | SHAMEEK BAIN KOLKATA/NEHRU |
2. | 03CS3006 | PAWAN SINGH FAUJADAR BEH/AZAD |
3. | 03CS3012 | SHAH RUSHIN NAVNEET AH/RP |
4. | 03CS1033 | SANDEEP BANDELA KAKI/ PATEL |
5. | 03CS1005 | NEERAJ NAGI RAJ/ AZ |
6. | 03CS1001 | S TEJASWAI UPPULURI AP/ LLR |
7. | 03CS3007 | ARIJIT GHOSH KOL/PATEL |
8. | 03CS1016 | HARI KRISHNA VEMURI VIJAYAWADA/ RP |
9. | 03CS1037 | ANEESH JAIN ND/ AZ |
10. | 03CS3009 | ARPIT JAIN JAIPUR/RP |
11. | 02CS1022 | SAMIRSATPATHY SAMBALPUR/PATEL |
Lectures : Mon - 4, Tue - 1,2, Thu -3 Room # : CSE 107 Units : 4-0-2 Credits : 4 (Theory) Instructor : Niloy Ganguly Contact : Room #313 (CSE), Phone 3460 Text Books: [1] Aho, A. V., Sethi, R. and Ullman, J. D. Compilers - Principles, Techniques and Tools Addison-Wesley, 1988 (Indian reprint) - aka Dragon book [2] Santanu Chattopadhyay Compiler Design PHI, 2005.
1. Write the regular expression for variable names. Assume that the variable name can start with alphabets or underscore and can also have digits but _____ is not a variable. (First 2 correct submissions accepted)
2. Write the regular expression to represent an ip address. (First 5 correct submissions accepted)
3. Given |r| the length of the regular expression, and |x| is the length of the input string write down the time and space complexity to test whether the string belongs to the regular expression or not by an (a) NFA and (b) DFA. (First 7 correct submissions accepted)
4. Show the two trees produced by the grammar S-> aSbS | bSaS | epsilon. (First 10 correct submissions accepted)
5. Given the grammar
E -> T E'
E' -> + T E' | epsilon
T -> F T'
T' -> * F T' | epsilon
F -> (exp) | id
Construct for Recursive Predictive Parsing, minimum state transition
diagram for the rules
T -> F T'
T' -> * F T' | epsilon
(First 10 correct submissions accepted)
6. Write down the CFG to detect the following. (a). occurence of balanced parentheses (b). strings over alphabet {a,b} such that every 'a' is followed by a 'b'. (First 10 correct submissions accepted)
7. Given the grammar
S -> iEtSS' | a
S'-> eS
E -> b.
Prepare the first and follow list and the LL(1) parsing table.
(First 20 correct submissions accepted)
8. Given the grammar
S -> A
A -> T | A + T | A - T
T -> F | T * F | T / F
F -> P | P ^ F
P -> id | (A)
Prepare the operator precedence table.
(First 23 correct submissions accepted)
1. Consider the grammar
S -> A S | b
A -> S A | a
a. Show that the grammar is ambiguous
b. Construct the corresponding SLR parsing table
c. Construct the corresponding LR(1) parsing table
d. Construct the corresponding LALR parsing table
Opening date - 28.09.2005, Closing Date - 6.10.2005
Persons to submit - 03CS1019, 03CS1025, 03CS3007
2. Consider the grammar
S -> AaAb
S -> BbBa
A -> epsilon
B -> epsilon
Show that the grammar is not SLR
Opening Date - 28.09.2005, Closing Date - 6.10.2005
Persons to submit - 03CS1006, 03CS1013, 03CS1027
Sl. No. | Roll No. | Name | MA | A | CT | AT | Ex | MS | ES | Tot | Grade | ||
1. | 03CS1001 | S TEJASWAI UPPULURI AP/ LLR | 4(8) | ||||||||||
2. | 03CS1002 | SAURABH AGARWAL CAL/ RP | 4(7) | 4 | |||||||||
3. | 03CS1003 | SHAUNAK CHATTERJEE CAL/ RK | 4(8) | 4 | |||||||||
4. | 03CS1004 | HARISH DAIYA RAJ/ RP | |||||||||||
5. | 03CS1005 | NEERAJ NAGI RAJ/ AZ | 0 | ||||||||||
6. | 03CS1006 | HENAL AGRAWAL GUJ/ AZ | |||||||||||
7. | 03CS1007 | VENUGOPAL KASTURI AP/ PATEL | 4(4) | 4 | 1(7) | ||||||||
8. | 03CS1008 | PARANG SARAF RAJGHAT/ RK | 4(5) | ||||||||||
9. | 03CS1010 | SHRAVYA REDDY KONDA AP/ | 4(8) | ||||||||||
10. | 03CS1011 | ARCHISMAN DAS ROUR/ RK | 4(5) | 4 | |||||||||
11. | 03CS1012 | GM RAVI SASTRY VIS/ NEHRU | 4(8) | 4 | |||||||||
12. | 03CS1013 | KUNAL SILKU LUCKNOW/ RP | 4(6) | ||||||||||
13. | 03CS1014 | PUSHKAR PRASAD BOMBAY/ RK | 4(5) | 4 | |||||||||
14. | 03CS1015 | SURESH SHARMA BIKANER/ NEHRU | 4(4) | 3(6,7,8) | |||||||||
15. | 03CS1016 | HARI KRISHNA VEMURI VIJAYAWADA/ RP | |||||||||||
16. | 03CS1017 | DEBAPRIYA CHATTERJEE KOLKATA/ RK | 4(8) | 4 | |||||||||
17. | 03CS1018 | SANJIB KUMAR DAS DHANBAD/ RP | 4(5) | 4 | |||||||||
18. | 03CS1019 | VIRENDRA SINGH SHEKHAWAT JAIPUR/ LLR | 4(6) | 4 | 1(7) | ||||||||
19. | 03CS1020 | ADITYA AWASTHI INDORE/ RP | 4(6) | ||||||||||
20. | 03CS1021 | PADURU NAGENDER REDDY AP/ RK | 4(3) | 4 | 1(7) | ||||||||
21. | 03CS1023 | KAPIL GUPTA KANPUR/ RP | 4(1) | 4 | 4(3,4,7,8) | ||||||||
22. | 03CS1024 | PIPPARI SURESH CHANDRA HYDERABAD/ LLR | 4(3) | 3(5,6,7) | |||||||||
23 | 03CS1025 | NITIN D MEHTA JODHPUR/ RK | 4(8) | 4 | |||||||||
24. | 03CS1026 | RAMJI NAGARIYA JHANSI/AZAD | 4(2) | ||||||||||
25. | 03CS1027 | SANDEEP KUMAR MISHRA RCHI/RK | 4 | ||||||||||
26. | 03CS1028 | NEERAJ MEENA JAIPUR/ NEHRU | 4(8) | 4 | |||||||||
27. | 03CS1031 | BABU PURAN KALAPALA VIS/ LLR | |||||||||||
28. | 03CS1032 | ARITRA SAHA CAL/ NEHRU | 4(6) | 2 | |||||||||
29. | 03CS1033 | SANDEEP BANDELA KAKI/ PATEL | 0 | ||||||||||
30. | 03CS1034 | ROHIT SINGHAL JAM/ RP | 4(1) | 4 | 3(5,7,8) | ||||||||
31. | 03CS1035 | SOURISH CHAUDHURI CAL/ NEHRU | 4(4) | 4 | 1(7) | ||||||||
32. | 03CS1036 | KUMAR DEEPAK DEO/ AZ | 4(2) | 4 | |||||||||
33. | 03CS1037 | ANEESH JAIN ND/ AZ | 4(2) | 1(8) | |||||||||
DUAL DEGREE | |||||||||||||
Sl. No. | Roll No. | Name | |||||||||||
1. | 03CS3003 | PIYUSH GOEL ND/RK | 4(5) | 4 | 1(7) | ||||||||
2. | 03CS3004 | DIGVIJAY SINGH ND/RK | 4(3) | 2(4,5) | |||||||||
3. | 03CS3005 | UMANG JAIN NEVEDA/PATEL | 4(4) | 4 | 2(5,7) | ||||||||
4. | 03CS3006 | PAWAN SINGH FAUJADAR BEH/AZAD | 0 | ||||||||||
5. | 03CS3007 | ARIJIT GHOSH KOL/PATEL | 3 | ||||||||||
6. | 03CS3008 | MUKESH AGRAWAL PATNA/AZAD | 4(2) | 4 | 2(7,8) | ||||||||
7. | 03CS3009 | ARPIT JAIN JAIPUR/RP | |||||||||||
8. | 03CS3010 | MAYANK JAIN /RK | 4(2) | 2 (7,8) | |||||||||
9. | 03CS3011 | UDIT SAJJANHAR MEERUT/RK | 4(8) | ||||||||||
10. | 03CS3012 | SHAH RUSHIN NAVNEET AH/RP | 4(8) | 0 | |||||||||
11. | 03CS3013 | MUNEISH KUMAR ADYA SIMLA/LLR | |||||||||||
12. | 03CS3014 | AMAR KUMAR DANI KOL/PATEL | 4(5) | 4 | 2(7,8) | ||||||||
13. | 03CS3015 | NITIN BANSAL FARI/RK | 4(5) | 4 | 1(6) | ||||||||
14. | 03CS3016 | HEMA SWETHA KOPPULA VIS/IG | 4(5) | 1(7) | |||||||||
15. | 03CS3018 | DIPAK KUMAR BEHERA BHU/NEHRU | 4(4) | 4 | 3(6,7,8) | ||||||||
16. | 03CS3019 | PRAMOD KUMAR GIRIDIH/LLR | 4 | ||||||||||
17. | 03CS3020 | BHABEN DEORI /LLR | 4(8) | 4 | |||||||||
18. | 03CS3021 | JOY DEEP NATH INDORE/RK | 4(4) | 4 | 2(7,8) | ||||||||
19. | 03CS3022 | TATHAGATA DAS KOL/AZAD | 4(3) | 2 + 1(8) | |||||||||
20. | 03CS3023 | SANKALP AGARWAL JAIPUR/AZAD | 4(8) | ||||||||||
21. | 03CS3024 | PANKAJ JAJOO KOTA/NEHRU | 4(3) | 3(6,7,8) | |||||||||
22. | 03CS3025 | KUMAR PUSPESH PATNA/NEHRU | 4(3) | 2(6,7) | |||||||||
FOURTH YEAR (2002 BATCH) | |||||||||||||
Sl. No. | Roll No. | Name | |||||||||||
1 | 02CS1009 | SHAMEEK BAIN KOLKATA/NEHRU | 0 | ||||||||||
2 | 02CS1010 | HRISHIKESH BHATTACHARYA KOLKATA/RP | 4(8) | 1 | |||||||||
3 | 02CS1022 | SAMIRSATPATHY SAMBALPUR/PATEL | 4(4) | 1(8) |
You have to implement the following two algorithms
For constructing a lexical analyzer/scanner from a given set of regular expression. The input alphabet may be specified by the user. It should be possible to encode each symbol of the alphabet as a printable ascii character.
(A) | NFA construction | 15 |
(B) | NFA ouput in proper format | 5 |
(C) | Subset construction | 20 |
(D) | DFA ouput in proper format | 5 |
Total marks | 45 |
* Evaluation of items (B) and (D) will be done in the lab. Please be present on 12/09/2005 to show your code.
* The overall working of the code will be evaluated based on test cases.
Construct a simple C-like language with
main() { INT i=0; INT sum=0; INT count; read(count); for(i=0;i<10;i++) { read(x); sum+=x; } print(sum); }
You have to implement a Lexical Analyzer/Scanner for the simple C-like programming language using 'lex' tools.
Take a file as input (You can test it on the above example file).
Output the tokens along with:
Use the variable yyval to accomplish this.
Lex token specification | 15 |
Use of lex variables | 5 |
Total marks | 20 |
* Evaluation will be done on test cases.
Assignment 3: LL(1) Parser
You have to write a CFG for Simple-C programming language, and implement a table-driven LL(1) parser.
Given
Reuse
TO BE DONE - with paper and pencil
TO BE DONE - programming assignment
Input for this assignment
The input will be Simple-C programs, which may be wrong or correct syntactically and semantically. You will have to output both syntax and semantic errors in the Input.
Example Input Programs
Example 1: Correct Simple-C Program int main() { int fn1 = 1; int fn2 = 1 ; int i=0; int n; int fn=0; read(n); if(n < 1) print(0); else { while(i < n) { fn = fn1 + fn2; print(fn); fn2 = fn1; fn1 = fn; i++; } } } The above program should be accepted by the parser. Example 2: Wrong Simple-C Program int main() { int r; int p /* Syntactic error here, missing semicolon */ int int j; /* Parse error here, keyword int occurs two times */ int total=0; int i; read(r); read(p); scanf (j; /* unrecognized token here: scanf and mismatched parentheses*/ for(i = r; i < p; i+= j) total = total + j; print(total); }
Output Expected
If input is wrong, i.e the parser was not able to parse the input or lexer was not able to recognize a token, then the output along with diagnosed reasons should be presented to the user.
Sample Output
FAIL
Line number: 7 Parse Error
Or
FAIL
Line number: 6 Token 716aklas Unexpected Token
If input is correct then OUTPUT should be simply PASS.
Files To Be Submitted
You have to implement a Lexical Analyzer/Scanner for the simple C-like programming language using 'lex' tools.
Take a file as input (You can test it on the above example file).
Output the tokens along with:
Use the variable yyval to accomplish this.
Coverage of tokens of language | 5 |
Interface with lexical analyzer | 5 |
Construction of CFG for given language | 5 |
Table driven LL(1) parser | 10 |
Construction of LL(1) parsing table for particular CFG and its actual relevance to the given language | 20 |
Individual assessment | 5 |
Total marks | 50 |
The input will be Simple-C programs, which may be wrong or correct syntactically and semantically. You will have to output both syntax and semantic errors in the Input.
Example 1: Correct Simple-C Program int main() { int fn1 = 1; int fn2 = 1 ; int i=0; int n; int fn=0; read(n); if(n < 1) print(0); else { while(i < n) { fn = fn1 + fn2; print(fn); fn2 = fn1; fn1 = fn; i++; } } } The above program should be accepted by the parser. Example 2: Wrong Simple-C Program int main() { int r; int p /* Syntactic error here, missing semicolon */ int int j; /* Parse error here, keyword int occurs two times */ int total=0; int i; read(r); read(p); scanf (j; /* unrecognized token here: scanf and mismatched parentheses*/ for(i = r; i < p; i+= j) total = total + j; print(total); }
If input is wrong, i.e the parser was not able to parse the input or lexer was not able to recognize a token, then the output along with diagnosed reasons should be presented to the user.
FAIL
Line number: 7 Parse Error
Or
FAIL
Line number: 6 Token 716aklas Unexpected Token
If input is correct then OUTPUT should be simply PASS.
Take a file as input (You can test it on the above example file).
Output the tokens along with:
Use the variable yyval to accomplish this.
Running the program with your own LA | 20 |
Interchangability of LA by lex and your own LA | 5 |
Total Marks | 25 |
The input will be Simple-C programs, which may be wrong or correct syntactically and semantically. You will have to output both syntax and semantic errors in the Input.
Example 1: Correct Simple-C Program int main() { int fn1 = 1; int fn2 = 1 ; int i=0; int n; int fn=0; read(n); if(n < 1) print(0); else { while(i < n) { fn = fn1 + fn2; print(fn); fn2 = fn1; fn1 = fn; i++; } } } The above program should be accepted by the parser. Example 2: Wrong Simple-C Program int main() { int r; int p /* Syntactic error here, missing semicolon */ int int j; /* Parse error here, keyword int occurs two times */ int total=0; int i; read(r); read(p); scanf (j; /* unrecognized token here: scanf and mismatched parentheses*/ for(i = r; i < p; i+= j) total = total + j; print(total); }
If input is wrong, i.e the parser was not able to parse the input or lexer was not able to recognize a token, then the output along with diagnosed reasons should be presented to the user.
FAIL
Line number: 7 Parse Error
Or
FAIL
Line number: 6 Token 716aklas Unexpected Token
If input is correct then OUTPUT should be simply PASS.
LR(1) parser generator | 25 |
LR(1) grammar for language | 5 |
Overall LR(1) parser and lex pair operation and test example | 5 |
Own contribution | 5 |
Total Marks | 50 |
The input will be Simple-C programs, which may be wrong or correct syntactically and semantically. You will have to output both syntax and semantic errors in the Input.
Example 1: Correct Simple-C Program int main() { int fn1 = 1; int fn2 = 1 ; int i=0; int n; int fn=0; read(n); if(n < 1) print(0); else { while(i < n) { fn = fn1 + fn2; print(fn); fn2 = fn1; fn1 = fn; i++; } } } The above program should be accepted by the parser. Example 2: Wrong Simple-C Program int main() { int r; int p /* Syntactic error here, missing semicolon */ int int j; /* Parse error here, keyword int occurs two times */ int total=0; int i; read(r); read(p); scanf (j; /* unrecognized token here: scanf and mismatched parentheses*/ for(i = r; i < p; i+= j) total = total + j; print(total); }
Each grammar rule reduction should be printed as it occurs.
Overall LALR(1) parser and lex pair operation and test example | 25 |
Own contribution | 5 |
Total Marks | 30 |
You are to use the YACC based LALR(1) parser for the Simple-C programming language to generate 3-address code. Use the lex generated lexical analyzers to work with the parser that you generate. Your makefile should include a target for generating an executable from the 3-address code that you generate using a standard assembler. It should also include necessary commands to compile the programs generated by lex and yacc.
The 3-address code file should be generated as a result of make all.
The other specifications are same as for the assignment on LALR(1) Parser Generator for Simple-C
To understand how parameter passing for subroutine calls should be handled, generate the assembly for simple `C' programs using gcc -S and analyze the resulting assembly code. You should use printf() to output values computed in your program.
Basic code generation | 15 |
Subroutine handling and gcc compatibility | 10 |
Own contribution | 5 |
Total Marks | 30 |