From 4ac62056efd637c13b500ed1c26ca6f2a739b095 Mon Sep 17 00:00:00 2001 From: Stephen M Moraco Date: Wed, 7 Dec 2022 23:38:29 -0700 Subject: [PATCH] add MODCZ operand constants (Spin2) - turn off debug log in prep for release --- spin2/CHANGELOG.md | 18 +++--- spin2/TEST/spin2/221206-fixes.spin2 | 10 ++++ spin2/src/spin1.semanticAndOutline.ts | 2 +- spin2/src/spin2.semanticAndOutline.ts | 55 ++++++++++++++++--- .../syntaxes/spin2.tmLanguage.YAML-tmLanguage | 7 +++ spin2/syntaxes/spin2.tmLanguage.json | 10 ++++ 6 files changed, 86 insertions(+), 16 deletions(-) diff --git a/spin2/CHANGELOG.md b/spin2/CHANGELOG.md index a761617..16b1357 100644 --- a/spin2/CHANGELOG.md +++ b/spin2/CHANGELOG.md @@ -22,7 +22,7 @@ Possible next additions: - Add new-file templates as Snippets - Add additional Snippets as the community identifies them -## [1.7.2] 2022-12-06 +## [1.7.2] 2022-12-07 Update Spin highlighting (syntax and/or semantic parser fixes) @@ -35,11 +35,18 @@ Update Spin2 highlighting (syntax and/or semantic parser fixes) - Spin2: Recognize non-float decimal numbers with exponents - Spin2: Recognize `debug_main` and `debug_coginit` compile time directives - Spin2: Recognize event names in pasm2 correctly -- Spin2: Fix cases where 'debug' used without parenthesis causes extension crash +- Spin2: Fix cases where `debug` used without parenthesis causes extension crash - Spin2: Recognize coginit constants (some pasm2 cases were being missed) -- Spin2: Add recognition of LutColors directive in debug statements with run-time termainal assignment +- Spin2: Add recognition of LutColors directive in debug statements with run-time terminal assignment +- Spin2: Recognize `modcz` operand constants -**NOTE:** *There is no change in our "Known Issues" list for this release.* +### - Known Issues w/v1.7.2 + +- We haven't yet learned how to control the ending position of the edit cursor. So in many cases when using selection, not an insert point, the cursor may end up not being where you might expect it to be after pressing TAB or Shift+TAB. We are looking into how to solve this. Even tho' this problem exists the formatting ability this new service provides is well worth this minor headache. We will keep looking for a means to get this under control. +- The single-quote comment (now only on debug statements) is being handled by the semantic (vs. syntactic) parser this is causing external VSCode extensions to do brace, parenthesis, and bracket paring to be marked within trailing line comments on debug lines +- Syntax highlight of DAT section sometimes fails... (although it is less often now...) +- Semantic highlight: the 'modification' attribute is being over-applied, should use more than := as test!!!! +- *I'm sure there are more issues...* ## [1.7.1] 2022-12-05 @@ -55,7 +62,6 @@ Update to keyboard mapping: All key mapping now reenabled and Align mode now ful - The single-quote comment (now only on debug statements) is being handled by the semantic (vs. syntactic) parser this is causing external VSCode extensions to do brace, parenthesis, and bracket paring to be marked within trailing line comments on debug lines - Syntax highlight of DAT section sometimes fails... (although it is less often now...) - Semantic highlight: the 'modification' attribute is being over-applied, should use more than := as test!!!! -- *I'm sure there are more issues...* ## [1.7.0] 2022-12-02 @@ -77,7 +83,6 @@ Fun Update! First release of two **NEW** features and more. - The single-quote comment (now only on debug statements) is being handled by the semantic (vs. syntactic) parser this is causing external VSCode extensions to do brace, parenthesis, and bracket paring to be marked within trailing line comments on debug lines - Syntax highlight of DAT section sometimes fails... (although it is less often now...) - Semantic highlight: the 'modification' attribute is being over-applied, should use more than := as test!!!! -- *I'm sure there are more issues...* ## [1.6.1] 2022-11-29 @@ -95,7 +100,6 @@ Minor update to the formal release (*clean up muli-line behavior, clean up in-li - Syntax highlight of DAT section sometimes fails... (although it is less often now...) - Semantic highlight: the 'modification' attribute is being over-applied, should use more than := as test!!!! - ## [1.6.0] 2022-11-28 First formal release - Update for tabbing. Now operates according to latest Spec. diff --git a/spin2/TEST/spin2/221206-fixes.spin2 b/spin2/TEST/spin2/221206-fixes.spin2 index a6deb77..1139e54 100644 --- a/spin2/TEST/spin2/221206-fixes.spin2 +++ b/spin2/TEST/spin2/221206-fixes.spin2 @@ -126,3 +126,13 @@ pasm_program debug 'do a DEBUG at the start of the program to open debugger jmp #.loop long 0[12] 'fill with some NOP's to make it easy to see the code above +' ----------------------------------------------------------------- +DAT + org + ' $1F8..$1F9 = ptra_, ptrb_ +' $1FA..$1FF = direct +' $200..$3FF = lut +' +rdreg modz _clr wz 'force read BUG: "_clr" is RED + +' ----------------------------------------------------------------- diff --git a/spin2/src/spin1.semanticAndOutline.ts b/spin2/src/spin1.semanticAndOutline.ts index bea3e4b..94ea67c 100644 --- a/spin2/src/spin1.semanticAndOutline.ts +++ b/spin2/src/spin1.semanticAndOutline.ts @@ -2621,7 +2621,7 @@ export class Spin1DocumentSemanticTokensProvider implements vscode.DocumentSeman private spin1log: any = undefined; // adjust following true/false to show specific parsing debug - private spin1DebugLogEnabled: boolean = true; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit + private spin1DebugLogEnabled: boolean = false; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit private showSpinCode: boolean = true; private showCON: boolean = true; private showOBJ: boolean = true; diff --git a/spin2/src/spin2.semanticAndOutline.ts b/spin2/src/spin2.semanticAndOutline.ts index 4e0b993..140fdf9 100644 --- a/spin2/src/spin2.semanticAndOutline.ts +++ b/spin2/src/spin2.semanticAndOutline.ts @@ -1570,6 +1570,7 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman !this._isBinaryOperator(namePart) && !this._isBuiltinReservedWord(namePart) && !this._isCoginitReservedSymbol(namePart) && + !this._isPasmModczOperand(namePart) && !this._isDebugMethod(namePart) && !bIsAlsoDebugLine ) { @@ -3287,7 +3288,7 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman private spin2log: any = undefined; // adjust following true/false to show specific parsing debug - private spin2DebugLogEnabled: boolean = true; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit + private spin2DebugLogEnabled: boolean = false; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit private showSpinCode: boolean = true; private showCON: boolean = true; private showOBJ: boolean = true; @@ -4360,6 +4361,45 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman return reservedStatus; } + private _isPasmModczOperand(name: string): boolean { + const pasmModczOperand: string[] = [ + "_clr", + "_nc_and_nz", + "_nz_and_nc", + " _gt", + "_nc_and_z", + "_z_and_nc", + "_nc", + "_ge", + "_c_and_nz", + "_nz_and_c", + "_nz", + "_ne", + "_c_ne_z", + "_z_ne_c", + "_nc_or_nz", + "_nz_or_nc", + "_c_and_z", + "_z_and_c", + "_c_eq_z", + "_z_eq_c", + "_z", + "_e", + "_nc_or_z", + "_z_or_nc", + "_c", + "_lt", + "_c_or_nz", + "_nz_or_c", + "_c_or_z", + "_z_or_c", + "_le", + "_set", + ]; + const reservedStatus: boolean = pasmModczOperand.indexOf(name.toLowerCase()) != -1; + return reservedStatus; + } + private _isSpinBuiltinMethod(name: string): boolean { const spinMethodNames: string[] = [ "akpin", @@ -4446,7 +4486,6 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman private _isPasmReservedWord(name: string): boolean { const pasmReservedswordsOfNote: string[] = [ - // EVENT_(INT|CT1|CT2|CT3|SE1|SE2|SE3|SE4|PAT|FBW|XMT|XFI|XRO|XRL|ATN|QMT) "ijmp1", "ijmp2", "ijmp3", @@ -4475,10 +4514,6 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman "addbits", "true", "false", - //'eventse1', 'eventse2', 'eventse3', 'eventse4', - //'eventct1', 'eventct2', 'eventct3', 'eventct4', - //'eventpat', 'eventfbw', 'eventxmt', 'eventxfi', - //'eventxro', 'eventxrl', 'eventatn', 'eventqmt' ]; const reservedStatus: boolean = pasmReservedswordsOfNote.indexOf(name.toLowerCase()) != -1; return reservedStatus; @@ -4975,8 +5010,10 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman if (name.length > 2) { const checkType: string = name.toUpperCase(); // yeah, FILE too! (oddly enough) - if (checkType == "BYTEFIT" || checkType == "WORDFIT" || checkType == "BYTE" || checkType == "WORD" || checkType == "LONG" || checkType == "RES" || checkType == "FILE") { + if (checkType == "FILE") { returnStatus = true; + } else { + returnStatus = this._isDatStorageType(name); } } return returnStatus; @@ -4986,8 +5023,10 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman let returnStatus: boolean = false; if (name.length > 2) { const checkType: string = name.toUpperCase(); - if (checkType == "BYTEFIT" || checkType == "WORDFIT" || checkType == "BYTE" || checkType == "WORD" || checkType == "LONG" || checkType == "RES") { + if (checkType == "RES") { returnStatus = true; + } else { + returnStatus = this._isStorageType(name); } } return returnStatus; diff --git a/spin2/syntaxes/spin2.tmLanguage.YAML-tmLanguage b/spin2/syntaxes/spin2.tmLanguage.YAML-tmLanguage index 94a4dbe..a63f5ce 100644 --- a/spin2/syntaxes/spin2.tmLanguage.YAML-tmLanguage +++ b/spin2/syntaxes/spin2.tmLanguage.YAML-tmLanguage @@ -248,6 +248,8 @@ repository: include: '#cog_register_names' - include: '#coginit_constants' + - + include: '#modcz_constants' - name: storage.modifier.pasm2 match: '(?i)\b(ORG(F|H)?|FIT)\b' @@ -445,6 +447,8 @@ repository: include: '#cog_register_names' - include: '#coginit_constants' + - + include: '#modcz_constants' - name: storage.type.pasm.spin2 match: '(?i)\b(BYTE|WORD|BYTEFIT|WORDFIT|LONG)\b' @@ -499,6 +503,9 @@ repository: event_constants: name: constant.language.events-interrupts.spin2 match: '(?i)\bEVENT_(INT|CT1|CT2|CT3|SE1|SE2|SE3|SE4|PAT|FBW|XMT|XFI|XRO|XRL|ATN|QMT)\b' + modcz_constants: + name: constant.language.modcz.operands.spin2 + match: '(?i)\b((_c(_and_nz|_and_z|eq_z|ne_z|or_nz|or_z)?|_(clr|e|ge|gt|le|lt|ne|set)?|_nc(_and_nz|and_z|or_nz|or_z)?|_nz(_and_c|_and_nc|_or_c|_or_nc)?|_z(_and_c|_and_nc|_eq_c|_ne_c|_or_c|_or_nc)?))\b' smartpins_constants: name: meta.block.spin.language.spin2 patterns: diff --git a/spin2/syntaxes/spin2.tmLanguage.json b/spin2/syntaxes/spin2.tmLanguage.json index c9d7871..29e9dd1 100644 --- a/spin2/syntaxes/spin2.tmLanguage.json +++ b/spin2/syntaxes/spin2.tmLanguage.json @@ -381,6 +381,9 @@ { "include": "#coginit_constants" }, + { + "include": "#modcz_constants" + }, { "name": "storage.modifier.pasm2", "match": "(?i)\\b(ORG(F|H)?|FIT)\\b" @@ -662,6 +665,9 @@ { "include": "#coginit_constants" }, + { + "include": "#modcz_constants" + }, { "name": "storage.type.pasm.spin2", "match": "(?i)\\b(BYTE|WORD|BYTEFIT|WORDFIT|LONG)\\b" @@ -736,6 +742,10 @@ "name": "constant.language.events-interrupts.spin2", "match": "(?i)\\bEVENT_(INT|CT1|CT2|CT3|SE1|SE2|SE3|SE4|PAT|FBW|XMT|XFI|XRO|XRL|ATN|QMT)\\b" }, + "modcz_constants": { + "name": "constant.language.modcz.operands.spin2", + "match": "(?i)\\b((_c(_and_nz|_and_z|eq_z|ne_z|or_nz|or_z)?|_(clr|e|ge|gt|le|lt|ne|set)?|_nc(_and_nz|and_z|or_nz|or_z)?|_nz(_and_c|_and_nc|_or_c|_or_nc)?|_z(_and_c|_and_nc|_eq_c|_ne_c|_or_c|_or_nc)?))\\b" + }, "smartpins_constants": { "name": "meta.block.spin.language.spin2", "patterns": [