input buffering in lexical analysis in CD

1,366 views 8 slides Apr 06, 2024
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

Input buffering is an important concept in compiler design that refers to the way in which the compiler reads input from the source code. In many cases, the compiler reads input one character at a time, which can be a slow and inefficient process. Input buffering is a technique that allows the compi...


Slide Content

Input Buffering in Lexical Analysis Presented by Prof.C.G.Kokane Pawar Computer Engg SBGI Miraj

How Lexical Work Input Buffering : The lexical analyzer scans the characters of the source program one at a time to discover tokens; it is desirable for the lexical analyzer to read its input from an input buffer. We have two pointers one marks to the beginning of the token begin discovered. A look-ahead pointer scans a head of the beginning point, until the token is discovered.

Sometimes lexical analyzer needs to look ahead some symbols to decide about the token to return. In C language: we need to look after ‐, = or < to decide what token to return.

Lexical Analyzer is the interface between the source program and the compiler. The main task of lexical Analyzer is to read the input characters and produce a sequence of tokens that the parser uses for syntax analysis. The Role of the Lexical Analyzer Interaction of lexical analyzer with parser Lexical Analyzer

Upon receiving a "get next token" command from the parser, the Lexical Analyzer reads input characters until it can identify the next token. . The Role of the Lexical Analyzer Interaction of lexical analyzer with parser

Removal of white space and the comments. White space (blanks, tabs, and newline characters ). Correlating error messages from the compiler with the source program. For example, the lexical analyzer may keep track of the number of newline characters seen, so that a line number can be associated with an error message. The Secondary Tasks of Lexical Analyzer: Note : Regular Expressions are used to define the tokens recognized by lexical analyzer. The lexical analyzer is implemented as Finite Automata (DFA).
Tags