mirror of
https://github.com/bearlanguageorg/bear.git
synced 2026-08-26 15:17:19 +00:00
Extension update for vasm
This commit is contained in:
@@ -487,8 +487,10 @@ contents (arrays rendered as `[1, 2, ...]`).
|
|||||||
(functions, structs, enums, constants, locals, and stdlib module functions),
|
(functions, structs, enums, constants, locals, and stdlib module functions),
|
||||||
and hover (symbol kind + line). The `extension/` folder contains a VS Code
|
and hover (symbol kind + line). The `extension/` folder contains a VS Code
|
||||||
client (`code --install-extension extension/` after `npm install` in
|
client (`code --install-extension extension/` after `npm install` in
|
||||||
`extension/`) with syntax highlighting, or point any other LSP client at
|
`extension/`) with syntax highlighting for `.vr` / `.vrmm` source and
|
||||||
`vr lsp`.
|
`.vasm` assembly (labels, `.global` directives, and mnemonics; the
|
||||||
|
assembly language gets highlighting only — no language server), or point
|
||||||
|
any other LSP client at `vr lsp`.
|
||||||
|
|
||||||
## Releases
|
## Releases
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
//
|
//
|
||||||
// Spawns `vr lsp` (the toolchain's built-in language server) and wires up
|
// Spawns `vr lsp` (the toolchain's built-in language server) and wires up
|
||||||
// diagnostics, go-to-definition, and hover for .vr / .vrmm files.
|
// diagnostics, go-to-definition, and hover for .vr / .vrmm files.
|
||||||
|
// .vasm files get their own language (vuurraaf-asm) with dedicated syntax
|
||||||
|
// highlighting but no language server, since the server compiles .vr source.
|
||||||
// The toolchain binary defaults to `vr` on PATH; override it with the
|
// The toolchain binary defaults to `vr` on PATH; override it with the
|
||||||
// `vuurraaf.toolchainPath` setting.
|
// `vuurraaf.toolchainPath` setting.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"comments": {
|
||||||
|
"lineComment": ";"
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
-1
@@ -13,7 +13,8 @@
|
|||||||
"Linters"
|
"Linters"
|
||||||
],
|
],
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
"onLanguage:vuurraaf"
|
"onLanguage:vuurraaf",
|
||||||
|
"onLanguage:vuurraaf-asm"
|
||||||
],
|
],
|
||||||
"main": "./client/extension.js",
|
"main": "./client/extension.js",
|
||||||
"contributes": {
|
"contributes": {
|
||||||
@@ -29,6 +30,17 @@
|
|||||||
".vrmm"
|
".vrmm"
|
||||||
],
|
],
|
||||||
"configuration": "./language-configuration.json"
|
"configuration": "./language-configuration.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "vuurraaf-asm",
|
||||||
|
"aliases": [
|
||||||
|
"VuurRaaf Assembly",
|
||||||
|
"vasm"
|
||||||
|
],
|
||||||
|
"extensions": [
|
||||||
|
".vasm"
|
||||||
|
],
|
||||||
|
"configuration": "./language-configuration-vasm.json"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"grammars": [
|
"grammars": [
|
||||||
@@ -36,6 +48,11 @@
|
|||||||
"language": "vuurraaf",
|
"language": "vuurraaf",
|
||||||
"scopeName": "source.vuurraaf",
|
"scopeName": "source.vuurraaf",
|
||||||
"path": "./syntaxes/vuurraaf.tmLanguage.json"
|
"path": "./syntaxes/vuurraaf.tmLanguage.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language": "vuurraaf-asm",
|
||||||
|
"scopeName": "source.vuurraaf-asm",
|
||||||
|
"path": "./syntaxes/vuurraaf-asm.tmLanguage.json"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"configuration": {
|
"configuration": {
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||||
|
"name": "VuurRaaf Assembly",
|
||||||
|
"scopeName": "source.vuurraaf-asm",
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#comments"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#directives"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#labels"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#mnemonics"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#strings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#numbers"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#operands"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"comments": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "comment.line.semicolon.vuurraaf-asm",
|
||||||
|
"match": ";.*$"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"directives": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "keyword.other.directive.vuurraaf-asm",
|
||||||
|
"match": "^\\s*(\\.[a-zA-Z_][a-zA-Z0-9_]*)\\b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "meta.label.vuurraaf-asm",
|
||||||
|
"match": "^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:\\s*$",
|
||||||
|
"captures": {
|
||||||
|
"1": {
|
||||||
|
"name": "entity.name.function.vuurraaf-asm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"mnemonics": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "keyword.control.vuurraaf-asm",
|
||||||
|
"match": "\\b(halt|push_int|push_str|load|store|pop|dup|add|sub|mul|div|mod|neg|eq|ne|lt|le|gt|ge|and|or|not|jmp|jz|jnz|call|ret|retv|print|println|assert|enter|mkarray|aget|aset|alen|apush|mkstruct|sget|sset)\\b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"strings": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "string.quoted.double.vuurraaf-asm",
|
||||||
|
"begin": "\"",
|
||||||
|
"end": "\"",
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "constant.character.escape.vuurraaf-asm",
|
||||||
|
"match": "\\\\\\(\\\\|n|t|r|\"|$)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"numbers": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "constant.numeric.vuurraaf-asm",
|
||||||
|
"match": "-?\\b\\d+\\b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"operands": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "variable.other.reference.vuurraaf-asm",
|
||||||
|
"match": "\\b[a-zA-Z_][a-zA-Z0-9_]*\\b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
; math.vasm — raw bytecode, hand-written in VuurRaaf assembly.
|
||||||
|
; Assemble + link + run with:
|
||||||
|
; vr assemble examples/math.vasm
|
||||||
|
; vr link math.vobj -o math.vbin
|
||||||
|
; vr run math.vbin
|
||||||
|
|
||||||
|
.global main
|
||||||
|
|
||||||
|
main:
|
||||||
|
push_int 6
|
||||||
|
push_int 7
|
||||||
|
mul
|
||||||
|
println
|
||||||
|
push_str "computed 6 * 7 = 42"
|
||||||
|
println
|
||||||
|
push_int 40
|
||||||
|
push_int 2
|
||||||
|
call add 2 ; calls the exported `add` symbol below
|
||||||
|
println
|
||||||
|
halt
|
||||||
|
|
||||||
|
; a callable function: takes two args, returns their sum
|
||||||
|
.global add
|
||||||
|
add:
|
||||||
|
enter 0 ; no extra locals (args were copied in by `call`)
|
||||||
|
load 0
|
||||||
|
load 1
|
||||||
|
add
|
||||||
|
retv
|
||||||
@@ -12,6 +12,9 @@ const vscode = require('vscode');
|
|||||||
const DEMO_URI = vscode.Uri.file(
|
const DEMO_URI = vscode.Uri.file(
|
||||||
path.join(__dirname, '..', 'fixtures', 'workspace', 'demo.vr')
|
path.join(__dirname, '..', 'fixtures', 'workspace', 'demo.vr')
|
||||||
);
|
);
|
||||||
|
const VASM_URI = vscode.Uri.file(
|
||||||
|
path.join(__dirname, '..', 'fixtures', 'workspace', 'math.vasm')
|
||||||
|
);
|
||||||
|
|
||||||
async function openDemo() {
|
async function openDemo() {
|
||||||
const doc = await vscode.workspace.openTextDocument(DEMO_URI);
|
const doc = await vscode.workspace.openTextDocument(DEMO_URI);
|
||||||
@@ -37,6 +40,13 @@ suite('VuurRaaf extension', function () {
|
|||||||
test('vuurraaf language (grammar) is registered', async function () {
|
test('vuurraaf language (grammar) is registered', async function () {
|
||||||
const langs = await vscode.languages.getLanguages();
|
const langs = await vscode.languages.getLanguages();
|
||||||
assert.ok(langs.includes('vuurraaf'), 'vuurraaf language id not registered');
|
assert.ok(langs.includes('vuurraaf'), 'vuurraaf language id not registered');
|
||||||
|
assert.ok(langs.includes('vuurraaf-asm'), 'vuurraaf-asm language id not registered');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('.vasm files get the vuurraaf-asm language id', async function () {
|
||||||
|
const doc = await vscode.workspace.openTextDocument(VASM_URI);
|
||||||
|
await vscode.window.showTextDocument(doc);
|
||||||
|
assert.strictEqual(doc.languageId, 'vuurraaf-asm', 'expected vuurraaf-asm, got ' + doc.languageId);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('language server publishes compiler diagnostics', async function () {
|
test('language server publishes compiler diagnostics', async function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user