Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

LEXICAL ANALYSER USING C/C++

UTPAL KALITA (CSE 5th Sem) Lexical analyzer converts stream of input characters into a stream of tokens. Some of the tokens that our lexical analyzer identifies are as follows: KEYWORDS: int, char, float, double, if, for, while, else, switch, struct, printf, scanf, case, break, return, typedef, void IDENTIFIERS: main, fopen, getch etc NUMBERS: positive and negative integers, positive and negative floating point numbers. OPERATORS: +, ++, -, , ||, *, ?, /, >, >=, <, <=, =, ==, &, &&. For tokenizing into identifiers and keywords we incorporate a symbol table which initially consists of predefined keywords. The tokens are read from an input String. If the encountered token is an identifier or a keyword the lexical analyzer will look up in the symbol table to check the existence of the respective token. If an entry does exist then we proceed to the next token. If not then that particular token along with the token value is written into the symbol table. The rest of the tokens are directly displayed by writing into an output.

INTRODUCTION OF LEXICAL ANALYSIS PROCESS:

Lexical analysis involves scanning the program to be compiled and recognizing the tokens that make up the source statements Scanners or lexical analyzers are usually designed to recognize keywords , operators , and identifiers , as well as integers, floating point numbers , character strings , and other similar items that are written as part of the source program . The exact set of tokens to be recognized of course, depends upon the programming language being used to describe it. A sequence of input characters that comprises a single token is called a lexeme. A lexical analyzer can insulate a parser from the lexeme representation of tokens

Minimum Requirements Software requirements : Operating System : Windows 98/XP/Seven(32-bit) Language: C/C++ Compiler: Turbo C 3.0, DosBox Hardware requirements : Processor : Intel Pentium IV or above Ram : 256 Mb (min) HardDisk : 1 GB Monitor: VGA enabled standard Monitor Keyboard: 101- Standard Keyboard

-------------------------------------------------------------------------------------------------------------------------------

You might also like