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

Old errors removed from the compiler

Compiler version: 11.2017

When I decided in October 2017 to use runtime checks in the first pass of the compiler, I had to do substantial work to remove all the places where out-of-range assigments were done or uninitialized variables were used.

At the same time I tried to use the PASSCAN scanner with the source code formatter PASFORM. This implied the use of the scalar type SYMB. When I introduced this into PASFORM, I got some hundred errors P104 due to unknown identifiers. It turned out, that most P104 errors were followed by other additional errors, because the compiler did additional checks on undefined or incomplete internal structures, which it should not do after the first error.

Furthermore, the compiler crashed, when there was an erroneous semicolon before else, like, for example, in:


program CRASH2 ( OUTPUT ) ; type CHARX = array [ 1.. CMAX ] of CHAR ; var C : CHAR ; begin (* HAUPTPROGRAMM *) C := 'X' ; if C = 'X' then C := 'A' ; else C := 'B' ; end (* HAUPTPROGRAMM *) .

the problem was, that the statement before "else" ended correctly, and the symbol else at the beginning of the next statement was not handled correctly by the parser and lead to disaster. This had to be fixed as the first step.

The next working version of the compiler showed these errors:


c:\work\pascal\work>ppb crash2 PCINT (Build 1.0 Nov 11 2017 08:49:28) **** STANFORD PASCAL COMPILER, OPPOLZER VERSION OF 09.2017 **** 3 SYNTAX ERROR(S) DETECTED. **** 16 LINE(S) READ, 0 PROCEDURE(S) COMPILED, **** 12 P_INSTRUCTIONS GENERATED, 0.02 SECONDS IN COMPILATION. **** LAST ERROR/WARNING ON LINE --> 14 **** ERROR/WARNING CODES FOR THIS PROGRAM : **** 6 : ILLEGAL SYMBOL **** 104 : IDENTIFIER IS NOT DECLARED **** 107 : INCOMPATIBLE SUBRANGE TYPES *** EXIT Aufruf mit Parameter = 3 ***

The semicolon before "else" is now handled correctly; the compiler shows an error P006 ("Illegal symbol") at the "else" symbol.

This is the 09.2017 version, which does not yet show the errors on the terminal. But anyway: P104 is shown, because CMAX is not defined, and P117 is shown, because the type of CMAX does not fit to the type of the integer constant 1 (which makes no sense).

There were many places in the compiler, where such additional errors after P104 were shown. I tried to eliminate all or most of these. The compiler output now looks like this (12.2017 version):


c:\work\pascal\work>pp crash2 PCINT (Build 1.0 Nov 11 2017 08:49:28) **** STANFORD PASCAL COMPILER, OPPOLZER VERSION OF 12.2017 **** 4 type CHARX = array [ 1.. CMAX ] of CHAR ; ! +++ Error P104: IDENTIFIER IS NOT DECLARED 14 else ! +++ Error P006: ILLEGAL SYMBOL **** Compiler Summary **** **** 2 Errors. **** 16 LINE(S) READ, 0 PROCEDURE(S) COMPILED, **** 12 P_INSTRUCTIONS GENERATED, 0.06 SECONDS IN COMPILATION. **** Last Error/Warning on Line 14 **** Error/Warning Codes for this Program: **** P006: ILLEGAL SYMBOL **** P104: IDENTIFIER IS NOT DECLARED *** EXIT Aufruf mit Parameter = 2 ***

Back to Compiler main page