Oppolzer - Informatik / Stanford Pascal Compiler


Home       Lebenslauf       Schwerpunkte       Kenntnisse       Seminare       Kunden       Projekte       Produkte       Blog       Stanford Pascal       Kontakt

The Stanford Pascal Compiler / Evolution Steps

Back to Compiler main page

20 significant characters on variable names (not only 12)

Now I could try to change the IDLNGTH constant in the compiler; I decided to go to 20 instead of 12. The syntax errors, which were in the hundreds before, have decreased to 4, because some definitions still used the numeric constant 12 and not the type ALPHA which depends on IDLNGTH; when I changed that, all worked OK.

But now I had the problem, that the second pass (P-Code translator) didn't work any more, because due to the changed IDLNGTH the output format of the P-Code file changed on certain instructions, and the P-Code translator couldn't read it any more. I soon discoverd that the P-Code translator had the same IDLNGTH constant; but setting it to 20, too, didn't resolve the issue - this would have been too easy.

I had to examine the differences on the P-Code file and discovered that due to my change there were differences on three P-Code instruction types: CST, ENT and BGN. One of these (ENT) was in fact wrong after the change; I had to correct the first pass (output length of the function name was 14, but it should have been IDLNGTH + 2).

After I've seen the effects of my change on the P-Code file, I knew better what I had to change on the second pass. The input and output routines in the P-Code translator had the same flaws as the compiler output (length was 14, but should have been IDLNGTH + 2). Another topic was that the header generated by the compiler containing the function name and the compile timestamp now has 40 bytes instead of 32, and it now has room for 20 bytes of the main program name (for example: the first pass has the program name PASCALCOMPILER, and that name didn't fit in the old program header, so it was completely omitted - but now it's there). Of course, there are branch instructions to jump over this header.

After all these modifications, I successfully compiled the following program (which had a syntax error E101 before, because of duplicate names):


program TESTDUPL ( INPUT , OUTPUT ) ; var VARIABLE_M_LANGEM_NAMEN : INTEGER ; VARIABLE_M_LANGEM_ANDEREM_NAMEN : INTEGER ; begin (* HAUPTPROGRAMM *) VARIABLE_M_LANGEM_NAMEN := 5 ; VARIABLE_M_LANGEM_ANDEREM_NAMEN := 12 ; WRITELN ( VARIABLE_M_LANGEM_NAMEN ) ; WRITELN ( VARIABLE_M_LANGEM_ANDEREM_NAMEN ) ; end (* HAUPTPROGRAMM *) .

Back to Compiler main page