feat: add Linkerscript (#5693)

This commit is contained in:
Amaan Qureshi 2023-11-19 04:10:52 -05:00 committed by GitHub
parent b016211057
commit d876296476
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 193 additions and 0 deletions

View file

@ -284,6 +284,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [latex](https://github.com/latex-lsp/tree-sitter-latex) (maintained by @theHamsta, @clason)
- [x] [ledger](https://github.com/cbarrete/tree-sitter-ledger) (maintained by @cbarrete)
- [x] [leo](https://github.com/r001/tree-sitter-leo) (maintained by @r001)
- [x] [linkerscript](https://github.com/amaanq/tree-sitter-linkerscript) (maintained by @amaanq)
- [x] [liquidsoap](https://github.com/savonet/tree-sitter-liquidsoap) (maintained by @toots)
- [x] [llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) (maintained by @benwilliamgraham)
- [x] [lua](https://github.com/MunifTanjim/tree-sitter-lua) (maintained by @muniftanjim)

View file

@ -332,6 +332,9 @@
"leo": {
"revision": "23a9534d09d523d0dcee7dbf89e7c819e6835f6f"
},
"linkerscript": {
"revision": "f99011a3554213b654985a4b0a65b3b032ec4621"
},
"liquidsoap": {
"revision": "91d2708e12a5869154a85190b13ac89cb1414189"
},

View file

@ -1017,6 +1017,15 @@ list.llvm = {
maintainers = { "@benwilliamgraham" },
}
list.linkerscript = {
install_info = {
url = "https://github.com/amaanq/tree-sitter-linkerscript",
files = { "src/parser.c" },
},
filetype = "ld",
maintainers = { "@amaanq" },
}
list.liquidsoap = {
install_info = {
url = "https://github.com/savonet/tree-sitter-liquidsoap",

View file

@ -0,0 +1,6 @@
[
(sections_command)
(output_section)
(memory_command)
(phdrs_command)
] @fold

View file

@ -0,0 +1,146 @@
; Keywords
[
"ENTRY"
"SECTIONS"
"AT"
"OVERLAY"
"NOCROSSREFS"
"MEMORY"
"PHDRS"
"FILEHDR"
] @keyword
; Conditionals
(conditional_expression [ "?" ":" ] @conditional.ternary)
; Variables
(symbol) @variable
(filename) @string.special @text.underline
; Functions
(call_expression
function: (symbol) @function.call)
((call_expression
function: (symbol) @preproc)
(#eq? @preproc "DEFINED"))
((call_expression
function: (symbol) @function.builtin)
(#any-of? @function.builtin
"ABSOLUTE" "ALIAS" "ADDR" "ALIGN" "ALIGNOF" "BASE" "BLOCK" "CHIP" "DATA_SEGMENT_ALIGN"
"DATA_SEGMENT_END" "DATA_SEGMENT_RELRO_END" "END" "LENGTH" "LOADADDR" "LOG2CEIL" "MAX" "MIN"
"NEXT" "ORIGIN" "SEGMENT_START" "SIZEOF" "BYTE" "FILL" "LONG" "SHORT" "QUAD" "SQUAD" "WORD"))
[
"KEEP"
"PROVIDE"
"PROVIDE_HIDDEN"
] @function.builtin
; Types
(section_type "(" [ "NOLOAD" "DSECT" "COPY" "INFO" "OVERLAY" ] @type.builtin ")")
; Fields
[
"ORIGIN" "org" "o"
"LENGTH" "len" "l"
] @field.builtin
; Constants
((symbol) @constant
(#lua-match? @constant "^[%u_][%u%d_]+$"))
; Labels
(entry_command name: (symbol) @label)
(output_section name: (symbol) @label)
(memory_command name: (symbol) @label)
(phdrs_command name: (symbol) @label)
(region ">" (symbol) @label)
(lma_region ">" (symbol) @label)
(phdr ":" (symbol) @label)
([(symbol) (filename)] @label
(#lua-match? @label "^%."))
; Exceptions
"ASSERT" @exception
[
"/DISCARD/"
"."
] @variable.builtin
; Operators
[
"+"
"-"
"*"
"/"
"%"
"||"
"&&"
"|"
"&"
"=="
"!="
">"
">="
"<="
"<"
"<<"
">>"
"!"
"~"
"="
"+="
"-="
"*="
"/="
"<<="
">>="
"&="
"|="
] @operator
; Literals
(number) @number
(quoted_symbol) @string
(wildcard_pattern [ "*" "[" "]" ] @character.special)
(attributes) @character.special
; Punctuation
[ "{" "}" "(" ")" ] @punctuation.bracket
[
":"
";"
] @punctuation.delimiter
">" @punctuation.special
; Comments
(comment) @comment @spell

View file

@ -0,0 +1,11 @@
[
(sections_command)
(output_section)
(memory_command)
(phdrs_command)
] @indent.begin
[
"}"
")"
] @indent.branch @indent.end

View file

@ -0,0 +1,2 @@
((comment)
(#set! injection.language "comment"))

View file

@ -0,0 +1,15 @@
; References
[
(symbol)
(filename)
(quoted_symbol)
] @reference
; Definitions
(output_section name: (symbol) @definition.var)
(memory_command name: (symbol) @definition.var)
(phdrs_command name: (symbol) @definition.var)