0% found this document useful (0 votes)
1 views

Compiler Lab Assignment 1-2.docx

The document outlines two assignments for a Compiler Lab course at the National Institute of Technology. Assignment 1 involves developing a programming language similar to C, including creating keywords, operators, and a lexical analyzer, while also implementing error handling and testing with sample programs. Assignment 2 focuses on creating a parser for the language, including defining grammar, handling ambiguity, and demonstrating the parsing process with error detection.

Uploaded by

Mohd Shoaib
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Compiler Lab Assignment 1-2.docx

The document outlines two assignments for a Compiler Lab course at the National Institute of Technology. Assignment 1 involves developing a programming language similar to C, including creating keywords, operators, and a lexical analyzer, while also implementing error handling and testing with sample programs. Assignment 2 focuses on creating a parser for the language, including defining grammar, handling ambiguity, and demonstrating the parsing process with error detection.

Uploaded by

Mohd Shoaib
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

NATIONAL INSTITUTE OF TECHNOLOGY


Compiler Lab (CSPC62)

Assignment 1: More detail

A. Develop the components of a programming language having all features similar to C.


Your keywords should end with ‘_’ followed by the initials of your name and each
identifier should start with the last three digits of your roll number.
a. Must have Keywords for Loop, Switch Case, If-Else, type of
variables/numbers, structure
b. Operators
c. punctuations
d. (,),{,},[,]
e. identifiers, numbers, strings
B. Write regular expressions for each of them and draw the corresponding DFA
C. Write Lex code implementing the patterns and corresponding actions.
D. Write codes for handling errors during lexical analysis.
E. Compile the Lex code and create your own lexical analyzer (L).
F. Write a sample source program for a scientific calculator in the language you
developed and do the following:
a. Show that L is able to correctly recognize the tokens and handle errors
correctly.
b. Show output tokens in the print statement.
c. Show the contents of your Symbol table after each token is processed.
d. Write small programs in the language you have developed.
G. Further test with other sample programs in this new language to check every
statement of the compiler and show that it is working correctly.
a. Write sample program to do linear search and binary search
b. Write sample program to implement any sorting technique
c. Write programs containing array, functions, switch cases, if-else statements
and loops.

Assignment 2:
A. Create a parser that can handle all the components of this programming language.
a. Write the production rules of your grammar.
b. Remove ambiguity using precedence and associativity.
c. Build the state-automata and the parse table.
d. Do error recovery using Synch symbols.
B. Show that this parser correctly parses the input token generated by your lexical
analyser for the programs written in your programming language as well as identifies
errors.
a. Parse the programs written in Assignment 1 and show that your compiler is
correctly detecting the tokens and report errors.
b. Parse the program using your parser. Print step by step parsing process and
draw the parse tree.

You might also like