Chapter Two: Lexical Analysis

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/14

flashcard set

Earn XP

Description and Tags

Vocabulary practice flashcards covering fundamental concepts, roles, structures, and input buffering techniques of lexical analysis in compiler design.

15 Terms

1
New cards

Lexical Analyzer (Lexer)

The first phase of a compiler that reads the input stream of characters from the source program, strips out whitespace and comments, groups characters into lexemes, and produces a sequence of tokens for syntax analysis by the parser.

2
New cards

Token

A sequence of characters from the source program having a collective meaning and representing a classification of lexical units; formally represented as a pair consisting of a token name and an optional attribute value.

3
New cards

Lexeme

A specific sequence of alphanumeric characters in the source program that matches the pattern for a token and is identified by the lexical analyzer as an instance of that token.

4
New cards

Pattern

A rule or description of the form that lexemes of a token may take, typically specified using regular expressions.

5
New cards

Symbol Table

A data structure with which the lexical analyzer interacts to store records of identifiers, containing information such as the lexeme, its type, and the line number where it was first seen.

6
New cards

Token Attribute

Additional information associated with a token that provides specific details about a lexeme (such as distinguishing the numbers 0 and 1 under token 'num'); practically implemented as a pointer to the token's entry in the symbol table.

7
New cards

Panic Mode Recovery

An error recovery method in which the lexical analyzer deletes or skips successive characters from the remaining input until it finds a well-formed token.

8
New cards

Transition Diagram

A stylized flowchart used in the construction of a lexical analyzer consisting of nodes called states and directed edges labeled with symbols, used to model token recognition.

9
New cards

Retract (∗*)

An indicator on an accepting state in a transition diagram denoting that the lexical analyzer read one character beyond the token lexeme (such as an 'other' character) and must step back the input pointer by one character.

10
New cards

Begin Pointer (bpbp)

A pointer in an input buffering scheme that marks the starting position of the current lexeme being scanned.

11
New cards

Forward Pointer (fpfp)

A pointer in an input buffering scheme that moves ahead character by character to search for the delimiter indicating the end of the current lexeme.

12
New cards

One Buffer Scheme

An input buffering method using a single buffer, which fails when a long lexeme crosses the buffer boundary because refilling the buffer overwrites the beginning of the lexeme.

13
New cards

Two Buffer Scheme

An input buffering method that scans two buffers alternately, refilling one while the other is being scanned to avoid overwriting lexemes, limited only if a single lexeme exceeds the length of an entire buffer.

14
New cards

Sentinel

A special end-of-buffer marker (typically an eofeof character) placed at the end of each buffer in a two-buffer scheme to identify the boundary and trigger the loading or switching of buffers.

15
New cards

Macro Expansion

An additional task performed by some lexical analyzers where macro calls within the source code are expanded into their full definitions.