Wednesday, February 2, 2011

hoc: hoc1 and hoc2 complete

On a whim I picked up Kernighan and Pike's The Unix Programming Environment and decided to fully implement High-Order Calculator (hoc) - the programming language used as a development case in the book. At least, so far I implemented hoc1 and hoc2, including the exercises (extensions).

The development case, as it is, describes the development of a simple programming language using yacc and lex over six stages. hoc 1 and 2 represent stages 1 and 2.

So, hoc2 has the following capabilities:
  • +,-,*,/,% floating point values
  • nested parenthesis
  • simple variables - a single lower case letter can be assigned a value
  • expression terminating semicolon
    • 2+3; 4*2; a=7.4;
  • a basic system of interpreter commands is included, with only a single command: '?'
    • typing '?' will print the result of the previous computation
Now come the next 4 stages...

No comments:

Post a Comment