Plov011 : findType
The targets for version Plov011 were rather high:
The function parameters are also one bridge too far. At present this would be rather difficult to implement. The major problem is related to the fact that function parameters are optional, so the end of line token playes a key role again. I keep this option for the future. IF it will be implemented the function parameters will be implemented as local variables.
I added quite some code for the PALO checker, even opened a new memorypool to store the PALO codes for easier checking. In the end I concluded that
Plov011 : findType and StatementSequence
The old version of StatementSequence was:
PROCEDURE StatementSequence;
BEGIN
GetSymbol;
LOOP
CG ("");
IF weHaveLocals AND (FindLocal (token) = TRUE) THEN
IF thisLocal^.type = Vartype THEN Assignment END
ELSIF FindSymbol (token) = TRUE THEN
IF (thisSymbol^.type = Vartype) THEN Assignment
ELSIF thisSymbol^.type = Proctype THEN Procedurecall
ELSIF Strings.StrEq (token, "IF") THEN isIF
ELSIF Strings.StrEq (token, "LOOP") THEN isLOOP
ELSIF Strings.StrEq (token, "RETURN") THEN isRETURN
ELSIF Strings.StrEq (token, "WHILE") THEN isWHILE
ELSIF Strings.StrEq (token, "REPEAT") THEN isREPEAT
ELSIF Strings.StrEq (token, "EXIT") THEN isEXIT
ELSIF Strings.StrEq (token, "END") THEN RETURN
ELSIF Strings.StrEq (token, "UNTIL") THEN RETURN
ELSIF Strings.StrEq (token, "ELSIF") THEN RETURN
ELSIF Strings.StrEq (token, "ELSE") THEN RETURN
ELSE
ErrorMessage (10) (* Error in StatementSequence *)
END
ELSE
ErrorMessage (9) (* Undefined symbol *)
END
END
END StatementSequence;
The first four lines after CG ("") are too complex. They were necessitated by the introduction f local
variables, which live in their own memorypool. In order to simplify this (symbol checking would be a major
task in inline PALO checking) I created the findType procedure:
PROCEDURE findType (name : Identifier) : SymbolType;
VAR symPtr : SymbolPtr;
BEGIN
IF weHaveLocals AND (FindLocal (token) = TRUE) THEN
symPtr := thisLocal
ELSIF FindSymbol (token) = TRUE THEN
symPtr := thisSymbol
ELSE
RETURN None
END;
RETURN symPtr^.type
END findType;
This function takes some of the gobbledygook away from StatementSequence and other procedures that need to
perform typechecking of symbols. What it does is:
SymbolType = (Progtype, Proctype, Constype, Vartype, Keytype, None);The new findType function was succesfully implemented in the new StatementSequence:
PROCEDURE StatementSequence;
BEGIN
GetSymbol;
LOOP
CG ("");
IF findType (token) = Vartype THEN Assignment
ELSIF findType (token) = Proctype THEN Procedurecall
ELSIF Strings.StrEq (token, "IF") THEN isIF
ELSIF Strings.StrEq (token, "LOOP") THEN isLOOP
ELSIF Strings.StrEq (token, "RETURN") THEN isRETURN
ELSIF Strings.StrEq (token, "WHILE") THEN isWHILE
ELSIF Strings.StrEq (token, "REPEAT") THEN isREPEAT
ELSIF Strings.StrEq (token, "EXIT") THEN isEXIT
ELSIF Strings.StrEq (token, "END") THEN RETURN
ELSIF Strings.StrEq (token, "UNTIL") THEN RETURN
ELSIF Strings.StrEq (token, "ELSIF") THEN RETURN
ELSIF Strings.StrEq (token, "ELSE") THEN RETURN
ELSE
ErrorMessage (10) (* Error in StatementSequence *)
END
END
END StatementSequence;
I think this procedure is more in the line of Modula-2. It looks neat, does the job and is easier to
understand.
Plov011 : the new PALO
At present, PALO is too complex. It is too 'chatty'. Too clear. It does not comply with one of Wirth's laws:
PALO needs to be simplified without loosing it's readibility. More in Plov012 and the PALO/ALTO section.
Plov12 : PALO 2 codes
Plov012 has been created and runs stable. Which shouldn't be too strange since only a few lines of text have been changed. Plov012 puts out PALO-2 codes. For more information, I refer to the Palo/Alto section on this topic. Use the navigator frame to get there.
Page created on 11 September 2008 and
Page equipped with FroogleBuster technology