From 9adab54130a0ee61cc0194fe6ed4f05a2694e7e7 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sat, 14 Dec 2019 21:49:55 +0300 Subject: [PATCH] add ERROR directive --- src/generic/Dev/Mod/CPM.cp | 31 ++++++++++++++++--------------- src/generic/Dev/Mod/CPR.cp | 27 +++++++++++++++------------ 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/generic/Dev/Mod/CPM.cp b/src/generic/Dev/Mod/CPM.cp index 97c6b3e..4cbeb50 100644 --- a/src/generic/Dev/Mod/CPM.cp +++ b/src/generic/Dev/Mod/CPM.cp @@ -734,21 +734,6 @@ MODULE DevCPM; | 301: msg := 'implicit type cast' | 302: msg := 'guarded variable can be side-effected' | 303: msg := 'open array (or pointer to array) containing pointers' - | 900: msg := 'never used' - | 901: msg := 'never set' - | 902: msg := 'used before set' - | 903: msg := 'set but never used' - | 904: msg := 'used as varpar, possibly not set' - | 905: msg := 'also declared in outer scope' - | 906: msg := 'access/assignment to intermediate' - | 907: msg := 'redefinition' - | 908: msg := 'new definition' - | 909: msg := 'statement after RETURN/EXIT' - | 910: msg := 'for loop variable set' - | 911: msg := 'implied type guard' - | 912: msg := 'superfluous type guard' - | 913: msg := 'call might depend on evaluation sequence of params.' - | 930: msg := 'superfluous semicolon' | 401: msg := 'bytecode restriction: no structured assignment' | 402: msg := 'bytecode restriction: no procedure types' | 403: msg := 'bytecode restriction: no nested procedures' @@ -757,6 +742,7 @@ MODULE DevCPM; | 411: msg := 'no proofable return' | 412: msg := 'illegal constructor call' | 413: msg := 'missing constructor call' + | 501: msg := 'user defined error' (* COM-related | 700: msg := '700' | 701: msg := '701' @@ -766,6 +752,21 @@ MODULE DevCPM; | 777: msg := 'register not released' | 778: msg := 'float register not released' | 779: msg := 'float register overallocated' + | 900: msg := 'never used' + | 901: msg := 'never set' + | 902: msg := 'used before set' + | 903: msg := 'set but never used' + | 904: msg := 'used as varpar, possibly not set' + | 905: msg := 'also declared in outer scope' + | 906: msg := 'access/assignment to intermediate' + | 907: msg := 'redefinition' + | 908: msg := 'new definition' + | 909: msg := 'statement after RETURN/EXIT' + | 910: msg := 'for loop variable set' + | 911: msg := 'implied type guard' + | 912: msg := 'superfluous type guard' + | 913: msg := 'call might depend on evaluation sequence of params.' + | 930: msg := 'superfluous semicolon' ELSE Strings.IntToString(err, msg) END END GetErrorMsg; diff --git a/src/generic/Dev/Mod/CPR.cp b/src/generic/Dev/Mod/CPR.cp index b43b539..851d82e 100644 --- a/src/generic/Dev/Mod/CPR.cp +++ b/src/generic/Dev/Mod/CPR.cp @@ -7,10 +7,10 @@ MODULE DevCPR; (* symbol values *) null = 0; - if = 1; then = 2; else = 3; elsif = 4; end = 5; new = 6; - ident = 7; plus = 8; minus = 9; - not = 10; and = 11; or = 12; rpar = 13; lpar = 14; - endcom = 15; eof = 16; + if = 1; then = 2; else = 3; elsif = 4; end = 5; + new = 6; error = 7; ident = 8; plus = 9; minus = 10; + not = 11; and = 12; or = 13; rpar = 14; lpar = 15; + endcom = 16; eof = 17; (* func numbers *) var = 0; defined = 1; @@ -74,6 +74,7 @@ MODULE DevCPR; IF name = "END" THEN sym := end ELSIF name = "ELSE" THEN sym := else ELSIF name = "ELSIF" THEN sym := elsif + ELSIF name = "ERROR" THEN sym := error END | "I": Identifier(sym); IF name = "IF" THEN sym := if END | "N": Identifier(sym); IF name = "NEW" THEN sym := new END @@ -200,6 +201,14 @@ MODULE DevCPR; IF top = NIL THEN err(51); fold := 0; If(TRUE) END END End; + PROCEDURE Printable* (): BOOLEAN; + VAR c: Context; + BEGIN + c := top; + WHILE (c # NIL) & c.val DO c := c.next END; + RETURN c = NIL + END Printable; + PROCEDURE Parse*; VAR val: BOOLEAN; s: Selector; BEGIN @@ -209,6 +218,8 @@ MODULE DevCPR; IF sym = ident THEN s := New(name, FALSE); Get(sym) ELSE err(48) END + ELSIF sym = error THEN + IF Printable() THEN err(501) END; Get(sym) ELSIF sym = ident THEN Get(sym); IF sym = plus THEN Old(name).val := TRUE; Get(sym) @@ -238,14 +249,6 @@ MODULE DevCPR; IF sym # endcom THEN err(5) ELSE DevCPM.errpos := DevCPM.curpos - 1 END END Parse; - PROCEDURE Printable* (): BOOLEAN; - VAR c: Context; - BEGIN - c := top; - WHILE (c # NIL) & c.val DO c := c.next END; - RETURN c = NIL - END Printable; - PROCEDURE Check*; BEGIN IF fold # 1 THEN err(14) END -- 2.29.2