From 19fb8eefe2a91612038d0240c65f1e83ca6ee70f Mon Sep 17 00:00:00 2001 From: Jose Rodriguez Date: Sun, 23 Jan 2022 23:12:34 +0100 Subject: [PATCH 1/3] cleanup: fix comment typos --- src/api/symboltable/scope.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/symboltable/scope.py b/src/api/symboltable/scope.py index e2d181cd2..7bd7a4720 100644 --- a/src/api/symboltable/scope.py +++ b/src/api/symboltable/scope.py @@ -29,7 +29,7 @@ class Scope: The caseins dict stores the symbol names in lowercase only if the global OPTION ignore case is enabled (True). This is because - most BASIC dialects are case insensitive. 'caseins' will be used + most BASIC dialects are case-insensitive. 'caseins' will be used as a fallback if the symbol name does not exists. On init() the parent mangle can be stored. The mangle is a prefix @@ -55,7 +55,7 @@ def __getitem__(self, key: str) -> Optional[SymbolVAR]: def __setitem__(self, key: str, value: SymbolVAR): assert isinstance(value, Symbol) self.symbols[key] = value - if value.caseins: # Declared with case insensitive option? + if value.caseins: # Declared with case-insensitive option? self.caseins[key.lower()] = value def __delitem__(self, key: str): From 00f593bd325bbbffaf802f8dae8016dff629e7fc Mon Sep 17 00:00:00 2001 From: Jose Rodriguez Date: Sun, 20 Feb 2022 11:24:35 +0100 Subject: [PATCH 2/3] refact: use Enum value in zxbpp initalization --- src/zxbc/zxbc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zxbc/zxbc.py b/src/zxbc/zxbc.py index 18958d78e..4b663a800 100755 --- a/src/zxbc/zxbc.py +++ b/src/zxbc/zxbc.py @@ -165,7 +165,7 @@ def main(args=None, emitter=None): asm_output = "\n".join(asm_output) # Now filter them against the preprocessor again - zxbpp.setMode("asm") + zxbpp.setMode(zxbpp.PreprocMode.ASM) zxbpp.OUTPUT = "" zxbpp.filter_(asm_output, filename=input_filename) From 8c9b7c7858665ef140efe3fc5aaccf7dfaf92e6c Mon Sep 17 00:00:00 2001 From: Jose Rodriguez Date: Tue, 8 Mar 2022 22:49:39 +0100 Subject: [PATCH 3/3] feat: make while condition warning muteable --- src/zxbc/zxbparser.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/zxbc/zxbparser.py b/src/zxbc/zxbparser.py index 906b261bc..82a26b6ea 100755 --- a/src/zxbc/zxbparser.py +++ b/src/zxbc/zxbparser.py @@ -28,7 +28,7 @@ import src.api.symboltable.symboltable from src.api.debug import __DEBUG__ # analysis:ignore from src.api.opcodestemps import OpcodesTemps -from src.api.errmsg import error +from src.api.errmsg import error, warning_condition_is_always from src.api.errmsg import warning from src.api.global_ import LoopInfo @@ -1869,11 +1869,8 @@ def p_while_sentence(p): gl.LOOPS.pop() q = make_block(p[2], p[3]) - if is_number(p[1]) and p[1].value: - if q is None: - warning(p[1].lineno, "Condition is always true and leads to an infinite loop.") - else: - warning(p[1].lineno, "Condition is always true and might lead to an infinite loop.") + if is_number(p[1]): + warning_condition_is_always(p.lineno(1), bool(p[1].value)) p[0] = make_sentence(p.lineno(1), "WHILE", p[1], q)