2011-11-10 The path of my studies passed some theoretical computer science basics just by. Well, that made it easier for me then, but more difficult and worse (!) now. Yesterday and today, I learned to implement a finate state machine, the hard way. I had to teach me almost everything my- self. If you have the chance, then learn it when it is tought to you. Some remarks: Draw the right graph first. Implement it with one large loop, having the one simple gettoken() function. Although I don't like the switch syntax in C, you best take two nested switch statements. Use ungettoken() and return to the starting state, if you find a non-matching token. Well, it took about 200 lines of state machine to match and sum up signed decimal integer and floating point numbers (also in scientific notation). To draw the graph for a troff document, I used pic. There should be some preprocessor for pic to ease this task, but I found none. The Dragon Book includes some nice graphs, probably generated with pic macros. I should find out how they created them. The other possibility would be graphviz, I think. Unfortunately, I'm not matured using it. I would have needed too much time to find out how to use it. Hence, I did it in a poor man's version with pic. Here are the sources: .PS circlerad = .15 S0: circle "\fBS0\fP" at .2,-.6 S1: circle "\fBS1\fP" at 1,0 S2: circle "\fBS2\fP" at 2.5,.2 S3: circle "\fBS3\fP" at 2,-.4 S4: circle "\fBS4\fP" at 3,-.5 S5: circle "\fBS5\fP" at 3,-1.3 S6: circle "\fBS6\fP" at 2,-1.3 S7: circle "\fBS7\fP" at 1,-1.5 arrow <- left from S0.w box invis "\fIStart\fP" arrow " + -" from S0 to S1 chop arrow ". " above from S0 to S3 chop arc -> cw from S0.n to S2.nw rad .7 "0-9" at .3,.1 arrow "0-9 " above from S1 to S2 chop arrow "." above from S1 to S3 chop arrow " ." above from S2 to S4 chop arc -> cw from S2.e to S5.e rad .4 "E e" at 3.4,.1 spline -> from S2.ne right .3 up .3 then left up .1 then \ to S2.n " 0-9" above arrow "0-9 " above from S3 to S4 chop arrow "E e" from S4 to S5 chop spline -> from S4.e right .3 then up .4 left .1 then to S4.ne "0-9" at 3.3,-.6 arrow "+ -" below from S5 to S6 chop arc -> cw from S5.sw to S7.se rad 2 "0-9" at 2.7,-1.7 arrow " 0-9" below from S6 to S7 chop spline -> from S7.w left .2 then down .2 right .1 then \ to S7.sw "0-9 " above .PE http://marmaro.de/lue/ markus schnalke