The Scanner
The scanner groups the input stream (of characters) into a stream of tokens (lexeme) and constructs a symbol table which is used later for contextual analysis. The lexemes include
· Key words,
· identifiers,
· operators,
· constants: numeric, character, special, and
· comments.
The lexical phase (scanner) groups characters into lexical units or tokens. The input to the lexical phase is a character stream. The output is a stream of tokens. Regular expressions are used to define the tokens recognized by a scanner (or lexical analyzer). The scanner is implemented as a finite state machine.
Lex and Flex are tools for generating scanners is C. Flex is a faster version of Lex.
Posted in Computer Science, Information Technology, Compiler Design, Compiler Design |
