Assignment 1 Lexical Analysis Using Flex
Assignment 1 Lexical Analysis Using Flex
Introduction
The lexical analyzer is the part of the compiler that reads the source text, it may also
perform certain secondary tasks at the user interface. One such task is stripping out
comments and white space in the form of blanks, tabs and new line characters, from the
source program. Another is correlating error messages from the compiler with the source
program i.e. keeping a correspondence between errors and source line numbers.
Objectives
Tools/Software Requirement
Description
Task 1
Write a flex program to process a pascal-like toy language with the following
specifications:
A keyword: procedure
An identifier: compute
A keyword: begin
An identifier: area
Unrecognized character: =
A float: 3.141 (3.141)
An operator: *
An identifier: radius
An operator: *
An identifier: radius
A keyword: end
A keyword: function
An identifier: main
A keyword: begin
An identifier: compute
A keyword: end
Task 2
44 0 0 0
33 44 0 0
22 33 44 0
726 44 0 0
770 0 0 0
1 770 0 0
769 0 0 0
result = 769
Deliverables
You are required to upload your task (Sources & PDF document) zipped in a single rar
file using the link created on TEAMS.
Note: Java user can perform the above tasks using jflex
http://jflex.de/