136 lines
4.9 KiB
JSON
136 lines
4.9 KiB
JSON
{
|
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
"name": "RISC-V Assembly",
|
|
"scopeName": "source.riscv-asm",
|
|
"patterns": [
|
|
{"include": "#comments"},
|
|
{"include": "#labels"},
|
|
{"include": "#directives"},
|
|
{"include": "#instructions"},
|
|
{"include": "#registers"},
|
|
{"include": "#numbers"},
|
|
{"include": "#strings"}
|
|
],
|
|
"repository": {
|
|
"comments": {
|
|
"patterns": [
|
|
{
|
|
"name": "comment.line.number-sign.riscv-asm",
|
|
"begin": "#",
|
|
"end": "$"
|
|
},
|
|
{
|
|
"name": "comment.block.riscv-asm",
|
|
"begin": "/\\*",
|
|
"end": "\\*/"
|
|
}
|
|
]
|
|
},
|
|
"labels": {
|
|
"patterns": [
|
|
{
|
|
"name": "entity.name.function.riscv-asm",
|
|
"match": "^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:"
|
|
}
|
|
]
|
|
},
|
|
"directives": {
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.control.directive.riscv-asm",
|
|
"match": "\\b(\\.text|\\.data|\\.bss|\\.section|\\.global|\\.globl|\\.extern|\\.equ|\\.set|\\.align|\\.balign|\\.word|\\.dword|\\.byte|\\.half|\\.ascii|\\.asciiz|\\.string|\\.zero|\\.space|\\.skip|\\.org|\\.include)\\b"
|
|
}
|
|
]
|
|
},
|
|
"instructions": {
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.mnemonic.arithmetic.riscv-asm",
|
|
"match": "\\b(add|addi|sub|lui|auipc|xor|xori|or|ori|and|andi|sll|slli|srl|srli|sra|srai|slt|slti|sltu|sltiu)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.mnemonic.load-store.riscv-asm",
|
|
"match": "\\b(lb|lh|lw|ld|lbu|lhu|lwu|sb|sh|sw|sd)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.mnemonic.branch.riscv-asm",
|
|
"match": "\\b(beq|bne|blt|bge|bltu|bgeu|jal|jalr)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.mnemonic.system.riscv-asm",
|
|
"match": "\\b(ecall|ebreak|csrrw|csrrs|csrrc|csrrwi|csrrsi|csrrci|fence|fence\\.i)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.mnemonic.multiplication.riscv-asm",
|
|
"match": "\\b(mul|mulh|mulhsu|mulhu|div|divu|rem|remu)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.mnemonic.atomic.riscv-asm",
|
|
"match": "\\b(lr\\.w|sc\\.w|lr\\.d|sc\\.d|amoswap|amoadd|amoxor|amoand|amoor|amomin|amomax|amominu|amomaxu)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.mnemonic.pseudoinstruction.riscv-asm",
|
|
"match": "\\b(nop|li|la|mv|not|neg|seqz|snez|sltz|sgtz|j|jr|ret|call|tail)\\b"
|
|
}
|
|
]
|
|
},
|
|
"registers": {
|
|
"patterns": [
|
|
{
|
|
"name": "variable.language.register.riscv-asm",
|
|
"match": "\\b(x[0-9]|x[12][0-9]|x3[01]|zero|ra|sp|gp|tp|t[0-6]|s[0-9]|s1[01]|a[0-7]|fp)\\b"
|
|
},
|
|
{
|
|
"name": "variable.language.register.floating.riscv-asm",
|
|
"match": "\\b(f[0-9]|f[12][0-9]|f3[01]|ft[0-9]|ft1[01]|fs[0-9]|fs1[01]|fa[0-7])\\b"
|
|
}
|
|
]
|
|
},
|
|
"numbers": {
|
|
"patterns": [
|
|
{
|
|
"name": "constant.numeric.hex.riscv-asm",
|
|
"match": "\\b0[xX][0-9a-fA-F]+\\b"
|
|
},
|
|
{
|
|
"name": "constant.numeric.binary.riscv-asm",
|
|
"match": "\\b0[bB][01]+\\b"
|
|
},
|
|
{
|
|
"name": "constant.numeric.octal.riscv-asm",
|
|
"match": "\\b0[0-7]+\\b"
|
|
},
|
|
{
|
|
"name": "constant.numeric.decimal.riscv-asm",
|
|
"match": "\\b[0-9]+\\b"
|
|
}
|
|
]
|
|
},
|
|
"strings": {
|
|
"patterns": [
|
|
{
|
|
"name": "string.quoted.double.riscv-asm",
|
|
"begin": "\"",
|
|
"end": "\"",
|
|
"patterns": [
|
|
{
|
|
"name": "constant.character.escape.riscv-asm",
|
|
"match": "\\\\."
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "string.quoted.single.riscv-asm",
|
|
"begin": "'",
|
|
"end": "'",
|
|
"patterns": [
|
|
{
|
|
"name": "constant.character.escape.riscv-asm",
|
|
"match": "\\\\."
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
} |