Work Note 2, DM516, Spring 2012
Lecture February 2
-
Syntax analysis (parsing).
Background material: Appel Chapter 3.
Exercises February 7
-
Appel 2.1 a-f.
-
Discuss the C programming style introduced in Appel, Chapter 1.
Make changes in Program 1.5 corresponding to the addition of the
following rules to Grammar 1.3:
- Exp -> string
- Exp -> sqrt ( Exp )
- Stm -> if ( Exp ) then Stm
-
Read about Flex. Make an overview of the additional possibilities
for specifying regular expressions which are available in the tool
compared with what was discussed at the lecture.
-
What does the following regular expressions match?
-
\"([^\"])*\"
-
http:[^?]*\?
-
[-+]?[0-9]*\.[0-9]+([eE][-+]?[0-9]+)?
-
Make and test the following three Flex scanners:
-
Make texts politically correct. Replace "idiot" with
"intellectually challenged person", etc.
-
Remove all whitespace and produce lines in lengths of 80 characters.
-
Remove all tags from an HTML document.
For those who do not speak HTML fluently, HTML is just regular
text with some extra interpreted constructions.
A "tag" consists of a "less than" symbol followed by some text
and closed by a "greater than" symbol
(you can view the source of this page to see an example).
With regards to literature and material on C, flex, etc., see the
literature page.
Announcements
-
In weeks 6, 7, and 8, there will be some changes compared with
the announced by the faculty as to which slots are used for
lectures and exercises, respectively.
Last modified: Fri Feb 3 12:09:40 CET 2012
Kim Skak Larsen
(kslarsen@imada.sdu.dk)