Fix HDL and Hack Assembly syntax highlighting and queries

- Fixed HDL highlights query syntax error with #match? predicate
- Replaced #match? with #any-of? for exact string matching
- Fixed Hack Assembly outline query invalid field name
- Improved HDL syntax highlighting with comprehensive patterns
- Added HDL bracket matching for all syntax types
- Fixed XML scope mismatch from text.xml to source.xml
- Enhanced outline queries for better code navigation
This commit is contained in:
2025-09-11 11:24:24 -04:00
commit c231dbfd27
133 changed files with 2792 additions and 0 deletions

26
test-examples/Add.asm Normal file
View File

@@ -0,0 +1,26 @@
// Computes R0 = 2 + 3
@2
D=A
@3
D=D+A
@0
M=D
// Loop example with labels
@i
M=1
(LOOP)
@i
D=M
@10
D=D-A
@END
D;JGT
@i
M=M+1
@LOOP
0;JMP
(END)
@END
0;JMP

5
test-examples/And.cmp Normal file
View File

@@ -0,0 +1,5 @@
| a | b |out|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |

13
test-examples/And.hdl Normal file
View File

@@ -0,0 +1,13 @@
/**
* And gate:
* out = 1 if (a == 1 and b == 1)
* 0 otherwise
*/
CHIP And {
IN a, b;
OUT out;
PARTS:
Nand(a=a, b=b, out=nandOut);
Not(in=nandOut, out=out);
}

23
test-examples/CPU.tst Normal file
View File

@@ -0,0 +1,23 @@
load CPU.hdl,
output-file CPU.out,
compare-to CPU.cmp,
output-list time%S1.3.1 instruction%B0.16.0 pc%D0.5.0;
set instruction %B0011000000111001, // @12345
tick,
output;
tock,
output;
set instruction %B1110110000010000, // D=A
tick,
output;
tock,
output;
repeat 10 {
ticktock;
}
output;

24
test-examples/Math.jack Normal file
View File

@@ -0,0 +1,24 @@
class Math {
static Array twoToThe;
/** Initializes the library. */
function void init() {
var int i;
let twoToThe = Array.new(16);
let twoToThe[0] = 1;
let i = 1;
while (i < 16) {
let twoToThe[i] = twoToThe[i-1] + twoToThe[i-1];
let i = i + 1;
}
return;
}
function int multiply(int x, int y) {
var int sum, shiftedX;
let sum = 0;
let shiftedX = x;
// Implementation details...
return sum;
}
}

View File

@@ -0,0 +1,32 @@
// Stack arithmetic operations
push constant 7
push constant 8
add
// Memory operations
push local 0
push local 1
add
pop local 2
// Function definition
function Math.multiply 2
push constant 0
pop local 0
label LOOP
push local 1
push constant 0
eq
if-goto END
push local 0
push argument 0
add
pop local 0
goto LOOP
label END
push local 0
return