diff --git a/vscode/CHANGELOG.md b/vscode/CHANGELOG.md new file mode 100644 index 0000000..44e93a7 --- /dev/null +++ b/vscode/CHANGELOG.md @@ -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 diff --git a/vscode/README.md b/vscode/README.md new file mode 100644 index 0000000..933fd86 --- /dev/null +++ b/vscode/README.md @@ -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 \ No newline at end of file diff --git a/vscode/package.json b/vscode/package.json new file mode 100644 index 0000000..1837dc6 --- /dev/null +++ b/vscode/package.json @@ -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" + } + ] + } +} diff --git a/vscode/x65.configuration.json b/vscode/x65.configuration.json new file mode 100644 index 0000000..3ff5392 --- /dev/null +++ b/vscode/x65.configuration.json @@ -0,0 +1,25 @@ +{ + "comments": { + "lineComment": ";", + "blockComment": [ "/*", "*/" ] + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "autoClosingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"] + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"] + ] +} \ No newline at end of file diff --git a/vscode/x65.png b/vscode/x65.png new file mode 100644 index 0000000..2cb8c97 Binary files /dev/null and b/vscode/x65.png differ diff --git a/vscode/x65.tmLanguage b/vscode/x65.tmLanguage new file mode 100644 index 0000000..80b8571 --- /dev/null +++ b/vscode/x65.tmLanguage @@ -0,0 +1,229 @@ + + + + + fileTypes + + s + i + + name + x65 + patterns + + + include + #comments + + + include + #constants + + + include + #control + + + include + #opcodes + + + include + #quotes + + + include + #storage + + + include + #operators + + + include + #labels + + + repository + + control + + patterns + + + match + (?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 + name + directive + + + + opcodes + + patterns + + + match + \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 + name + keyword.other.opcode + + + match + \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 + name + keyword.pc + + + match + (?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+|[:$#(]) + name + keyword.other.opcode.6502.illegal + + + + comments + + patterns + + + begin + /\* + end + \*/ + name + comment.block + + + match + //.* + name + comment.line.double-slash + + + match + ;.* + name + comment.line.semicolon + + + match + ^\S*\s*(\*.*) + captures + + 1 + + name + comment.line.asterisk + + + + + + quotes + + patterns + + + begin + ' + end + ' + name + string.quoted.single + + + begin + " + end + " + name + string.quoted.double + + + + constants + + patterns + + + match + (?i)(?<=,)\s*[xy]\b(?!.*\.reg) + name + constant.language.registers + + + match + \b[0-9]+\b + name + constant.numeric.decimal + + + match + (?i)\$\b\h+\b|\b0x\h+\b + name + constant.numeric.hexadecimal + + + match + %\b[0-1]+\b + name + constant.numeric.binary + + + + storage + + patterns + + + match + (?i)(^|\s+)align\b + name + storage.modifier + + + + labels + + patterns + + + match + (?i)(^|\s+)[\!\.][a-zA-Z0-9_]+\b + name + label.local + + + match + (?i)(^|\s+)[!\!\.][a-zA-Z0-9_]+\b + name + label.global + + + match + (?i)[\!\%]\b + name + label.scope + + + + operators + + patterns + + + match + (?i)[+\-*/%!|^=~\:&<>] + name + constant.language + + + + + scopeName + source.asm.6502.x65 + uuid + 3a93182b-9647-4133-bead-cd118e3ed088 + + diff --git a/vscode/x65.tmTheme b/vscode/x65.tmTheme new file mode 100644 index 0000000..c01c1f8 --- /dev/null +++ b/vscode/x65.tmTheme @@ -0,0 +1,226 @@ + + + + + name + x65 + settings + + + settings + + background + #000048 + caret + #ffffff + foreground + #eeee88 + invisibles + #3B3A32 + lineHighlight + #40406060 + selection + #0088ff + + + + name + Comment + scope + comment + settings + + foreground + #cc44cc + + + + name + String + scope + string + settings + + foreground + #00cc55 + + + + name + Number + scope + constant.numeric + settings + + foreground + #77e0c0 + + + + name + Directive + scope + directive + settings + + foreground + #40b0ff + + + + name + Built-in constant + scope + constant.language + settings + + foreground + #c090ff + + + + name + User-defined constant + scope + constant.character, constant.other + settings + + foreground + #c0a040 + + + + name + Variable + scope + variable + settings + + foreground + #a9fdac + + + + name + Keyword + scope + keyword + settings + + foreground + #ff7979 + + + + name + Storage + scope + storage + settings + + fontStyle + + foreground + #dede79 + + + + name + LocalLabel + scope + label.local + settings + + fontStyle + + foreground + #a0c0ff + + + + name + GlobalLabel + scope + label.global + settings + + fontStyle + + foreground + #80ffa0 + + + + name + ScopeLabel + scope + label.scope + settings + + fontStyle + + foreground + #ff80a0 + + + + name + Function name + scope + entity.name.function + settings + + fontStyle + + foreground + #8cdaff + + + + name + Tag name + scope + entity.name.tag + settings + + fontStyle + + foreground + #88ddbb + + + + name + Library constant + scope + support.constant + settings + + fontStyle + + foreground + #ecfdb9 + + + + name + Invalid + scope + invalid + settings + + background + #f92649 + fontStyle + + foreground + #F8F8F0 + + + + uuid + 38b4e4f7-c037-42d5-8ccc-eda7c052d512 + colorSpaceName + sRGB + + \ No newline at end of file diff --git a/x65.cpp b/x65.cpp index 81e9763..2a3303b 100644 --- a/x65.cpp +++ b/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());