Added separate syntax highlighting for stack pointer vs. normal address registers.
This commit is contained in:
parent
c00a403638
commit
9a37b9c569
File diff suppressed because it is too large
Load Diff
@ -84,13 +84,14 @@ public class M68kParser implements PsiParser, LightPsiParser {
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// AREG
|
||||
// AREG | REG_SP
|
||||
public static boolean AddressRegister(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "AddressRegister")) return false;
|
||||
if (!nextTokenIs(b, "<address register>", AREG)) return false;
|
||||
if (!nextTokenIs(b, "<address register>", AREG, REG_SP)) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _NONE_, ADDRESS_REGISTER, "<address register>");
|
||||
r = consumeToken(b, AREG);
|
||||
if (!r) r = consumeToken(b, REG_SP);
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
return r;
|
||||
}
|
||||
@ -99,7 +100,7 @@ public class M68kParser implements PsiParser, LightPsiParser {
|
||||
// AddressRegister !(OP_MINUS|OP_AR_DIV)
|
||||
public static boolean AddressRegisterDirectAddressingMode(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "AddressRegisterDirectAddressingMode")) return false;
|
||||
if (!nextTokenIsFast(b, AREG)) return false;
|
||||
if (!nextTokenIsFast(b, AREG, REG_SP)) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _NONE_, ADDRESS_REGISTER_DIRECT_ADDRESSING_MODE, "<AddressingMode>");
|
||||
r = AddressRegister(b, l + 1);
|
||||
@ -445,7 +446,6 @@ public class M68kParser implements PsiParser, LightPsiParser {
|
||||
// DataRegister | AddressRegister
|
||||
static boolean DataOrAddressRegister(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "DataOrAddressRegister")) return false;
|
||||
if (!nextTokenIs(b, "<data or address register>", AREG, DREG)) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _NONE_, null, "<data or address register>");
|
||||
r = DataRegister(b, l + 1);
|
||||
@ -931,7 +931,6 @@ public class M68kParser implements PsiParser, LightPsiParser {
|
||||
// (DataOrAddressRegister|RegisterRange) ((OP_AR_DIV|OP_MINUS) (DataOrAddressRegister|RegisterRange))*
|
||||
public static boolean RegisterListAddressingMode(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "RegisterListAddressingMode")) return false;
|
||||
if (!nextTokenIsFast(b, AREG, DREG)) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _NONE_, REGISTER_LIST_ADDRESSING_MODE, "<AddressingMode>");
|
||||
r = RegisterListAddressingMode_0(b, l + 1);
|
||||
@ -993,7 +992,6 @@ public class M68kParser implements PsiParser, LightPsiParser {
|
||||
// DataOrAddressRegister OP_MINUS DataOrAddressRegister
|
||||
static boolean RegisterRange(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "RegisterRange")) return false;
|
||||
if (!nextTokenIs(b, "", AREG, DREG)) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = DataOrAddressRegister(b, l + 1);
|
||||
|
@ -116,6 +116,7 @@ public interface M68kTypes {
|
||||
IElementType OTHER_DIRECTIVE = new M68kTokenType("OTHER_DIRECTIVE");
|
||||
IElementType PC = new M68kTokenType("PC");
|
||||
IElementType REG_CCR = new M68kTokenType("REG_CCR");
|
||||
IElementType REG_SP = new M68kTokenType("REG_SP");
|
||||
IElementType REG_SR = new M68kTokenType("REG_SR");
|
||||
IElementType REG_USP = new M68kTokenType("REG_USP");
|
||||
IElementType REG_VBR = new M68kTokenType("REG_VBR");
|
||||
|
@ -35,7 +35,7 @@ import static de.platon42.intellij.plugins.m68k.lexer.LexerUtil.*;
|
||||
|
||||
EOL=\R
|
||||
WHITE_SPACE=\p{Blank}+
|
||||
AREG=((a[0-7])|sp)
|
||||
AREG=(a[0-6])
|
||||
DREG=(d[0-7])
|
||||
ASSIGNMENT=(([:letter:]|_)(([:letter:]|[:digit:])|_)*:?((\p{Blank}+equ\p{Blank}+)|(\p{Blank}+set\p{Blank}+)|\p{Blank}*=\p{Blank}*))
|
||||
LOCAL_LABEL=(\.([:letter:]|_)(([:letter:]|[:digit:])|_)*:?)|(([:letter:]|_)(([:letter:]|[:digit:])|_)*\$:?)
|
||||
@ -216,6 +216,7 @@ SKIP_TO_EOL=[^\r\n]+
|
||||
|
||||
{AREG} { yybegin(ASMOPS_OP); return AREG; }
|
||||
{DREG} { yybegin(ASMOPS_OP); return DREG; }
|
||||
"sp"|"a7" { yybegin(ASMOPS_OP); return REG_SP; }
|
||||
"pc" { yybegin(ASMOPS_OP); return PC; }
|
||||
"ccr" { yybegin(ASMOPS_OP); return REG_CCR; }
|
||||
"sr" { yybegin(ASMOPS_OP); return REG_SR; }
|
||||
|
@ -195,7 +195,7 @@ DataRegister ::= DREG {
|
||||
extends = Register
|
||||
}
|
||||
|
||||
AddressRegister ::= AREG {
|
||||
AddressRegister ::= AREG | REG_SP {
|
||||
name = "address register"
|
||||
extends = Register
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.
|
||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.PROGRAM_COUNTER
|
||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.SEPARATOR
|
||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.SPECIAL_REG
|
||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.STACK_POINTER
|
||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.STRING
|
||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.SYMBOLDEF
|
||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.SYMBOLREF
|
||||
@ -65,6 +66,12 @@ demo_init ; global label
|
||||
POPM
|
||||
.skip rts
|
||||
|
||||
irq: move.l a0,-(sp)
|
||||
move usp,a0
|
||||
move.l a0,$400.w
|
||||
move.l (sp)+,a0
|
||||
rte
|
||||
|
||||
hello: dc.b 'Hello World!',10,0
|
||||
even
|
||||
dc.w *-hello ; length of string
|
||||
@ -97,17 +104,18 @@ hello: dc.b 'Hello World!',10,0
|
||||
AttributesDescriptor("Symbol reference", SYMBOLREF),
|
||||
AttributesDescriptor("Assembly mnemonic", MNEMONIC),
|
||||
AttributesDescriptor("Macro invocation", MACRO_CALL),
|
||||
AttributesDescriptor("Byte/short data width", DATA_WIDTH_BS),
|
||||
AttributesDescriptor("Word data width", DATA_WIDTH_W),
|
||||
AttributesDescriptor("Long data width", DATA_WIDTH_L),
|
||||
AttributesDescriptor("Data width: Byte/short", DATA_WIDTH_BS),
|
||||
AttributesDescriptor("Data width: Word", DATA_WIDTH_W),
|
||||
AttributesDescriptor("Data width: Long", DATA_WIDTH_L),
|
||||
AttributesDescriptor("Data preprocessor directives", DATA_PREPROCESSOR),
|
||||
AttributesDescriptor("Other preprocessor directives", OTHER_PREPROCESSOR),
|
||||
AttributesDescriptor("Strings", STRING),
|
||||
AttributesDescriptor("Numbers", NUMBER),
|
||||
AttributesDescriptor("Address registers", AREG),
|
||||
AttributesDescriptor("Data registers", DREG),
|
||||
AttributesDescriptor("Program counter", PROGRAM_COUNTER),
|
||||
AttributesDescriptor("Special registers", SPECIAL_REG),
|
||||
AttributesDescriptor("Registers: Address registers", AREG),
|
||||
AttributesDescriptor("Registers: Stack pointer", STACK_POINTER),
|
||||
AttributesDescriptor("Registers: Data registers", DREG),
|
||||
AttributesDescriptor("Registers: Program counter", PROGRAM_COUNTER),
|
||||
AttributesDescriptor("Registers: Special registers", SPECIAL_REG),
|
||||
AttributesDescriptor("Comments", COMMENT),
|
||||
AttributesDescriptor("Bad characters", BAD_CHARACTER)
|
||||
)
|
||||
|
@ -39,6 +39,7 @@ class M68kSyntaxHighlighter(val project: Project?) : SyntaxHighlighterBase() {
|
||||
M68kTypes.OPSIZE_W -> arrayOf(DATA_WIDTH_W)
|
||||
M68kTypes.OPSIZE_L -> arrayOf(DATA_WIDTH_L)
|
||||
M68kTypes.AREG -> arrayOf(AREG)
|
||||
M68kTypes.REG_SP -> arrayOf(STACK_POINTER)
|
||||
M68kTypes.DREG -> arrayOf(DREG)
|
||||
M68kTypes.REG_USP, M68kTypes.REG_SR, M68kTypes.REG_CCR, M68kTypes.REG_VBR -> arrayOf(SPECIAL_REG)
|
||||
M68kTypes.COMMENT -> arrayOf(COMMENT)
|
||||
@ -66,6 +67,7 @@ class M68kSyntaxHighlighter(val project: Project?) : SyntaxHighlighterBase() {
|
||||
val STRING = TextAttributesKey.createTextAttributesKey("MC68000_STRING", DefaultLanguageHighlighterColors.STRING)
|
||||
val NUMBER = TextAttributesKey.createTextAttributesKey("MC68000_NUMBER", DefaultLanguageHighlighterColors.NUMBER)
|
||||
val AREG = TextAttributesKey.createTextAttributesKey("MC68000_AREG", DefaultLanguageHighlighterColors.PARAMETER)
|
||||
val STACK_POINTER = TextAttributesKey.createTextAttributesKey("MC68000_SP", DefaultLanguageHighlighterColors.PARAMETER)
|
||||
val DREG = TextAttributesKey.createTextAttributesKey("MC68000_DREG", DefaultLanguageHighlighterColors.PARAMETER)
|
||||
val SPECIAL_REG = TextAttributesKey.createTextAttributesKey("MC68000_SPECIALREG", DefaultLanguageHighlighterColors.PARAMETER)
|
||||
val PROGRAM_COUNTER = TextAttributesKey.createTextAttributesKey("MC68000_PROGRAM_COUNTER", DefaultLanguageHighlighterColors.PARAMETER)
|
||||
|
@ -30,6 +30,6 @@ Assembly File: a.asm
|
||||
PsiElement(M68kTokenType.OP_MINUS)('-')
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kAddressRegisterImpl(ADDRESS_REGISTER)
|
||||
PsiElement(M68kTokenType.AREG)('sp')
|
||||
PsiElement(M68kTokenType.REG_SP)('sp')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
@ -13,5 +13,5 @@ Assembly File: a.asm
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
M68kAddressRegisterDirectAddressingModeImpl(ADDRESS_REGISTER_DIRECT_ADDRESSING_MODE)
|
||||
M68kAddressRegisterImpl(ADDRESS_REGISTER)
|
||||
PsiElement(M68kTokenType.AREG)('a7')
|
||||
PsiElement(M68kTokenType.REG_SP)('a7')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
@ -10,7 +10,7 @@ Assembly File: a.asm
|
||||
M68kAddressRegisterIndirectAddressingModeImpl(ADDRESS_REGISTER_INDIRECT_ADDRESSING_MODE)
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kAddressRegisterImpl(ADDRESS_REGISTER)
|
||||
PsiElement(M68kTokenType.AREG)('sp')
|
||||
PsiElement(M68kTokenType.REG_SP)('sp')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
M68kAddressRegisterIndirectAddressingModeImpl(ADDRESS_REGISTER_INDIRECT_ADDRESSING_MODE)
|
||||
|
@ -18,6 +18,6 @@ Assembly File: a.asm
|
||||
PsiElement(M68kTokenType.OP_MINUS)('-')
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kAddressRegisterImpl(ADDRESS_REGISTER)
|
||||
PsiElement(M68kTokenType.AREG)('sp')
|
||||
PsiElement(M68kTokenType.REG_SP)('sp')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
@ -20,7 +20,7 @@ Assembly File: a.asm
|
||||
PsiElement(M68kTokenType.SYMBOL)('foo')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
M68kAddressRegisterImpl(ADDRESS_REGISTER)
|
||||
PsiElement(M68kTokenType.AREG)('sp')
|
||||
PsiElement(M68kTokenType.REG_SP)('sp')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
M68kAddressRegisterImpl(ADDRESS_REGISTER)
|
||||
PsiElement(M68kTokenType.AREG)('a0')
|
||||
|
@ -19,7 +19,7 @@ Assembly File: a.asm
|
||||
PsiElement(M68kTokenType.SYMBOL)('foo')
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kAddressRegisterImpl(ADDRESS_REGISTER)
|
||||
PsiElement(M68kTokenType.AREG)('sp')
|
||||
PsiElement(M68kTokenType.REG_SP)('sp')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
M68kDataRegisterImpl(DATA_REGISTER)
|
||||
PsiElement(M68kTokenType.DREG)('d0')
|
||||
|
@ -10,7 +10,7 @@ Assembly File: a.asm
|
||||
M68kAddressRegisterIndirectWithIndexNewAddressingModeImpl(ADDRESS_REGISTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE)
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kAddressRegisterImpl(ADDRESS_REGISTER)
|
||||
PsiElement(M68kTokenType.AREG)('sp')
|
||||
PsiElement(M68kTokenType.REG_SP)('sp')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
M68kDataRegisterImpl(DATA_REGISTER)
|
||||
PsiElement(M68kTokenType.DREG)('d0')
|
||||
|
@ -20,7 +20,7 @@ Assembly File: a.asm
|
||||
PsiElement(M68kTokenType.SYMBOL)('foo')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
M68kAddressRegisterImpl(ADDRESS_REGISTER)
|
||||
PsiElement(M68kTokenType.AREG)('sp')
|
||||
PsiElement(M68kTokenType.REG_SP)('sp')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
M68kAddressRegisterIndirectWithDisplacementNewAddressingModeImpl(ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE)
|
||||
|
@ -19,7 +19,7 @@ Assembly File: a.asm
|
||||
PsiElement(M68kTokenType.SYMBOL)('foo')
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kAddressRegisterImpl(ADDRESS_REGISTER)
|
||||
PsiElement(M68kTokenType.AREG)('sp')
|
||||
PsiElement(M68kTokenType.REG_SP)('sp')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
M68kAddressRegisterIndirectWithDisplacementOldAddressingModeImpl(ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE)
|
||||
|
Loading…
Reference in New Issue
Block a user