Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
It a topic of Compiler Construction
Typology: Schemes and Mind Maps
1 / 52
This page cannot be seen from the preview
Don't miss anything!
Muhammad Fawad Nasim [email protected]
๏ Generates the target program with the help of intermediate source code representation and symbol table.
๏ A character sequence that cannot be scanned into any valid token is a lexical error. ๏ Lexical errors are uncommon, but they still must be handled by a scanner. ๏ Misspelling of identifiers, keyword, or operators are considered as lexical errors. ๏ Usually, a lexical error is caused by the appearance of some illegal character, mostly at the beginning of a token.
A lexical analyzer reads characters from the input and groups them into "token objects."
1. Scanning consists of the simple processes that do not require tokenization of the input, such as deletion of comments and compaction of consecutive whitespace characters into one.
Lexical Analyzer Parser Source program token getNextToken Symbol table To semantic analysis
Tokens Lexeme Patterns
In programming language, keywords, constants, identifiers, strings, numbers, operators and punctuations symbols can be considered as tokens. Types of Tokens Keywords (words that convey a special meaning to the language compiler. do, float etc in c++) Identifiers (variable names etc) Literals (constant) Punctuators (โโ, ; [] {}) Operators (+,/ etc)
๏ int (keyword), value (identifier), = (operator), 100 (constant) and ; (symbol).