Monday, April 16, 2007

TAS Must Die, Chapter 14

I started creating the P2 parser this weekend. I took a delightfully neaderthal approach which was to write just enough code to dump the iscript tokens to sysout, find a cohesive batch of them (like the SET statement, for example) and code it up.

It didn't take long to get REM, SET, and INCLUDE mostly working. I suspect as I feed different iscript files through the parser I'll find different cases that the parser doesn't handle. I don't actually have any documentation for iscript. I have no clue as to the full extent of the supported syntax. That's made maintaining it for these last 2 years pretty invigorating at times.

What's interesting about this phase of the project is designing the pcode. I think of pcode as über assembly language. Each pcode statement will do a specific task and contain all the information to do so. For example, of I know a token is a number, I'll probably mark it as such in the pcode.

|set|someVariableName|314|

The pcode interpreter could figure out of 314 is an integer or a variable. But I've already done that in the lexer and parser. So why not have

|set|someVariableName|314,contant,integer|

I don't know if the pcode interpreter will need all the information, but if I have it I might as well provide it.

I'll probably start writing the Factory in parallel. The factory will accept a list of pcodes and return a list of executable classes. This will allow me to execute the pcode - and check my work.

No comments:

Post a Comment