Code: Select all
MODULE PrivTestCodeProc; IMPORT SYSTEM;
PROCEDURE {code} Proc1 ,,,,,,,, "", "", "", 9, "", "",,,,,,,, ; (* <= now it compiles! *)
PROCEDURE {code} Proc2 12 34; (* <= error "," comma missing *)
PROCEDURE {code} Proc3 "12" "34"; (* <= error ";" semicolon missing *)
END PrivTestCodeProc.
I suggest a few things:
1. Allowing empty string as a part of a code procedure body does not make sense. It's not even ASCIIZ string! Therefore, when empty string is encountered in the description of a code procedure, I propose to mark it by error "63 illegal value of constant".
2. We must make sure that after comma the following literal (sym = number OR sym = string) always follows. Comma or something else (not number and not string) after comma are not allowed and must be marked as error "13 factor starts with incorrect symbol".
Code procedures with empty body still possible.
The code changes as follows:
This piece of code in text format:
Code: Select all
LOOP
IF sym = number THEN ...
ELSIF sym = string THEN c := DevCPS.intval - 1 (*exclude 0X*);
IF c = 0 (*empty string*) THEN err(63) END; EnsureLen(n + c);
FOR i := 0 TO c - 1 DO s[n + i] := DevCPS.str[i] END;
DevCPS.Get(sym); INC(n, c)
END ;
IF sym = comma THEN DevCPS.Get(sym); IF (sym # number) & (sym # string) THEN err(13) END
ELSIF (sym = number) OR (sym = string) THEN err(comma)
ELSE EXIT
END
END;