CS 43001 Compiler Construction

(Autumn Semester 2005)

Theory
Niloy Ganguly niloy@cse.iitkgp.ernet.in

Laboratory
Chitta Ranjan Mandal chitta@cse.iitkgp.ernet.in
Niloy Ganguly niloy@cse.iitkgp.ernet.in

Teaching Assisstant
Subrat Kr. Panda subrat@cse.iitkgp.ernet.in
Hitashyam Maka hitashyam2@yahoo.com
Siva Kumar akkireddisiva@yahoo.co.in


Notices

Theory

       Lectures
       Evaluation
       Blog
       Mini-Assignments
       Assignments
       Students List

Laboratory

       Lab-Assignments
          Assignment 1
          Assignment 2
          Assignment 3
          Assignment 4
          Assignment 5
          Assignment 6
          Assignment 7

Notices

6.12.2005 - Grades are out. Enjoy!!!
27.09.2005 - People in serious trouble over attendance (in order of seriousness).
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
24.10.2005 - Class Test on 7.11.2005, 2.30 pm
26.10.2005 - Lab viva on 14.11.2005, 1.30 pm, all group members should come together
15.11.2005 - Marks (also viva) are out (partially), check your marks. If you have any questions regarding your marks, your questions will be answered after endsem along with your endsem marks. (Appointment time will be announced later.)
If you have any questions regarding your lab assignment marks, please mail your respective TA , writing clearly the debates you have. If he feels your queries worth addressing , he will give you an appointment.
MANY OF YOU HAVE NOT SUBMITTED THE NOTES. PLEASE SUBMIT IT BY 17.11.2005. OTHERWISE IT WILL BE DISTRIBUTED TO OTHERS. THIS IS A HARD DEADLINE

Theory

  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.

Lectures

The lecture notes are unedited version of student submission.
01.08.05 - Introduction, 03CS3012 (03CS3022)
04.08.05 - Introduction, 03CS3015
08.08.05 - Lexical Analyzer, 03CS3006 (03CS3019)
09.08.05 - Thompson Construction, Subset Construction, 03CS1005 (03CS3003)
09.08.05 - Thompson Construction, Subset Construction, 03CS3014
11.08.05 - Lex, 03CS1033 (03CS1018)
16.08.05 - Syntax Analysis, Error Recovery, 03CS1035
16.08.05 - Problems in Grammar, 03CS1002
22.08.05 - Top Down Parsing, Recursive Descent, Predictive Parsing, 03CS1021
25.08.05 - LL(1) Parser, 03CS3008
29.08.05 - LL(1) Parser, 03CS1014
29.08.05 - LL(1) Parser, 03CS1011
30.08.05 - Bottom-up Parser, Operator Precedence Parser, 03CS3005
30.08.05 - Operator Precedence Parser, 03CS1017
01.09.05 - Operator Precedence Parser, 03CS1032
05.09.05 - LR Parser, 02CS1009 (03CS3018)
06.09.05 - LR Parser, 03CS3021
06.09.05 - LR Parser, 03CS3020
12.09.05 - LR(1) Parser, 03CS1028
13.09.05 - LR(1) Parser, LALR Parser, 03CS1036
13.09.05 - LR(1) Parser, LALR Parser, 03CS3021
15.09.05 - Ambiguity in Grammar, Error Recovery 03CS1023
26.09.05 - Error Recovery, Syntax Directed Translation 03CS1004(03CS1007)
27.09.05 - Intermediate Code Generation 03CS1026
27.09.05 - Three Address Code Generation, Introduction 03CS1001, 03CS1008 (03CS1012)
03.10.05 - Three Address Code Generation 03CS1016
04.10.05 - Three Address Code Generation - Array 03CS1020
04.10.05 - Three Address Code Generation - Array 03CS1024
04.10.05 - Three Address Code Generation - Array 03CS1031(03CS1034)
17.10.05 - Three Address Code Generation -Boolean Functions 03CS1037
18.10.05 - Three Address Code Generation - Control Statements 03CS3004
18.10.05 - Three Address Code Generation 03CS3009
20.10.05 - Three Address Code Generation - Backpatching 03CS3010
24.10.05 - Three Address Code Generation - Translation of Control Flow Statement 02CS1010
25.10.05 - Three Address Code Generation 02CS1022 (03CS1001)
25.10.05 - Target Code Generation 03CS3012 (03CS1006)
27.10.05 - Target Code Generation - Basic Blocks 03CS3006
31.10.05 - Target Code Generation - Next Usage 03CS1033
3.11.05 - Target Code Generation - Register Allocation 02CS1022
7.11.05 - Target Code Generation - DAG 02CS1009 - This note is slightly different from class note.
8.11.05 - Target Code Generation - DAG 03CS1008
8.11.05 - Target Code Generation - DAG 03CS3006
10.11.05 - Target Code Generation - DAG 03CS1015
14.11.05 - Type Checking 03CS3013
17.11.05 - Type Checking and Peephole Optimization 03CS3013

