Plov004 : running compiler tests
Plov004 has seen the light of day. It is many times more stable than Plov003 used to be, 48 hours ago. Yet, there is still some room for improvement.
Plov004 : compiling source 'test1'
Testing source :
PROGRAM Number1 BEGIN END Number1Compilation results in :
jan@beryllium:~/modula/Plov$ Plov004 <test1 PROGRAM Number1 BEGIN END Number1 Number1 Program type RETURN Keyword type EXIT Keyword type LOOP Keyword type BEGIN Keyword type END Keyword type IF Keyword type THEN Keyword type ELSIF Keyword type ODD Keyword type PROCEDURE Keyword type PROGRAM Keyword type CONSTANTS Keyword type VARIABLES Keyword type jan@beryllium:~/modula/Plov$It ends well, so all is well! This is no surprise, since the source of Plov003 was already altered to cope with test1.
Plov004 : compiling source 'test2'
Testing source :
PROGRAM Number1 CONSTANTS pi = 314 ee = 272 END BEGIN END Number1Compilation results in :
jan@beryllium:~/modula/Plov$ Plov004 <test2 PROGRAM Number1 CONSTANTS pi = 314 ee = 272 END BEGIN END Number1 Number1 Program type RETURN Keyword type EXIT Keyword type LOOP Keyword type BEGIN Keyword type END Keyword type IF Keyword type THEN Keyword type ELSIF Keyword type ODD Keyword type PROCEDURE Keyword type PROGRAM Keyword type CONSTANTS Keyword type VARIABLES Keyword type pi Constant type = 314 ee Constant type = 272 jan@beryllium:~/modula/Plov$As you can see, the symbol table is printed after every run and also the output of GetSymbol is printed atop. This is caused by the following piece of code:
PROCEDURE GetSymbol;
BEGIN
IF InOut.EOF () = FALSE THEN
InOut.ReadString (token)
END;
InOut.WriteString (token); InOut.Write (11C); InOut.WriteBf
END GetSymbol;
InOut.WriteString (token); takes care of dumping the newly read token to screen. InOut.Write (11C); writes a
TAB character to screen, inserting spaces until the cursor X-position is at a multiple of 8. InOut.WriteBf
flushes the buffer NOW. This is handy since this is only done after a LineFeed is issued. But if the program
gets caught in an endless loop there will be no final LF and hence also nothing to see on screen.
Plov004 : compiling source 'test3'
Testing source :
PROGRAM Number1 CONSTANTS pi = 314 ee = 272 END VARIABLES A B C Def GhYh J123 NH4NO3 END BEGIN END Number1Compilation results in :
jan@beryllium:~/modula/Plov$ Plov004 <test3 PROGRAM Number1 CONSTANTS pi = 314 ee = 272 END VARIABLES A B C Def GhYh J123 NH4NO3 END BEGIN END Number1 Number1 Program type RETURN Keyword type EXIT Keyword type LOOP Keyword type BEGIN Keyword type END Keyword type IF Keyword type THEN Keyword type ELSIF Keyword type ODD Keyword type PROCEDURE Keyword type PROGRAM Keyword type CONSTANTS Keyword type VARIABLES Keyword type pi Constant type = 314 ee Constant type = 272 A Variable type B Variable type C Variable type Def Variable type GhYh Variable type J123 Variable type NH4NO3 Variable type jan@beryllium:~/modula/Plov$Fine as well!
Plov004 : compiling source 'test4'
Testing source :
PROGRAM Number1 CONSTANTS pi = 314 ee = 272 END VARIABLES A B C Def GhYh J123 NH4NO3 END PROCEDURE AddItUp BEGIN END AddItUp BEGIN AddItUp END Number1Compilation results in :
jan@beryllium:~/modula/Plov$ Plov004 <test4 PROGRAM Number1 CONSTANTS pi = 314 ee = 272 END VARIABLES A B C Def GhYh J123 NH4NO3 END PROCEDURE AddItUp BEGIN END AddItUp BEGIN AddItUp END Number1 Number1 Program type RETURN Keyword type EXIT Keyword type LOOP Keyword type BEGIN Keyword type END Keyword type IF Keyword type THEN Keyword type ELSIF Keyword type ODD Keyword type PROCEDURE Keyword type PROGRAM Keyword type CONSTANTS Keyword type VARIABLES Keyword type pi Constant type = 314 ee Constant type = 272 A Variable type B Variable type C Variable type Def Variable type GhYh Variable type J123 Variable type NH4NO3 Variable type AddItUp Procedure type jan@beryllium:~/modula/Plov$A rather complex source with Constant, Variable and Procedrue definitions.
Plov004 : compiling source 'fout1'
Testing source :
PROGRAM Number1 CONSTANTS pi = 314 ee = 272 END VARIABLES A B C 0Def GhYh J123 NH4NO3 END PROCEDURE Diff BEGIN END Diff PROCEDURE AddItUp BEGIN END AddItUp BEGIN AddItUp Diff END Number1Compilation results in :
jan@beryllium:~/modula/Plov$ Plov004 <fout1 PROGRAM Number1 CONSTANTS pi = 314 ee = 272 END VARIABLES A B C 0Def Illegal identifier name : 0Def GhYh J123 NH4NO3 END PROCEDURE Diff BEGIN END Diff PROCEDURE AddItUp BEGIN END AddItUp BEGIN AddItUp Diff END Number1The symbol table has been omitted here. The Token Dump (above) gives the clues. Variable '0Def' starts with a zero so it is illegal. The error is flagged and compilation continues as if nothing had happened!
Plov004 : compiling source 'fout2'
Testing source :
PROGRAM Number1 CONSTANTS pi = 314 ee = A272 272 = 122 END VARIABLES A B C 0Def GhYh J123 NH4NO3 END PROCEDURE Diff BEGIN END Diff PROCEDURE AddItUp BEGIN END AddItUp BEGIN AddItUp Diff END Number1Compilation results in :
jan@beryllium:~/modula/Plov$ Plov004 <fout2 PROGRAM Number1 CONSTANTS pi = 314 ee = A272 Invalid digit in : A272 272 Illegal identifier name : 272 END VARIABLES A B C 0Def Illegal identifier name : 0Def GhYh J123 NH4NO3 END PROCEDURE Diff BEGIN END Diff PROCEDURE AddItUp BEGIN END AddItUp BEGIN AddItUp Diff END Number1Three errors. Each one flagged. They do not interfere with eachother. Professor Wirth could be prooud of me!
Plov004 : compiling source 'test6'
Testing source :
PROGRAM NH3production
CONSTANTS pi = 314159
ee = 271828
years = 2007
days = 31
END
VARIABLES temp
press
NH3
H2SO4
nitrogen
END
PROCEDURE Measure
BEGIN
END Measure
PROCEDURE Blow
BEGIN
END Blow
BEGIN
LOOP
Measure
Blow
EXIT
END
END NH3production
Compilation results in :
jan@beryllium:~/modula/Plov$ Plov004 <test6 PROGRAM NH3production CONSTANTS pi = 314159 ee = 271828 years = 2007 days = 31 END VARIABLES temp press NH3 H2SO4 nitrogen END PROCEDURE Measure BEGIN END Measure PROCEDURE Blow BEGIN END Blow BEGIN LOOP Measure Blow EXIT END END NH3production NH3production Program type RETURN Keyword type EXIT Keyword type LOOP Keyword type BEGIN Keyword type END Keyword type IF Keyword type THEN Keyword type ELSIF Keyword type ODD Keyword type PROCEDURE Keyword type PROGRAM Keyword type CONSTANTS Keyword type VARIABLES Keyword type pi Constant type = 314159 ee Constant type = 271828 years Constant type = 2007 days Constant type = 31 temp Variable type press Variable type NH3 Variable type H2SO4 Variable type nitrogen Variable type Measure Procedure type Blow Procedure type jan@beryllium:~/modula/Plov$Even the LOOP/END/EXIT is processed!
Plov004 : compiling source 'fout3'
Testing source :
PROGRAM NH3production CONSTANTS pi = 314159 ee = 271828 years = 2007 days = 31 END VARIABLES temp press NH3 H2SO4 nitrogen END PROCEDURE Measure BEGIN END Measure PROCEDURE Blow BEGIN END Blow BEGIN Measure Blow EXIT END NH3productionCompilation results in :
jan@beryllium:~/modula/Plov$ Plov004 <fout3 PROGRAM NH3production CONSTANTS pi = 314159 ee = 271828 years = 2007 days = 31 END VARIABLES temp press NH3 H2SO4 nitrogen END PROCEDURE Measure BEGIN END Measure PROCEDURE Blow BEGIN END Blow BEGIN Measure Blow EXIT EXIT without LOOP END NH3productionEXIT without LOOP. For the rest: nothing reported. Sounds fine to me.
Plov004 : compiling source 'test7'
Testing source :
PROGRAM assignments CONSTANTS nrOf = 12 PINcode = 1153 ZIPcode = 5012 END VARIABLES aantal sum avg END BEGIN aantal := nrOf sum := sum + PINcode avg := sum / aantal END assignmentsCompilation results in :
jan@beryllium:~/modula/Plov$ Plov004 <test7 PROGRAM assignments CONSTANTS nrOf = 12 PINcode = 1153 ZIPcode = 5012 END VARIABLES aantal sum avg END BEGIN aantal := nrOf sum := sum + PINcode Error in StatementSequence END assignmentsOne error: in 'sum := sum + PINcode', the PINcode triggers an 'Error in StatementSequence'. And the next line 'avg := sum / aantal' is skipped altogether. I think the 'synchronize' function is to blame here.
Plov004 : compiling source 'test...'
The current version of Plov004 compiles all 10 test programs. The placement of GetSymbol is critical!
Page created on 7 October 2007 and
Page equipped with FroogleBuster technology