Lexical Analysis I: Compiler Construction
Lexical Analysis I: Compiler Construction
2130-001
Compiler Construction
Lecture 4:
Lexical Analysis I
Token classes
One token per keyword
Tokens for the operators
One token representing all identifiers
Tokens representing constants (e.g. numbers)
Tokens for punctuation symbols
Example
Dealing With Errors
Lexical analyzer unable to proceed: no
pattern matches
Panic mode recovery: delete successive
characters from remaining input until
token found
Insert missing character
Delete a character
Replace character by another
Transpose two adjacent characters
Example
declarations
%%
translation rules
%%
auxiliary functions
declarations
translation rules
auxiliary functions
Anything between these
2 marks is copied as it is
in lex.yy.c
braces means the pattern
is defined somewhere
Actions
pattern
Lecture of Today
Sections 3.1 to 3.5
First part of the project assigned