in Books, Doing Books, Theory of Computation

Theory of Computation #17

Ok, now we can parse the individual statements. Let’s start with easier ones: incr and decr. What we ant is a hash-map which looks like this:

What we want to do is pattern-matching. I will some regex for each one which works fine here for individual statements. The variable names can consist of digits, lower and uppercase letters and underscores.

Here’s the code:

The next thing I want to do is to create variables dynamically. I integrate this into the function decr and incr first, just because it’s easier. The creation of variables int he while statement is a special case because automatically it won’t do the stuff in it because the variable is bound to 0 intially.


Last part tomorrow

Write a Comment