Statement hierarchy in programming languages

Posted by sudo on Stack Overflow See other posts from Stack Overflow or by sudo
Published on 2010-03-30T09:03:54Z Indexed on 2010/03/30 9:13 UTC
Read the original article Hit count: 309

I quickly wrote an interpreter for some sort of experimental programing language i came up with, in PHP (yes, in PHP). The language itself doesn't have anything really special, I just wanted to give it a try.

I got the basic things working (Hello World, input to output, string manipulation, arithmetics) but I'm getting stuck with the management of blocks and grouped statements.

What I mean is: PHP and most other languages let you do this: ((2+2)*(8+2)+2), of course not only with mathematical computations.

My program structure currently consists of a multidimensional array built like this:

ID => Type (Identifier, String, Int, Newline, EOF, Comma, ...)
      Contents (If identifier, int or string)
  • How could I allow statements to be executed in a defined order like in the PHP example above?

© Stack Overflow or respective owner

Related posts about interpreter

Related posts about programming-languages