tailieunhanh - Compiler construction: Lecture 9, 10 - Majid Mumtaz
The following will be discussed in this chapter: The role of lexical analyzer, lexical analysis vs parsing, recall, example, regular expressions, regular expressions – algebraic laws, alternative notations,. Inviting you to refer. | Compiler Construction Week-5 Lecture 9-10 Majid Mumtaz Department of Computer Science CIIT Wah 1 The Role of Lexical Analyzer Primary Role - Read the input characters of the source program Group them into lexemes Produce a sequence of tokens for each lexeme Secondary Role Interacting with the symbol table If a lexeme constitutes an identifier . variables types subroutines etc. it needs to be entered into the symbol table This information can be read later on in order to determine the appropriate token to pass on to the parser for syntax analysis . 2 The Role of Lexical Analyzer Secondary Role Removing comments and whitespace - Blank newline tab - Other characters that are used to separate tokens in the source input code . colon Secondary Role Correlating error messages generated by the compiler with the source code - Keeping track of the number of newline characters seen in order to associate a line number with each error message - Making a copy of the source program and inserting the error messages at the appropriate positions.
đang nạp các trang xem trước