Work Note 2, DM546, Spring 2015
Lecture February 5
-
Syntax analysis (parsing).
Background material: Appel Chapter 3.
Exercises February 11
-
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.
Last modified: Mon Feb 2 11:29:51 CET 2015
Kim Skak Larsen
(kslarsen@imada.sdu.dk)