135 lines
4.6 KiB
JSON
135 lines
4.6 KiB
JSON
{
|
|
"fileTypes": [
|
|
"vm"
|
|
],
|
|
"name": "Virtual Machine Language",
|
|
"patterns": [
|
|
{
|
|
"include": "#arithmetic-command"
|
|
},
|
|
{
|
|
"include": "#memory-access-command"
|
|
},
|
|
{
|
|
"include": "#program-flow-command"
|
|
},
|
|
{
|
|
"include": "#function-calling-command"
|
|
},
|
|
{
|
|
"include": "#comment"
|
|
}
|
|
],
|
|
"repository": {
|
|
"arithmetic-command": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Performs arithmetic and logical operations on the stack.",
|
|
"match": "\\b(add|sub|neg|eq|gt|lt|and|or|not|shiftleft|shiftright)\\b",
|
|
"name": "keyword.operator"
|
|
}
|
|
]
|
|
},
|
|
"memory-access-command": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Transfers data between the stack and virtual memory segments.",
|
|
"match": "\\b(push|pop)\\s+([^ \\/]*)\\s+(\\d+)\\b",
|
|
"name": "keyword.operator",
|
|
"captures": {
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Segment",
|
|
"match": "[a-zA-Z\\_\\.\\$\\:]+[a-zA-Z\\_\\.\\$\\:\\d]*",
|
|
"name": "storage.type"
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Location",
|
|
"match": "\\d+",
|
|
"name": "constant.numeric"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"program-flow-command": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Facilitates conditional and unconditional branching operations.",
|
|
"match": "\\b(label|goto|if-goto)\\s+([^ \\/]*)\\b",
|
|
"name": "keyword.control",
|
|
"captures": {
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Label",
|
|
"match": "[a-zA-Z\\_\\.\\$\\:]+[a-zA-Z\\_\\.\\$\\:\\d]*",
|
|
"name": "entity.name.section"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"function-calling-command": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Defines/calls functions.",
|
|
"match": "\\b(function|call)\\s+([^ \\/]*)\\s+(\\w+)\\b",
|
|
"name": "keyword.control",
|
|
"captures": {
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Function name",
|
|
"match": "[a-zA-Z\\_\\.\\$\\:]+[a-zA-Z\\_\\.\\$\\:\\d]*",
|
|
"name": "entity.name.function"
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Number of local variables/arguments passed",
|
|
"match": "\\d+",
|
|
"name": "constant.numeric"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"comment": "Returns from functions.",
|
|
"match": "return",
|
|
"name": "keyword.control"
|
|
}
|
|
]
|
|
},
|
|
"comment": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Inline comment",
|
|
"begin": "\\/\\/",
|
|
"end": "\\n",
|
|
"name": "comment.line.double-slash"
|
|
},
|
|
{
|
|
"comment": "Multiline comment",
|
|
"begin": "\\/\\*",
|
|
"end": "\\*\\/",
|
|
"name": "comment.block"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"scopeName": "source.vm"
|
|
}
|