diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-14 03:40:32 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-14 03:40:32 +0000 |
| commit | fed12356ba4cd7c36b10fe5191878c7348d27206 (patch) | |
| tree | cc8c255c1e5f422c3bca9f3546d2d878d5f40cc0 /plugin | |
| parent | 97a7614bf16c27ac0f7c22340f9a0ba0ba716ade (diff) | |
feat(plugin): highlight native C types and imports
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'plugin')
| -rw-r--r-- | plugin/AGENTS/ARCH.md | 4 | ||||
| -rw-r--r-- | plugin/syntaxes/cie-pseudocode.tmLanguage.json | 2 | ||||
| -rw-r--r-- | plugin/test/highlighting.test.js | 10 |
3 files changed, 15 insertions, 1 deletions
diff --git a/plugin/AGENTS/ARCH.md b/plugin/AGENTS/ARCH.md index 8215615..b25a6d7 100644 --- a/plugin/AGENTS/ARCH.md +++ b/plugin/AGENTS/ARCH.md @@ -76,6 +76,10 @@ interrupt an interactive program with Ctrl+C before running another file. Follow the current compiler, rather than implementing every PDF feature: - Uppercase, case-sensitive keywords; ASCII `<-` assignment; `//` comments. +- Native C aliases C_INT/C_CHAR/C_STRING/C_DOUBLE and the C_TYPE import keyword + use type scopes. C_TYPE's quoted expression remains a string, and casts use + ordinary parentheses. `TYPE Name = C_TYPE("...")` is a single-line alias + declaration, so it does not open an indentation block. - Double-quoted strings and single-quoted characters have no escapes or multiline continuation. The compiler accepts `'''` as a quote character literal. - Blocks: IF/THEN/ELSE/ENDIF, WHILE/DO/ENDWHILE, REPEAT/UNTIL, FOR/NEXT, diff --git a/plugin/syntaxes/cie-pseudocode.tmLanguage.json b/plugin/syntaxes/cie-pseudocode.tmLanguage.json index fe3582c..191eec2 100644 --- a/plugin/syntaxes/cie-pseudocode.tmLanguage.json +++ b/plugin/syntaxes/cie-pseudocode.tmLanguage.json @@ -29,7 +29,7 @@ "name": "storage.modifier.cie-pseudocode" }, { - "match": "(?<!\\w)(?:INTEGER|REAL|BOOLEAN|STRING|CHAR|ARRAY)(?!\\w)", + "match": "(?<!\\w)(?:INTEGER|REAL|BOOLEAN|STRING|CHAR|ARRAY|C_INT|C_CHAR|C_STRING|C_DOUBLE|C_TYPE)(?!\\w)", "name": "storage.type.cie-pseudocode" }, { diff --git a/plugin/test/highlighting.test.js b/plugin/test/highlighting.test.js index 0f677a3..f7a67db 100644 --- a/plugin/test/highlighting.test.js +++ b/plugin/test/highlighting.test.js @@ -33,6 +33,11 @@ test('C++ style scopes distinguish keywords, types, literals, operators and buil ['IF Ready THEN', 'IF', 'keyword.control'], ['DECLARE X : INTEGER', 'DECLARE', 'storage.modifier'], ['DECLARE X : INTEGER', 'INTEGER', 'storage.type'], + ['DECLARE X : C_INT', 'C_INT', 'storage.type'], + ['DECLARE X : C_CHAR', 'C_CHAR', 'storage.type'], + ['DECLARE X : C_STRING', 'C_STRING', 'storage.type'], + ['OUTPUT (C_DOUBLE)X', 'C_DOUBLE', 'storage.type'], + ['TYPE Native = C_TYPE("int")', 'C_TYPE', 'storage.type'], ['X <- TRUE', 'TRUE', 'constant.language'], ['X <- 12.5', '12.5', 'constant.numeric'], ['X <- 2 DIV 1', 'DIV', 'keyword.operator.word'], @@ -72,6 +77,11 @@ test('exception keywords reuse C++ scopes and ignore non-keyword occurrences', ( test('comments, strings, lowercase and keyword prefixes cannot become keywords', () => { assert.ok(scopesAt('// IF [(', 'IF').some(s => s.startsWith('comment.'))); assert.ok(scopesAt('OUTPUT "IF // ["', 'IF').some(s => s.startsWith('string.'))); + assert.ok(scopesAt('TYPE Native = C_TYPE("C_INT")', 'C_INT').some(s => s.startsWith('string.'))); + assert.ok(scopesAt('// C_TYPE("int")', 'C_TYPE').some(s => s.startsWith('comment.'))); + for (const text of ['c_int', 'C_INTValue', 'MyC_INT', 'C_TYPE_1']) { + assert.ok(!scopesAt(text, text).some(s => s.startsWith('storage.')), text); + } for (const text of ['if X then', 'IFValue <- 1', 'CASE OF X', 'CLASS Example']) { assert.ok(!scopesAt(text, text.split(' ')[0]).some( s => /^(keyword|storage)\./.test(s)), text); |
