Skip to content

Commit

Permalink
add linker script language (helix-editor#9835)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoohey31 authored Mar 9, 2024
1 parent fd89c3c commit e3c6c82
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 0 deletions.
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
| kdl |||| |
| kotlin || | | `kotlin-language-server` |
| latex ||| | `texlab` |
| ld || || |
| lean || | | `lean` |
| ledger || | | |
| llvm |||| |
Expand Down
12 changes: 12 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3273,3 +3273,15 @@ indent = { tab-width = 4, unit = " " }
[[grammar]]
name = "powershell"
source = { git = "https://github.com/airbus-cert/tree-sitter-powershell", rev = "c9316be0faca5d5b9fd3b57350de650755f42dc0" }

[[language]]
name = "ld"
scope = "source.ld"
injection-regex = "ld"
file-types = ["ld"]
block-comment-tokens = { start = "/*", end = "*/" }
indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "ld"
source = { git = "https://github.com/mtoohey31/tree-sitter-ld", rev = "81978cde3844bfc199851e39c80a20ec6444d35e" }
173 changes: 173 additions & 0 deletions runtime/queries/ld/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
; Identifiers

(section
.
(NAME) @namespace)

(NAME) @variable

; Operators

[
"="
"+="
"-="
"*="
"/="
"<<="
">>="
"&="
"|="
"^="
"*"
"/"
"%"
"+"
"-"
"<<"
">>"
"=="
"!="
"<="
">="
"<"
">"
"&"
"^"
"|"
"&&"
"||"
"?"
] @operator

; Keywords

[
"ABSOLUTE"
"ADDR"
"ALIGNOF"
"ASSERT"
"BYTE"
"CONSTANT"
"DATA_SEGMENT_ALIGN"
"DATA_SEGMENT_END"
"DATA_SEGMENT_RELRO_END"
"DEFINED"
"LOADADDR"
"LOG2CEIL"
"LONG"
"MAX"
"MIN"
"NEXT"
"QUAD"
"SHORT"
"SIZEOF"
"SQUAD"
"FILL"
"SEGMENT_START"
] @function.builtin

[
"CONSTRUCTORS"
"CREATE_OBJECT_SYMBOLS"
"LINKER_VERSION"
"SIZEOF_HEADERS"
] @constant.builtin

[
"AFTER"
"ALIGN"
"ALIGN_WITH_INPUT"
"ASCIZ"
"AS_NEEDED"
"AT"
"BEFORE"
"BIND"
"BLOCK"
"COPY"
"DSECT"
"ENTRY"
"EXCLUDE_FILE"
"EXTERN"
"extern"
"FLOAT"
"FORCE_COMMON_ALLOCATION"
"FORCE_GROUP_ALLOCATION"
"global"
"GROUP"
"HIDDEN"
"HLL"
"INCLUDE"
"INFO"
"INHIBIT_COMMON_ALLOCATION"
"INPUT"
"INPUT_SECTION_FLAGS"
"KEEP"
"l"
"LD_FEATURE"
"len"
"LENGTH"
"local"
"MAP"
"MEMORY"
"NOCROSSREFS"
"NOCROSSREFS_TO"
"NOFLOAT"
"NOLOAD"
"o"
"ONLY_IF_RO"
"ONLY_IF_RW"
"org"
"ORIGIN"
"OUTPUT"
"OUTPUT_ARCH"
"OUTPUT_FORMAT"
"OVERLAY"
"PHDRS"
"PROVIDE"
"PROVIDE_HIDDEN"
"READONLY"
"REGION_ALIAS"
"REVERSE"
"SEARCH_DIR"
"SECTIONS"
"SORT"
"SORT_BY_ALIGNMENT"
"SORT_BY_INIT_PRIORITY"
"SORT_BY_NAME"
"SORT_NONE"
"SPECIAL"
"STARTUP"
"SUBALIGN"
"SYSLIB"
"TARGET"
"TYPE"
"VERSION"
] @keyword

; Delimiters

[
","
";"
"&"
":"
">"
] @punctuation.delimiter

[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket

; Literals

(INT) @constant.numeric.integer

; Comment

(comment) @comment
12 changes: 12 additions & 0 deletions runtime/queries/ld/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
(sections)
(memory)
(section)
(phdrs)
(overlay_section)
(version)
(vers_node)
(vers_defns)
] @indent

"}" @outdent @extend.prevent-once
2 changes: 2 additions & 0 deletions runtime/queries/ld/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))

0 comments on commit e3c6c82

Please sign in to comment.