CS 4300
Fall 2006
A program in lex. (Modifed from original assignment by Jose Amaral.)
The file scan.l contains the description of tokens to
generate
a scanner using lex. To generate the scanner use the following
command:
lex scan.lYou will notice that lex created the file lex.yy.c in your current directory. Now you must compile this file into an executable program. Do so with the following:
cc -o scanner lex.yy.cNow you can run the executable scanner and play with it by typing in text and checking if it is recognized as a token. You may want to consult the file scan.l as you play with the scanner to understand how the tokens are specified. Make sure and try operators, words, parenthesis, etc. The scanner will output the type of symbol that it recognized for the input that you typed. What are the functions of period, space, and comma in this scanner? Can you list all the characters that are interpreted as special symbols by the scanner? You can use CTRL-D to terminate the scanner.