mirror of
https://github.com/soconnor0919/nand2tetris-zed.git
synced 2025-12-15 16:44:43 -05:00
- 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
88 lines
2.6 KiB
Scheme
88 lines
2.6 KiB
Scheme
; Enhanced HDL syntax highlighting based on actual usage patterns
|
|
|
|
; Main keywords
|
|
"CHIP" @keyword
|
|
"IN" @keyword
|
|
"OUT" @keyword
|
|
"PARTS" @keyword
|
|
"BUILTIN" @keyword
|
|
"CLOCKED" @keyword
|
|
|
|
; Section headers
|
|
(in_section) @keyword
|
|
(out_section) @keyword
|
|
(parts_body) @keyword
|
|
|
|
; Chip definition
|
|
(chip_definition
|
|
name: (identifier) @type) @type
|
|
|
|
; Pin definitions with proper field highlighting
|
|
(in_section
|
|
input_pin_name: (identifier) @variable.parameter) @variable.parameter
|
|
|
|
(out_section
|
|
output_pin_name: (identifier) @variable.parameter) @variable.parameter
|
|
|
|
; Bus identifiers (arrays)
|
|
(bus_identifier
|
|
(identifier) @variable
|
|
"[" @punctuation.bracket
|
|
(number) @constant.numeric
|
|
"]" @punctuation.bracket) @variable
|
|
|
|
; Part instantiations
|
|
(part
|
|
chip_name: (identifier) @function) @function
|
|
|
|
; Connections
|
|
(connection
|
|
part_pin: (identifier) @variable.parameter
|
|
"=" @operator
|
|
chip_pin: (identifier) @variable) @variable
|
|
|
|
; Built-in chip references
|
|
(builtin_body
|
|
chip_name: (identifier) @function.builtin) @function.builtin
|
|
|
|
; Clocked body
|
|
(clocked_body
|
|
(identifier) @variable) @variable
|
|
|
|
; Comments (both single-line and multi-line)
|
|
(comment) @comment
|
|
|
|
; Numbers
|
|
(number) @constant.numeric
|
|
|
|
; Identifiers (general)
|
|
(identifier) @variable
|
|
|
|
; Punctuation
|
|
"," @punctuation.delimiter
|
|
";" @punctuation.delimiter
|
|
":" @punctuation.delimiter
|
|
"(" @punctuation.bracket
|
|
")" @punctuation.bracket
|
|
"[" @punctuation.bracket
|
|
"]" @punctuation.bracket
|
|
"{" @punctuation.bracket
|
|
"}" @punctuation.bracket
|
|
"=" @operator
|
|
|
|
; Special highlighting for common HDL patterns
|
|
; Bit width specifications (simplified - no regex matching)
|
|
(bus_identifier
|
|
(identifier) @type)
|
|
|
|
; Common built-in chips (simplified - no regex matching)
|
|
(identifier) @function.builtin
|
|
(#any-of? @function.builtin "Nand" "Not" "And" "Or" "Xor" "Mux" "DMux" "Not16" "And16" "Or16" "Xor16" "Mux16" "DMux16" "Mux4Way16" "Mux8Way16" "DMux4Way" "DMux8Way" "Or8Way" "HalfAdder" "FullAdder" "Add16" "Inc16" "ALU" "Bit" "Register" "PC" "RAM8" "RAM64" "RAM512" "RAM4K" "RAM16K" "ROM32K" "Screen" "Keyboard" "DFF" "ARegister" "DRegister")
|
|
|
|
; Common control signals (simplified - no regex matching)
|
|
(identifier) @variable.builtin
|
|
(#any-of? @variable.builtin "load" "sel" "in" "out" "reset" "inc" "true" "false" "a" "b" "c" "d" "e" "f" "g" "h" "x" "y" "zx" "nx" "zy" "ny" "f" "no" "zr" "ng" "pos" "neg" "zero" "one" "minus_one")
|
|
|
|
; Memory address patterns (simplified - no regex matching)
|
|
(identifier) @variable.parameter
|
|
(#any-of? @variable.parameter "address" "load" "write" "read" "data" "value" "input" "output" "control" "enable" "disable" "clock" "reset" "clear" "set" "toggle") |