PxdScript language tutorial series.

Various notes

by Kasper Fauerby


Hi there,
This is just a small page which I will update when I change something in some of the chapters. Hopefully it will not get too big ;) Thanks to all the people who has helped me track down the errors - you know who you are.

Code packages:

I've decided to put all the source for the compiler into one .zip file and the source to the vm in another. This is in contrast to earlier where I had a source package for each chapter. So from now on you can always get the latest version of the source code by downloading these two packages from the tutorial webpage.


April 29, 2004: An error in the compiler source was brought to my attention. When creating the CODE struct for a 'call' expression we use two different string variables, the function name (callC) and the encoded argument signature string (callSignatureC). For some reason I had put both of these into the 'val' union in the CODE struct, which of course isn't possible. As a result, when setting the callSignatureC variable the content of callC was overwritten and the compiler emitted invalid code. Changes are required in the files tree.h, tree.c and emit.c - you can either fix the problem yourself or download an updated source package for the compiler.

Extra reading:

Here are a few links submitted by Fernando Rodrguez if you want to read in greater detail about Flex and Bison :


General overview of Lex and Yac 

Various things:

-If you try to build the code with VC++ the compiler will complain about not being able to find a function called yywrap. This is something used by bison and you'll have to define it yourself when using VC++. Simply add a function like this where the linker can find it:

int yywrap()
return 1;

I think it will also complain about not being able to find atoi and atof in some file - just include the stdlib.h header to the file and it'll work.

- You can force cygwin to link statically to the cygwin dll. By doing so you can run the exe on machines which does not have cygwin installed. You do this by adding a flag to the gcc compiler - change the makefile like this:

CFLAGS = -Wall -pedantic -g -mno-cygwin Here are


Keep on codin'
  Kasper Fauerby