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

CC Assignment 2

This document provides instructions for Assignment 2, which is due on November 26th, 2020. Students must implement a lexical analyzer using the FLEX tool to tokenize a Mini-C++ program. The Mini-C++ language definition and sample input/output are provided. Rules for the assignment specify it is individual work and plagiarism will not be tolerated. Students must read from an input file, write tokens to an output file, and list any lexical errors with line numbers. FLEX and GCC are the specified development tools.

Uploaded by

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

CC Assignment 2

This document provides instructions for Assignment 2, which is due on November 26th, 2020. Students must implement a lexical analyzer using the FLEX tool to tokenize a Mini-C++ program. The Mini-C++ language definition and sample input/output are provided. Rules for the assignment specify it is individual work and plagiarism will not be tolerated. Students must read from an input file, write tokens to an output file, and list any lexical errors with line numbers. FLEX and GCC are the specified development tools.

Uploaded by

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

Compiler Construction

Assignment 2

Deadline: you have to submit it till 26th November 2020 on google


classroom. No Late submission will be accepted.

MINI-C++: This is a subset of C++ language. Description of the language as follow:

Keyword: int, float, double, char, if, while, for, break, switch, case,
main, cout

Identifiers: examples (value, rate, Counter, _test123, etc). Same as in


C++ Language.

Integer Literals: example (123,223 etc)

Character, float and string literals: just like in C++

Operators: <,>, <=, =, ==, *, +, /,-,++,--,!,&

punctuations: [,{,(,),},] ,;,(,)

Comments: single line and multiline just same as in C++ language


This assignment is the extension of previous assignment; in this assignment you have to
implement the lexical analyzer using the FLEX tool.

Sample Input: Sample output:


a source file containing the source code of It write all the tokens in separate file.
mini c++ is input.
int main() <>DATATYP, int>
{ <KW, main>
int i=13; <PUN, ) >
int flag=0; <PUN, ( >
for(int j=2; j<I; j++) <PUN, { >
{ <> DATATYP, int>
If(j%2==0) <ID, i >
flag=1; <OP, = >
break; <INTLIT, 13 >
} <PUN, ; >
If(flag==0) <> DATATYP, int>
cout(“prime”); <ID, flag>
else <OP, = >
cout(“not prime”); <INTLIT, 0 >
<PUN, ; >
}
PRDODUE ALL TOKKENS LIKE ABOVE MENTION
FORMAT.

Rules:
1.This is an individual assignment. Each student has to submit his/her assignment work.
2.Group discussion is allowed but don’t share assignment with other student.
3.Plagiarisms not tolerable in any of its form. Minimum penalty would be an ‘0’ in all course
assignments
4: You have to read input form the file and write the token in output file.
5: you have to list down all the lexical error along with line number if exist in the program.

Tools:
Language (For Development): FLEX and GCC compiler

You might also like