Skip to content

Commit

Permalink
Asm6502: Use standard tokens and minor improvements (#3184)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Nov 22, 2021
1 parent c780928 commit 929c33e
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 140 deletions.
23 changes: 12 additions & 11 deletions components/prism-asm6502.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@ Prism.languages.asm6502 = {
'comment': /;.*/,
'directive': {
pattern: /\.\w+(?= )/,
alias: 'keyword'
alias: 'property'
},
'string': /(["'`])(?:\\.|(?!\1)[^\\\r\n])*\1/,
'opcode': {
'op-code': {
pattern: /\b(?:ADC|AND|ASL|BCC|BCS|BEQ|BIT|BMI|BNE|BPL|BRK|BVC|BVS|CLC|CLD|CLI|CLV|CMP|CPX|CPY|DEC|DEX|DEY|EOR|INC|INX|INY|JMP|JSR|LDA|LDX|LDY|LSR|NOP|ORA|PHA|PHP|PLA|PLP|ROL|ROR|RTI|RTS|SBC|SEC|SED|SEI|STA|STX|STY|TAX|TAY|TSX|TXA|TXS|TYA|adc|and|asl|bcc|bcs|beq|bit|bmi|bne|bpl|brk|bvc|bvs|clc|cld|cli|clv|cmp|cpx|cpy|dec|dex|dey|eor|inc|inx|iny|jmp|jsr|lda|ldx|ldy|lsr|nop|ora|pha|php|pla|plp|rol|ror|rti|rts|sbc|sec|sed|sei|sta|stx|sty|tax|tay|tsx|txa|txs|tya)\b/,
alias: 'property'
alias: 'keyword'
},
'hexnumber': {
pattern: /#?\$[\da-f]{2,4}\b/i,
alias: 'string'
'hex-number': {
pattern: /#?\$[\da-f]{1,4}\b/i,
alias: 'number'
},
'binarynumber': {
'binary-number': {
pattern: /#?%[01]+\b/,
alias: 'string'
alias: 'number'
},
'decimalnumber': {
'decimal-number': {
pattern: /#?\b\d+\b/,
alias: 'string'
alias: 'number'
},
'register': {
pattern: /\b[xya]\b/i,
alias: 'variable'
}
},
'punctuation': /[(),:]/
};
2 changes: 1 addition & 1 deletion components/prism-asm6502.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions tests/languages/asm6502/number_feature.test
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
LDA #127
STA $8000
STA #$1
LDX #%10001010

-------------------------
----------------------------------------------------

[
["opcode", "LDA"],
["decimalnumber", "#127"],
["opcode", "STA"],
["hexnumber", "$8000"],
["opcode", "LDX"],
["binarynumber", "#%10001010"]
["op-code", "LDA"], ["decimal-number", "#127"],
["op-code", "STA"], ["hex-number", "$8000"],
["op-code", "STA"], ["hex-number", "#$1"],
["op-code", "LDX"], ["binary-number", "#%10001010"]
]

-------------------------
----------------------------------------------------

Check for numbers
224 changes: 112 additions & 112 deletions tests/languages/asm6502/opcode_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -114,118 +114,118 @@ TYA
----------------------------------------------------

[
["opcode", "adc"],
["opcode", "and"],
["opcode", "asl"],
["opcode", "bcc"],
["opcode", "bcs"],
["opcode", "beq"],
["opcode", "bit"],
["opcode", "bmi"],
["opcode", "bne"],
["opcode", "bpl"],
["opcode", "brk"],
["opcode", "bvc"],
["opcode", "bvs"],
["opcode", "clc"],
["opcode", "cld"],
["opcode", "cli"],
["opcode", "clv"],
["opcode", "cmp"],
["opcode", "cpx"],
["opcode", "cpy"],
["opcode", "dec"],
["opcode", "dex"],
["opcode", "dey"],
["opcode", "eor"],
["opcode", "inc"],
["opcode", "inx"],
["opcode", "iny"],
["opcode", "jmp"],
["opcode", "jsr"],
["opcode", "lda"],
["opcode", "ldx"],
["opcode", "ldy"],
["opcode", "lsr"],
["opcode", "nop"],
["opcode", "ora"],
["opcode", "pha"],
["opcode", "php"],
["opcode", "pla"],
["opcode", "plp"],
["opcode", "rol"],
["opcode", "ror"],
["opcode", "rti"],
["opcode", "rts"],
["opcode", "sbc"],
["opcode", "sec"],
["opcode", "sed"],
["opcode", "sei"],
["opcode", "sta"],
["opcode", "stx"],
["opcode", "sty"],
["opcode", "tax"],
["opcode", "tay"],
["opcode", "tsx"],
["opcode", "txa"],
["opcode", "txs"],
["opcode", "tya"],
["opcode", "ADC"],
["opcode", "AND"],
["opcode", "ASL"],
["opcode", "BCC"],
["opcode", "BCS"],
["opcode", "BEQ"],
["opcode", "BIT"],
["opcode", "BMI"],
["opcode", "BNE"],
["opcode", "BPL"],
["opcode", "BRK"],
["opcode", "BVC"],
["opcode", "BVS"],
["opcode", "CLC"],
["opcode", "CLD"],
["opcode", "CLI"],
["opcode", "CLV"],
["opcode", "CMP"],
["opcode", "CPX"],
["opcode", "CPY"],
["opcode", "DEC"],
["opcode", "DEX"],
["opcode", "DEY"],
["opcode", "EOR"],
["opcode", "INC"],
["opcode", "INX"],
["opcode", "INY"],
["opcode", "JMP"],
["opcode", "JSR"],
["opcode", "LDA"],
["opcode", "LDX"],
["opcode", "LDY"],
["opcode", "LSR"],
["opcode", "NOP"],
["opcode", "ORA"],
["opcode", "PHA"],
["opcode", "PHP"],
["opcode", "PLA"],
["opcode", "PLP"],
["opcode", "ROL"],
["opcode", "ROR"],
["opcode", "RTI"],
["opcode", "RTS"],
["opcode", "SBC"],
["opcode", "SEC"],
["opcode", "SED"],
["opcode", "SEI"],
["opcode", "STA"],
["opcode", "STX"],
["opcode", "STY"],
["opcode", "TAX"],
["opcode", "TAY"],
["opcode", "TSX"],
["opcode", "TXA"],
["opcode", "TXS"],
["opcode", "TYA"]
["op-code", "adc"],
["op-code", "and"],
["op-code", "asl"],
["op-code", "bcc"],
["op-code", "bcs"],
["op-code", "beq"],
["op-code", "bit"],
["op-code", "bmi"],
["op-code", "bne"],
["op-code", "bpl"],
["op-code", "brk"],
["op-code", "bvc"],
["op-code", "bvs"],
["op-code", "clc"],
["op-code", "cld"],
["op-code", "cli"],
["op-code", "clv"],
["op-code", "cmp"],
["op-code", "cpx"],
["op-code", "cpy"],
["op-code", "dec"],
["op-code", "dex"],
["op-code", "dey"],
["op-code", "eor"],
["op-code", "inc"],
["op-code", "inx"],
["op-code", "iny"],
["op-code", "jmp"],
["op-code", "jsr"],
["op-code", "lda"],
["op-code", "ldx"],
["op-code", "ldy"],
["op-code", "lsr"],
["op-code", "nop"],
["op-code", "ora"],
["op-code", "pha"],
["op-code", "php"],
["op-code", "pla"],
["op-code", "plp"],
["op-code", "rol"],
["op-code", "ror"],
["op-code", "rti"],
["op-code", "rts"],
["op-code", "sbc"],
["op-code", "sec"],
["op-code", "sed"],
["op-code", "sei"],
["op-code", "sta"],
["op-code", "stx"],
["op-code", "sty"],
["op-code", "tax"],
["op-code", "tay"],
["op-code", "tsx"],
["op-code", "txa"],
["op-code", "txs"],
["op-code", "tya"],
["op-code", "ADC"],
["op-code", "AND"],
["op-code", "ASL"],
["op-code", "BCC"],
["op-code", "BCS"],
["op-code", "BEQ"],
["op-code", "BIT"],
["op-code", "BMI"],
["op-code", "BNE"],
["op-code", "BPL"],
["op-code", "BRK"],
["op-code", "BVC"],
["op-code", "BVS"],
["op-code", "CLC"],
["op-code", "CLD"],
["op-code", "CLI"],
["op-code", "CLV"],
["op-code", "CMP"],
["op-code", "CPX"],
["op-code", "CPY"],
["op-code", "DEC"],
["op-code", "DEX"],
["op-code", "DEY"],
["op-code", "EOR"],
["op-code", "INC"],
["op-code", "INX"],
["op-code", "INY"],
["op-code", "JMP"],
["op-code", "JSR"],
["op-code", "LDA"],
["op-code", "LDX"],
["op-code", "LDY"],
["op-code", "LSR"],
["op-code", "NOP"],
["op-code", "ORA"],
["op-code", "PHA"],
["op-code", "PHP"],
["op-code", "PLA"],
["op-code", "PLP"],
["op-code", "ROL"],
["op-code", "ROR"],
["op-code", "RTI"],
["op-code", "RTS"],
["op-code", "SBC"],
["op-code", "SEC"],
["op-code", "SED"],
["op-code", "SEI"],
["op-code", "STA"],
["op-code", "STX"],
["op-code", "STY"],
["op-code", "TAX"],
["op-code", "TAY"],
["op-code", "TSX"],
["op-code", "TXA"],
["op-code", "TXS"],
["op-code", "TYA"]
]

----------------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions tests/languages/asm6502/punctuation_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
( ) , :

----------------------------------------------------

[
["punctuation", "("],
["punctuation", ")"],
["punctuation", ","],
["punctuation", ":"]
]
17 changes: 9 additions & 8 deletions tests/languages/asm6502/register_feature.test
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
LDA $8000,x
ASL A

-------------------------
----------------------------------------------------

[
["opcode", "LDA"],
["hexnumber", "$8000"],
",",
["register", "x"],
["opcode", "ASL"],
["register", "A"]
["op-code", "LDA"],
["hex-number", "$8000"],
["punctuation", ","],
["register", "x"],

["op-code", "ASL"],
["register", "A"]
]

-------------------------
----------------------------------------------------

Check for registers

0 comments on commit 929c33e

Please sign in to comment.