mirror of
https://github.com/ksherlock/x65.git
synced 2025-01-15 02:30:01 +00:00
Visual Studio Code colorizing extension, Error includes line number of undefined label reference
* PrintError has an optional argument for enclosing file * Visual Studio Code extension
This commit is contained in:
parent
576ec5497d
commit
e37bf5ae11
2
vscode/CHANGELOG.md
Normal file
2
vscode/CHANGELOG.md
Normal file
@ -0,0 +1,2 @@
|
||||
## 0.1.0
|
||||
* Bunched together a shabby working version of Visual Studio Code editing of 6502 intended for assembling with x65
|
18
vscode/README.md
Normal file
18
vscode/README.md
Normal file
@ -0,0 +1,18 @@
|
||||
# x65 - Visual Studio Code Text Package
|
||||
|
||||
[Visual Studio Code](http://code.visualstudio.com/) is a funny little simple text editor with surprising extensibility. This little editor has matured and it's worth exploring.
|
||||
|
||||
As I don't like the marketplaceification of seemingly simple tools I'm not putting this on the visual studio coded marketplace, but if anyone wants to do that I don't mind.
|
||||
|
||||
In order to "side load" this extension into visual studio code follow these steps
|
||||
|
||||
1. Install Visual Studio Code unless already Installed
|
||||
2. Go to the visual studio code extension folder
|
||||
* Windows %USERPROFILE%\.vscode\extensions
|
||||
* Mac ~/.vscode/extensions
|
||||
* Linux ~/.vscode/extensions
|
||||
3. Create a folder named x65
|
||||
4. Copy the contents of this folder
|
||||
5. Start Visual Studio code, change your theme to x65 which is pretty much required to read x65 the "language"
|
||||
|
||||
For more information about Visual Studio Code extensions: https://code.visualstudio.com/Docs/extensions/install-extension
|
42
vscode/package.json
Normal file
42
vscode/package.json
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"name" : "x65",
|
||||
"displayName" : "x65",
|
||||
"description" : "x65 Assembler syntax",
|
||||
"version" : "0.1.0",
|
||||
"publisher" : "x65",
|
||||
"icon": "x65.png",
|
||||
"license" : "maybe",
|
||||
"engines" : {
|
||||
"vscode" : "^1.0.0"
|
||||
},
|
||||
"categories" : [
|
||||
"Languages"
|
||||
],
|
||||
"keywords" : [
|
||||
"x65", "6502", "6510", "65816"
|
||||
],
|
||||
"contributes" : {
|
||||
"languages" : [
|
||||
{
|
||||
"id" : "x65",
|
||||
"aliases" : ["6502"],
|
||||
"extensions" : [ ".s", ".i" ],
|
||||
"configuration" : "./x65.configuration.json"
|
||||
}
|
||||
],
|
||||
"grammars" : [
|
||||
{
|
||||
"language" : "x65",
|
||||
"scopeName" : "source.asm.6502.x65",
|
||||
"path" : "./x65.tmLanguage"
|
||||
}
|
||||
],
|
||||
"themes" : [
|
||||
{
|
||||
"label": "x65",
|
||||
"uiTheme": "vs-dark",
|
||||
"path": "./x65.tmTheme"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
25
vscode/x65.configuration.json
Normal file
25
vscode/x65.configuration.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"comments": {
|
||||
"lineComment": ";",
|
||||
"blockComment": [ "/*", "*/" ]
|
||||
},
|
||||
"brackets": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"]
|
||||
],
|
||||
"autoClosingPairs": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"],
|
||||
["\"", "\""],
|
||||
["'", "'"]
|
||||
],
|
||||
"surroundingPairs": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"],
|
||||
["\"", "\""],
|
||||
["'", "'"]
|
||||
]
|
||||
}
|
BIN
vscode/x65.png
Normal file
BIN
vscode/x65.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
229
vscode/x65.tmLanguage
Normal file
229
vscode/x65.tmLanguage
Normal file
@ -0,0 +1,229 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>fileTypes</key>
|
||||
<array>
|
||||
<string>s</string>
|
||||
<string>i</string>
|
||||
</array>
|
||||
<key>name</key>
|
||||
<string>x65</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#comments</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#constants</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#control</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#opcodes</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#quotes</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#storage</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#operators</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#labels</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>repository</key>
|
||||
<dict>
|
||||
<key>control</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i)((^|\s+)(CPU|PROCESSOR|PC|ORG|LOAD|EXPORT|SECTION|SEG|SEGMENT|MERGE|LINK|INCOBJ|ALIGN|MACRO|MAC|EVAL|PRINT|ECHO|BYTE|BYTES|WORD|WORDS|LONG|DC|DV|TEXT|INCLUDE|INCBIN|IMPORT|CONST|LABEL|STRING|UNDEF|INCSYM|LABPOOL|POOL|IF|IFDEF|ELSE|ELIF|ENDIF|STRUCT|ENUM|REPT|REPEAT|INCDIR|A16|A8|XY16|XY8|I16|I8|DUMMY|DUMMY_END|DS|ABORT|ERR)|\s+ert)\b</string>
|
||||
<key>name</key>
|
||||
<string>directive</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>opcodes</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\b(adc|and|asl|bit|clc|cld|cli|clv|cmp|cpx|cpy|dec|dex|dey|eor|inc|inx|iny|lda|ldx|ldy|lsr|nop|ora|pha|php|pla|plp|rol|ror|sbc|sec|sed|sei|sta|stx|sty|tax|txa|tay|tya|tsx|txs|ADC|AND|ASL|BIT|CLC|CLD|CLI|CLV|CMP|CPX|CPY|DEC|DEX|DEY|EOR|INC|INX|INY|LDA|LDX|LDY|LSR|NOP|ORA|PHA|PHP|PLA|PLP|ROL|ROR|SBC|SEC|SED|SEI|STA|STX|STY|TAX|TXA|TAY|TYA|TSX|TXS)\b</string>
|
||||
<key>name</key>
|
||||
<string>keyword.other.opcode</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\b(bcc|bcs|beq|bmi|bne|bpl|brk|bvc|bvs|jmp|jsr|rti|rts|BCC|BCS|BEQ|BMI|BNE|BPL|BRK|BVC|BVS|JMP|JSR|RTI|RTS)\b</string>
|
||||
<key>name</key>
|
||||
<string>keyword.pc</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i)(\s+|(?<=:))(aso|rln|lse|rrd|sax|lax|dcp|isb|anc|alr|arr|ane|anx|sbx|las|sha|shs|shx|shy|npo|cim|dop|top)(?=\s+|[:$#(])</string>
|
||||
<key>name</key>
|
||||
<string>keyword.other.opcode.6502.illegal</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>comments</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>/\*</string>
|
||||
<key>end</key>
|
||||
<string>\*/</string>
|
||||
<key>name</key>
|
||||
<string>comment.block</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>//.*</string>
|
||||
<key>name</key>
|
||||
<string>comment.line.double-slash</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>;.*</string>
|
||||
<key>name</key>
|
||||
<string>comment.line.semicolon</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>^\S*\s*(\*.*)</string>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>comment.line.asterisk</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>quotes</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>'</string>
|
||||
<key>end</key>
|
||||
<string>'</string>
|
||||
<key>name</key>
|
||||
<string>string.quoted.single</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>"</string>
|
||||
<key>end</key>
|
||||
<string>"</string>
|
||||
<key>name</key>
|
||||
<string>string.quoted.double</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>constants</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i)(?<=,)\s*[xy]\b(?!.*\.reg)</string>
|
||||
<key>name</key>
|
||||
<string>constant.language.registers</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\b[0-9]+\b</string>
|
||||
<key>name</key>
|
||||
<string>constant.numeric.decimal</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i)\$\b\h+\b|\b0x\h+\b</string>
|
||||
<key>name</key>
|
||||
<string>constant.numeric.hexadecimal</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>%\b[0-1]+\b</string>
|
||||
<key>name</key>
|
||||
<string>constant.numeric.binary</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>storage</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i)(^|\s+)align\b</string>
|
||||
<key>name</key>
|
||||
<string>storage.modifier</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>labels</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i)(^|\s+)[\!\.][a-zA-Z0-9_]+\b</string>
|
||||
<key>name</key>
|
||||
<string>label.local</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i)(^|\s+)[!\!\.][a-zA-Z0-9_]+\b</string>
|
||||
<key>name</key>
|
||||
<string>label.global</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i)[\!\%]\b</string>
|
||||
<key>name</key>
|
||||
<string>label.scope</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>operators</key>
|
||||
<dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i)[+\-*/%!|^=~\:&<>]</string>
|
||||
<key>name</key>
|
||||
<string>constant.language</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>scopeName</key>
|
||||
<string>source.asm.6502.x65</string>
|
||||
<key>uuid</key>
|
||||
<string>3a93182b-9647-4133-bead-cd118e3ed088</string>
|
||||
</dict>
|
||||
</plist>
|
226
vscode/x65.tmTheme
Normal file
226
vscode/x65.tmTheme
Normal file
@ -0,0 +1,226 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>x65</string>
|
||||
<key>settings</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>background</key>
|
||||
<string>#000048</string>
|
||||
<key>caret</key>
|
||||
<string>#ffffff</string>
|
||||
<key>foreground</key>
|
||||
<string>#eeee88</string>
|
||||
<key>invisibles</key>
|
||||
<string>#3B3A32</string>
|
||||
<key>lineHighlight</key>
|
||||
<string>#40406060</string>
|
||||
<key>selection</key>
|
||||
<string>#0088ff</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Comment</string>
|
||||
<key>scope</key>
|
||||
<string>comment</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>foreground</key>
|
||||
<string>#cc44cc</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>String</string>
|
||||
<key>scope</key>
|
||||
<string>string</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>foreground</key>
|
||||
<string>#00cc55</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Number</string>
|
||||
<key>scope</key>
|
||||
<string>constant.numeric</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>foreground</key>
|
||||
<string>#77e0c0</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Directive</string>
|
||||
<key>scope</key>
|
||||
<string>directive</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>foreground</key>
|
||||
<string>#40b0ff</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Built-in constant</string>
|
||||
<key>scope</key>
|
||||
<string>constant.language</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>foreground</key>
|
||||
<string>#c090ff</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>User-defined constant</string>
|
||||
<key>scope</key>
|
||||
<string>constant.character, constant.other</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>foreground</key>
|
||||
<string>#c0a040</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Variable</string>
|
||||
<key>scope</key>
|
||||
<string>variable</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>foreground</key>
|
||||
<string>#a9fdac</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Keyword</string>
|
||||
<key>scope</key>
|
||||
<string>keyword</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>foreground</key>
|
||||
<string>#ff7979</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Storage</string>
|
||||
<key>scope</key>
|
||||
<string>storage</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>fontStyle</key>
|
||||
<string></string>
|
||||
<key>foreground</key>
|
||||
<string>#dede79</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>LocalLabel</string>
|
||||
<key>scope</key>
|
||||
<string>label.local</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>fontStyle</key>
|
||||
<string></string>
|
||||
<key>foreground</key>
|
||||
<string>#a0c0ff</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>GlobalLabel</string>
|
||||
<key>scope</key>
|
||||
<string>label.global</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>fontStyle</key>
|
||||
<string></string>
|
||||
<key>foreground</key>
|
||||
<string>#80ffa0</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>ScopeLabel</string>
|
||||
<key>scope</key>
|
||||
<string>label.scope</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>fontStyle</key>
|
||||
<string></string>
|
||||
<key>foreground</key>
|
||||
<string>#ff80a0</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Function name</string>
|
||||
<key>scope</key>
|
||||
<string>entity.name.function</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>fontStyle</key>
|
||||
<string></string>
|
||||
<key>foreground</key>
|
||||
<string>#8cdaff</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Tag name</string>
|
||||
<key>scope</key>
|
||||
<string>entity.name.tag</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>fontStyle</key>
|
||||
<string></string>
|
||||
<key>foreground</key>
|
||||
<string>#88ddbb</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Library constant</string>
|
||||
<key>scope</key>
|
||||
<string>support.constant</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>fontStyle</key>
|
||||
<string></string>
|
||||
<key>foreground</key>
|
||||
<string>#ecfdb9</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Invalid</string>
|
||||
<key>scope</key>
|
||||
<string>invalid</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>background</key>
|
||||
<string>#f92649</string>
|
||||
<key>fontStyle</key>
|
||||
<string></string>
|
||||
<key>foreground</key>
|
||||
<string>#F8F8F0</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>uuid</key>
|
||||
<string>38b4e4f7-c037-42d5-8ccc-eda7c052d512</string>
|
||||
<key>colorSpaceName</key>
|
||||
<string>sRGB</string>
|
||||
</dict>
|
||||
</plist>
|
9
x65.cpp
9
x65.cpp
@ -1640,7 +1640,7 @@ public:
|
||||
StatusCode BuildSegment();
|
||||
|
||||
// Display error in stderr
|
||||
void PrintError(strref line, StatusCode error);
|
||||
void PrintError(strref line, StatusCode error, strref file = strref());
|
||||
|
||||
// Conditional Status
|
||||
bool ConditionalAsm(); // Assembly is currently enabled
|
||||
@ -3687,7 +3687,7 @@ StatusCode Asm::CheckLateEval(strref added_label, int scope_end, bool print_miss
|
||||
if (resolved) { i = lateEval.erase(i); }
|
||||
} else {
|
||||
if (print_missing_reference_errors && ret!=STATUS_XREF_DEPENDENT) {
|
||||
PrintError(i->expression, ret);
|
||||
PrintError(i->expression, ret, i->source_file);
|
||||
error_encountered = true;
|
||||
}
|
||||
++i;
|
||||
@ -5572,12 +5572,13 @@ StatusCode Asm::AddOpcode(strref line, int index, strref source_file) {
|
||||
}
|
||||
|
||||
// Build a line of code
|
||||
void Asm::PrintError(strref line, StatusCode error) {
|
||||
void Asm::PrintError(strref line, StatusCode error, strref source) {
|
||||
strown<512> errorText;
|
||||
if (contextStack.has_work()) {
|
||||
errorText.sprintf("Error " STRREF_FMT "(%d): ", STRREF_ARG(contextStack.curr().source_name),
|
||||
contextStack.curr().source_file.count_lines(line)+1);
|
||||
} else { errorText.append("Error: "); }
|
||||
} else if (source) { errorText.sprintf_append("Error (%d): ", source.count_lines(line)); }
|
||||
else { errorText.append("Error: "); }
|
||||
errorText.append(aStatusStrings[error]);
|
||||
errorText.append(" \"");
|
||||
errorText.append(line.get_trimmed_ws());
|
||||
|
Loading…
x
Reference in New Issue
Block a user