Evaluation

Teacher's Assessment : 20
        Miniassignment : 4
        Assignment : 4
        Class Test : 4
        Attendance : 4
        Extra : 4

Mid-sem : 30

End-sem : 50

Blog

Class Diary before midsem
03CS3016, 03CS3022, 03CS1010, 03CS3013, 03CS3024

Class Diary after midsem
03CS3011, 03CS3023, 03CS3025

Mini-Assignments

Answers - 03CS1003

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)

Assignments

Submit the assignments individually.

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

Students List

Sl. No. Roll No. Name MA A CTATExMSESTotGrade
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)

Lab Assignments

General Guidelines

Assignment 1: Assignment on Thompson's Construction

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.

Marking Guidelines

(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.

Assignment 2: Lex/Scanner for a simple language using lex

Construct a simple C-like language with

  1. Data Type : integer (INT/int), floating point (FLOAT/float)

  2. Condition constructs: if

  3. Loop Constructs: for, while
  4. Input / Output Constructs:
    1. read(x) - Read into variable x
    2. print(x) - Write variable x to output
  5. Relational operators, assignment and arithmetic operators
  6. Only function is main(), there is no other function.

Example


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.

Marking Guidelines

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

  1. The Simple-C language is a simplified and modified subset of C programming language.
    The language specifications are given in second assignment.
  2. You can get the CFG for C-programming language at Appendix A13 in Kernighan, B. W. and Ritchie, D. M., The C Programming Language, PHI.

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);
}

The input to your program should be given from the command line. Like a.out < testinput.txt

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.

Marking Guidelines

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

Assignment 4: Lexical Analyser and LL(1) Parser

You have to use the table-driven LL(1) parser developed in assignment 3 with your own lexical analyser developed in LA assignment for Simple-C programming language.

Given

  1. The Simple-C language is a simplified and modified subset of C programming language. The language specifications are given in second assignment.
  2. You can get the CFG for C-programming language at Appendix A13 in Kernighan, B. W. and Ritchie, D. M., The C Programming Language, PHI.

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);
}

The input to your program should be given from the command line. Like a.out < testinput.txt

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

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.

Marking Guidelines

Running the program with your own LA20
Interchangability of LA by lex and your own LA 5
Total Marks25

Assignment 5: LR(1) Parser Generator for Simple-C

You are required to develop a LR(1) parser generator for a given grammar. You are to use the generator to generate a LR(1) for the Simple-C programming language. Use one of your earlier lexical analyzers to work with the parser that you generate.

Given

  1. The Simple-C language is a simplified and modified subset of C programming language. The language specifications are given in the lexical analyser assignment.
  2. You can get the CFG for C-programming language at Appendix A-13 in Kernighan, B. W. and Ritchie, D. M., The C Programming Language, PHI.

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);
}

The input to your program should be given from the command line. Like a.out < testinput.txt

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

Marking Guidelines

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

Assignment 6: LALR(1) Parser Generator for Simple-C

You are to use the YACC parser generator to generate a LALR(1) parser for the Simple-C programming language. Use one of your earlier lexical analyzers to work with the parser that you generate.

Given

  1. The Simple-C language is a simplified and modified subset of C programming language. The language specifications are given in the lexical analyser assignment.
  2. You can get the CFG for C-programming language at Appendix A-13 in Kernighan, B. W. and Ritchie, D. M., The C Programming Language, PHI.

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);
}

The input to your program should be given from the command line. Eg a.out < testinput.txt

Output Expected

Each grammar rule reduction should be printed as it occurs.

Example

If you have a rule F->id which is reduced then the parser should print "F->id". If input is correct then OUTPUT should be simply PASS.

Files To Be Submitted

Marking Guidelines

Overall LALR(1) parser and lex pair operation and test example 25
Own contribution 5
Total Marks 30

Assignment 7: Intermediate Code Generation for Simple-C

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.

Files To Be Submitted

Marking Guidelines

Basic code generation 15
Subroutine handling and gcc compatibility 10
Own contribution 5
Total Marks 30