Progress on Lexer and BNF.

This commit is contained in:
Chris Hodges 2021-07-14 17:35:36 +02:00
parent 9047c53a0e
commit eb4552fa83
73 changed files with 1583 additions and 1646 deletions

View File

@ -37,12 +37,13 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
public static final TokenSet[] EXTENDS_SETS_ = new TokenSet[]{
create_token_set_(GLOBAL_LABEL, LABEL, LOCAL_LABEL),
create_token_set_(ADDRESS_REGISTER, DATA_REGISTER, REGISTER, SPECIAL_REGISTER),
create_token_set_(ABSOLUTE_ADDRESS_ADDRESSING_MODE, ADDRESSING_MODE, ADDRESS_REGISTER_DIRECT_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_ADDRESSING_MODE,
ADDRESS_REGISTER_INDIRECT_POST_INC_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_PRE_DEC_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE,
ADDRESS_REGISTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE, DATA_REGISTER_DIRECT_ADDRESSING_MODE, IMMEDIATE_DATA,
PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE, PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE, PROGRAM_COUNTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE, PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE,
SPECIAL_REGISTER_DIRECT_ADDRESSING_MODE),
REGISTER_LIST_ADDRESSING_MODE, SPECIAL_REGISTER_DIRECT_ADDRESSING_MODE),
create_token_set_(BINARY_ADD_EXPR, BINARY_BITWISE_AND_EXPR, BINARY_BITWISE_OR_EXPR, BINARY_BITWISE_XOR_EXPR,
BINARY_CMP_EQ_EXPR, BINARY_CMP_GE_EXPR, BINARY_CMP_GT_EXPR, BINARY_CMP_LE_EXPR,
BINARY_CMP_LT_EXPR, BINARY_CMP_NE_EXPR, BINARY_DIV_EXPR, BINARY_LOGICAL_AND_EXPR,
@ -95,17 +96,37 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// AddressRegister
// 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;
boolean r;
Marker m = enter_section_(b, l, _NONE_, ADDRESS_REGISTER_DIRECT_ADDRESSING_MODE, "<AddressingMode>");
r = AddressRegister(b, l + 1);
r = r && AddressRegisterDirectAddressingMode_1(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
// !(OP_MINUS|OP_AR_DIV)
private static boolean AddressRegisterDirectAddressingMode_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "AddressRegisterDirectAddressingMode_1")) return false;
boolean r;
Marker m = enter_section_(b, l, _NOT_);
r = !AddressRegisterDirectAddressingMode_1_0(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
// OP_MINUS|OP_AR_DIV
private static boolean AddressRegisterDirectAddressingMode_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "AddressRegisterDirectAddressingMode_1_0")) return false;
boolean r;
r = consumeTokenFast(b, OP_MINUS);
if (!r) r = consumeTokenFast(b, OP_AR_DIV);
return r;
}
/* ********************************************************** */
// ROUND_L AddressRegister ROUND_R !OP_PLUS
public static boolean AddressRegisterIndirectAddressingMode(PsiBuilder b, int l) {
@ -267,6 +288,7 @@ public class M68kParser implements PsiParser, LightPsiParser {
// | ProgramCounterIndirectWithIndexNewAddressingMode
// | AddressRegisterIndirectPreDecAddressingMode
// | AddressRegisterIndirectPostIncAddressingMode
// | RegisterListAddressingMode
// | ImmediateData
public static boolean AddressingMode(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "AddressingMode")) return false;
@ -287,16 +309,17 @@ public class M68kParser implements PsiParser, LightPsiParser {
if (!r) r = ProgramCounterIndirectWithIndexNewAddressingMode(b, l + 1);
if (!r) r = AddressRegisterIndirectPreDecAddressingMode(b, l + 1);
if (!r) r = AddressRegisterIndirectPostIncAddressingMode(b, l + 1);
if (!r) r = RegisterListAddressingMode(b, l + 1);
if (!r) r = ImmediateData(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
/* ********************************************************** */
// AsmOp (WHITE_SPACE AsmOperands)?
// AsmOp AsmOperands?
public static boolean AsmInstruction(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "AsmInstruction")) return false;
if (!nextTokenIs(b, SYMBOL)) return false;
if (!nextTokenIs(b, MNEMONIC)) return false;
boolean r;
Marker m = enter_section_(b);
r = AsmOp(b, l + 1);
@ -305,32 +328,21 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
// (WHITE_SPACE AsmOperands)?
// AsmOperands?
private static boolean AsmInstruction_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "AsmInstruction_1")) return false;
AsmInstruction_1_0(b, l + 1);
AsmOperands(b, l + 1);
return true;
}
// WHITE_SPACE AsmOperands
private static boolean AsmInstruction_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "AsmInstruction_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, WHITE_SPACE);
r = r && AsmOperands(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// SYMBOL OperandSize?
// MNEMONIC OperandSize?
public static boolean AsmOp(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "AsmOp")) return false;
if (!nextTokenIs(b, SYMBOL)) return false;
if (!nextTokenIs(b, MNEMONIC)) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, SYMBOL);
r = consumeToken(b, MNEMONIC);
r = r && AsmOp_1(b, l + 1);
exit_section_(b, m, ASM_OP, r);
return r;
@ -378,74 +390,28 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// SYMBOL ((WHITE_SPACE? OP_ASSIGN WHITE_SPACE?)|(WHITE_SPACE EQU WHITE_SPACE)) expr
// SYMBOLDEF (OP_ASSIGN|EQU) expr
public static boolean Assignment(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "Assignment")) return false;
if (!nextTokenIs(b, SYMBOL)) return false;
if (!nextTokenIs(b, SYMBOLDEF)) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, SYMBOL);
r = consumeToken(b, SYMBOLDEF);
r = r && Assignment_1(b, l + 1);
r = r && expr(b, l + 1, -1);
exit_section_(b, m, ASSIGNMENT, r);
return r;
}
// (WHITE_SPACE? OP_ASSIGN WHITE_SPACE?)|(WHITE_SPACE EQU WHITE_SPACE)
// OP_ASSIGN|EQU
private static boolean Assignment_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "Assignment_1")) return false;
boolean r;
Marker m = enter_section_(b);
r = Assignment_1_0(b, l + 1);
if (!r) r = Assignment_1_1(b, l + 1);
exit_section_(b, m, null, r);
r = consumeToken(b, OP_ASSIGN);
if (!r) r = consumeToken(b, EQU);
return r;
}
// WHITE_SPACE? OP_ASSIGN WHITE_SPACE?
private static boolean Assignment_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "Assignment_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = Assignment_1_0_0(b, l + 1);
r = r && consumeToken(b, OP_ASSIGN);
r = r && Assignment_1_0_2(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// WHITE_SPACE?
private static boolean Assignment_1_0_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "Assignment_1_0_0")) return false;
consumeToken(b, WHITE_SPACE);
return true;
}
// WHITE_SPACE?
private static boolean Assignment_1_0_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "Assignment_1_0_2")) return false;
consumeToken(b, WHITE_SPACE);
return true;
}
// WHITE_SPACE EQU WHITE_SPACE
private static boolean Assignment_1_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "Assignment_1_1")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokens(b, 0, WHITE_SPACE, EQU, WHITE_SPACE);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// WHITE_SPACE?
static boolean BlankLine(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "BlankLine")) return false;
consumeToken(b, WHITE_SPACE);
return true;
}
/* ********************************************************** */
// DataRegister | AddressRegister
static boolean DataOrAddressRegister(PsiBuilder b, int l) {
@ -472,17 +438,37 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// DataRegister
// DataRegister !(OP_MINUS|OP_AR_DIV)
public static boolean DataRegisterDirectAddressingMode(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "DataRegisterDirectAddressingMode")) return false;
if (!nextTokenIsFast(b, DREG)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, DATA_REGISTER_DIRECT_ADDRESSING_MODE, "<AddressingMode>");
r = DataRegister(b, l + 1);
r = r && DataRegisterDirectAddressingMode_1(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
// !(OP_MINUS|OP_AR_DIV)
private static boolean DataRegisterDirectAddressingMode_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "DataRegisterDirectAddressingMode_1")) return false;
boolean r;
Marker m = enter_section_(b, l, _NOT_);
r = !DataRegisterDirectAddressingMode_1_0(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
// OP_MINUS|OP_AR_DIV
private static boolean DataRegisterDirectAddressingMode_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "DataRegisterDirectAddressingMode_1_0")) return false;
boolean r;
r = consumeTokenFast(b, OP_MINUS);
if (!r) r = consumeTokenFast(b, OP_AR_DIV);
return r;
}
/* ********************************************************** */
// OPSIZE_WL
public static boolean DataWidth(PsiBuilder b, int l) {
@ -502,98 +488,17 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// (!WHITE_SPACE SYMBOL (COLON? COLON?)?)|(WHITE_SPACE? SYMBOL COLON COLON?)
// GLOBAL_LABEL_DEF
public static boolean GlobalLabel(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "GlobalLabel")) return false;
if (!nextTokenIs(b, "<global label>", SYMBOL, WHITE_SPACE)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, GLOBAL_LABEL, "<global label>");
r = GlobalLabel_0(b, l + 1);
if (!r) r = GlobalLabel_1(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
// !WHITE_SPACE SYMBOL (COLON? COLON?)?
private static boolean GlobalLabel_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "GlobalLabel_0")) return false;
if (!nextTokenIs(b, GLOBAL_LABEL_DEF)) return false;
boolean r;
Marker m = enter_section_(b);
r = GlobalLabel_0_0(b, l + 1);
r = r && consumeToken(b, SYMBOL);
r = r && GlobalLabel_0_2(b, l + 1);
exit_section_(b, m, null, r);
r = consumeToken(b, GLOBAL_LABEL_DEF);
exit_section_(b, m, GLOBAL_LABEL, r);
return r;
}
// !WHITE_SPACE
private static boolean GlobalLabel_0_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "GlobalLabel_0_0")) return false;
boolean r;
Marker m = enter_section_(b, l, _NOT_);
r = !consumeToken(b, WHITE_SPACE);
exit_section_(b, l, m, r, false, null);
return r;
}
// (COLON? COLON?)?
private static boolean GlobalLabel_0_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "GlobalLabel_0_2")) return false;
GlobalLabel_0_2_0(b, l + 1);
return true;
}
// COLON? COLON?
private static boolean GlobalLabel_0_2_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "GlobalLabel_0_2_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = GlobalLabel_0_2_0_0(b, l + 1);
r = r && GlobalLabel_0_2_0_1(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// COLON?
private static boolean GlobalLabel_0_2_0_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "GlobalLabel_0_2_0_0")) return false;
consumeToken(b, COLON);
return true;
}
// COLON?
private static boolean GlobalLabel_0_2_0_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "GlobalLabel_0_2_0_1")) return false;
consumeToken(b, COLON);
return true;
}
// WHITE_SPACE? SYMBOL COLON COLON?
private static boolean GlobalLabel_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "GlobalLabel_1")) return false;
boolean r;
Marker m = enter_section_(b);
r = GlobalLabel_1_0(b, l + 1);
r = r && consumeTokens(b, 0, SYMBOL, COLON);
r = r && GlobalLabel_1_3(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// WHITE_SPACE?
private static boolean GlobalLabel_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "GlobalLabel_1_0")) return false;
consumeToken(b, WHITE_SPACE);
return true;
}
// COLON?
private static boolean GlobalLabel_1_3(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "GlobalLabel_1_3")) return false;
consumeToken(b, COLON);
return true;
}
/* ********************************************************** */
// HASH expr
public static boolean ImmediateData(PsiBuilder b, int l) {
@ -608,24 +513,29 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// WHITE_SPACE Instruction
static boolean InstructionOnly(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "InstructionOnly")) return false;
if (!nextTokenIs(b, WHITE_SPACE)) return false;
// AsmInstruction | MacroCall
static boolean Instruction(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "Instruction")) return false;
if (!nextTokenIs(b, "", MNEMONIC, SYMBOL)) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, WHITE_SPACE);
r = r && parseMacroCallOrAsmInstruction(b, l + 1);
exit_section_(b, m, null, r);
r = AsmInstruction(b, l + 1);
if (!r) r = MacroCall(b, l + 1);
return r;
}
/* ********************************************************** */
// Instruction
static boolean InstructionOnly(PsiBuilder b, int l) {
return Instruction(b, l + 1);
}
/* ********************************************************** */
// LocalLabel | GlobalLabel
public static boolean Label(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "Label")) return false;
if (!nextTokenIs(b, "<label>", GLOBAL_LABEL_DEF, LOCAL_LABEL_DEF)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, LABEL, "<label>");
Marker m = enter_section_(b, l, _COLLAPSE_, LABEL, "<label>");
r = LocalLabel(b, l + 1);
if (!r) r = GlobalLabel(b, l + 1);
exit_section_(b, l, m, r, false, null);
@ -650,137 +560,27 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// Label WHITE_SPACE Instruction
// Label Instruction
static boolean LabelWithInstruction(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LabelWithInstruction")) return false;
if (!nextTokenIs(b, "", GLOBAL_LABEL_DEF, LOCAL_LABEL_DEF)) return false;
boolean r;
Marker m = enter_section_(b);
r = Label(b, l + 1);
r = r && consumeToken(b, WHITE_SPACE);
r = r && parseMacroCallOrAsmInstruction(b, l + 1);
r = r && Instruction(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// (!WHITE_SPACE ((DOT SYMBOL)|(SYMBOL DOLLAR)) COLON?)|(WHITE_SPACE? ((DOT SYMBOL)|(SYMBOL DOLLAR)) COLON)
// LOCAL_LABEL_DEF
public static boolean LocalLabel(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LocalLabel")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, LOCAL_LABEL, "<local label>");
r = LocalLabel_0(b, l + 1);
if (!r) r = LocalLabel_1(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
// !WHITE_SPACE ((DOT SYMBOL)|(SYMBOL DOLLAR)) COLON?
private static boolean LocalLabel_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LocalLabel_0")) return false;
if (!nextTokenIs(b, LOCAL_LABEL_DEF)) return false;
boolean r;
Marker m = enter_section_(b);
r = LocalLabel_0_0(b, l + 1);
r = r && LocalLabel_0_1(b, l + 1);
r = r && LocalLabel_0_2(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// !WHITE_SPACE
private static boolean LocalLabel_0_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LocalLabel_0_0")) return false;
boolean r;
Marker m = enter_section_(b, l, _NOT_);
r = !consumeToken(b, WHITE_SPACE);
exit_section_(b, l, m, r, false, null);
return r;
}
// (DOT SYMBOL)|(SYMBOL DOLLAR)
private static boolean LocalLabel_0_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LocalLabel_0_1")) return false;
boolean r;
Marker m = enter_section_(b);
r = LocalLabel_0_1_0(b, l + 1);
if (!r) r = LocalLabel_0_1_1(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// DOT SYMBOL
private static boolean LocalLabel_0_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LocalLabel_0_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokens(b, 0, DOT, SYMBOL);
exit_section_(b, m, null, r);
return r;
}
// SYMBOL DOLLAR
private static boolean LocalLabel_0_1_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LocalLabel_0_1_1")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokens(b, 0, SYMBOL, DOLLAR);
exit_section_(b, m, null, r);
return r;
}
// COLON?
private static boolean LocalLabel_0_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LocalLabel_0_2")) return false;
consumeToken(b, COLON);
return true;
}
// WHITE_SPACE? ((DOT SYMBOL)|(SYMBOL DOLLAR)) COLON
private static boolean LocalLabel_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LocalLabel_1")) return false;
boolean r;
Marker m = enter_section_(b);
r = LocalLabel_1_0(b, l + 1);
r = r && LocalLabel_1_1(b, l + 1);
r = r && consumeToken(b, COLON);
exit_section_(b, m, null, r);
return r;
}
// WHITE_SPACE?
private static boolean LocalLabel_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LocalLabel_1_0")) return false;
consumeToken(b, WHITE_SPACE);
return true;
}
// (DOT SYMBOL)|(SYMBOL DOLLAR)
private static boolean LocalLabel_1_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LocalLabel_1_1")) return false;
boolean r;
Marker m = enter_section_(b);
r = LocalLabel_1_1_0(b, l + 1);
if (!r) r = LocalLabel_1_1_1(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// DOT SYMBOL
private static boolean LocalLabel_1_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LocalLabel_1_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokens(b, 0, DOT, SYMBOL);
exit_section_(b, m, null, r);
return r;
}
// SYMBOL DOLLAR
private static boolean LocalLabel_1_1_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LocalLabel_1_1_1")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokens(b, 0, SYMBOL, DOLLAR);
exit_section_(b, m, null, r);
r = consumeToken(b, LOCAL_LABEL_DEF);
exit_section_(b, m, LOCAL_LABEL, r);
return r;
}
@ -851,7 +651,7 @@ public class M68kParser implements PsiParser, LightPsiParser {
// | REPT_TAG
// | REPT_END_TAG
// | FAIL_TAG)
// (WHITE_SPACE PreprocessorOperands)?
// PreprocessorOperands?
public static boolean PreprocessorDirective(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "PreprocessorDirective")) return false;
boolean r;
@ -904,24 +704,13 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
// (WHITE_SPACE PreprocessorOperands)?
// PreprocessorOperands?
private static boolean PreprocessorDirective_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "PreprocessorDirective_2")) return false;
PreprocessorDirective_2_0(b, l + 1);
PreprocessorOperands(b, l + 1);
return true;
}
// WHITE_SPACE PreprocessorOperands
private static boolean PreprocessorDirective_2_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "PreprocessorDirective_2_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, WHITE_SPACE);
r = r && PreprocessorOperands(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// expr
static boolean PreprocessorOperand(PsiBuilder b, int l) {
@ -1047,6 +836,73 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
/* ********************************************************** */
// (DataOrAddressRegister|RegisterRange) (OP_AR_DIV (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);
r = r && RegisterListAddressingMode_1(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
// DataOrAddressRegister|RegisterRange
private static boolean RegisterListAddressingMode_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "RegisterListAddressingMode_0")) return false;
boolean r;
r = DataOrAddressRegister(b, l + 1);
if (!r) r = RegisterRange(b, l + 1);
return r;
}
// (OP_AR_DIV (DataOrAddressRegister|RegisterRange))*
private static boolean RegisterListAddressingMode_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "RegisterListAddressingMode_1")) return false;
while (true) {
int c = current_position_(b);
if (!RegisterListAddressingMode_1_0(b, l + 1)) break;
if (!empty_element_parsed_guard_(b, "RegisterListAddressingMode_1", c)) break;
}
return true;
}
// OP_AR_DIV (DataOrAddressRegister|RegisterRange)
private static boolean RegisterListAddressingMode_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "RegisterListAddressingMode_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokenFast(b, OP_AR_DIV);
r = r && RegisterListAddressingMode_1_0_1(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// DataOrAddressRegister|RegisterRange
private static boolean RegisterListAddressingMode_1_0_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "RegisterListAddressingMode_1_0_1")) return false;
boolean r;
r = DataOrAddressRegister(b, l + 1);
if (!r) r = RegisterRange(b, l + 1);
return r;
}
/* ********************************************************** */
// 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);
r = r && consumeToken(b, OP_MINUS);
r = r && DataOrAddressRegister(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// REG_CCR | REG_SR | REG_USP | REG_VBR
public static boolean SpecialRegister(PsiBuilder b, int l) {
@ -1099,7 +955,6 @@ public class M68kParser implements PsiParser, LightPsiParser {
// Assignment
// | PreprocessorDirective
// | LabelInsts
// | BlankLine
public static boolean statement(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "statement")) return false;
boolean r;
@ -1107,7 +962,6 @@ public class M68kParser implements PsiParser, LightPsiParser {
r = Assignment(b, l + 1);
if (!r) r = PreprocessorDirective(b, l + 1);
if (!r) r = LabelInsts(b, l + 1);
if (!r) r = BlankLine(b, l + 1);
exit_section_(b, l, m, r, false, M68kParser::statement_recover);
return r;
}
@ -1170,7 +1024,7 @@ public class M68kParser implements PsiParser, LightPsiParser {
} else if (g < 2 && consumeTokenSmart(b, OP_CMP_EQ)) {
r = expr(b, l, 2);
exit_section_(b, l, m, BINARY_CMP_EQ_EXPR, r, true, null);
} else if (g < 2 && binary_cmp_ne_expr_0(b, l + 1)) {
} else if (g < 2 && consumeTokenSmart(b, OP_CMP_NOT_EQ)) {
r = expr(b, l, 2);
exit_section_(b, l, m, BINARY_CMP_NE_EXPR, r, true, null);
} else if (g < 3 && consumeTokenSmart(b, OP_CMP_LT)) {
@ -1223,15 +1077,6 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
// OP_CMP_NOT_EQ|OP_CMP_NOT_EQ2
private static boolean binary_cmp_ne_expr_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "binary_cmp_ne_expr_0")) return false;
boolean r;
r = consumeTokenSmart(b, OP_CMP_NOT_EQ);
if (!r) r = consumeTokenSmart(b, OP_CMP_NOT_EQ2);
return r;
}
public static boolean unary_plus_expr(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "unary_plus_expr")) return false;
if (!nextTokenIsSmart(b, OP_PLUS)) return false;

View File

@ -6,10 +6,10 @@ import org.jetbrains.annotations.Nullable;
public interface M68kAbsoluteAddressAddressingMode extends M68kAddressingMode {
@Nullable
M68kAddressSize getAddressSize();
@Nullable
M68kAddressSize getAddressSize();
@NotNull
M68kExpr getExpr();
@NotNull
M68kExpr getExpr();
}

View File

@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
public interface M68kAddressRegister extends M68kRegister {
@NotNull
PsiElement getAreg();
@NotNull
PsiElement getAreg();
}

View File

@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
public interface M68kAddressRegisterDirectAddressingMode extends M68kAddressingMode {
@NotNull
M68kAddressRegister getAddressRegister();
@NotNull
M68kAddressRegister getAddressRegister();
}

View File

@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
public interface M68kAddressRegisterIndirectAddressingMode extends M68kAddressingMode {
@NotNull
M68kAddressRegister getAddressRegister();
@NotNull
M68kAddressRegister getAddressRegister();
}

View File

@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
public interface M68kAddressRegisterIndirectPostIncAddressingMode extends M68kAddressingMode {
@NotNull
M68kAddressRegister getAddressRegister();
@NotNull
M68kAddressRegister getAddressRegister();
}

View File

@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
public interface M68kAddressRegisterIndirectPreDecAddressingMode extends M68kAddressingMode {
@NotNull
M68kAddressRegister getAddressRegister();
@NotNull
M68kAddressRegister getAddressRegister();
}

View File

@ -5,10 +5,10 @@ import org.jetbrains.annotations.NotNull;
public interface M68kAddressRegisterIndirectWithDisplacementNewAddressingMode extends M68kAddressingMode {
@NotNull
M68kAddressRegister getAddressRegister();
@NotNull
M68kAddressRegister getAddressRegister();
@NotNull
M68kExpr getExpr();
@NotNull
M68kExpr getExpr();
}

View File

@ -5,10 +5,10 @@ import org.jetbrains.annotations.NotNull;
public interface M68kAddressRegisterIndirectWithDisplacementOldAddressingMode extends M68kAddressingMode {
@NotNull
M68kAddressRegister getAddressRegister();
@NotNull
M68kAddressRegister getAddressRegister();
@NotNull
M68kExpr getExpr();
@NotNull
M68kExpr getExpr();
}

View File

@ -6,16 +6,16 @@ import org.jetbrains.annotations.Nullable;
public interface M68kAddressRegisterIndirectWithIndexNewAddressingMode extends M68kAddressingMode {
@NotNull
M68kAddressRegister getAddressRegister();
@NotNull
M68kAddressRegister getAddressRegister();
@Nullable
M68kDataWidth getDataWidth();
@Nullable
M68kDataWidth getDataWidth();
@NotNull
M68kRegister getRegister();
@NotNull
M68kRegister getRegister();
@NotNull
M68kExpr getExpr();
@NotNull
M68kExpr getExpr();
}

View File

@ -6,16 +6,16 @@ import org.jetbrains.annotations.Nullable;
public interface M68kAddressRegisterIndirectWithIndexOldAddressingMode extends M68kAddressingMode {
@NotNull
M68kAddressRegister getAddressRegister();
@NotNull
M68kAddressRegister getAddressRegister();
@Nullable
M68kDataWidth getDataWidth();
@Nullable
M68kDataWidth getDataWidth();
@NotNull
M68kRegister getRegister();
@NotNull
M68kRegister getRegister();
@NotNull
M68kExpr getExpr();
@NotNull
M68kExpr getExpr();
}

View File

@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
public interface M68kAddressSize extends PsiElement {
@NotNull
PsiElement getOpsizeWl();
@NotNull
PsiElement getOpsizeWl();
}

View File

@ -7,13 +7,10 @@ import org.jetbrains.annotations.Nullable;
public interface M68kAsmInstruction extends PsiElement {
@NotNull
M68kAsmOp getAsmOp();
@NotNull
M68kAsmOp getAsmOp();
@Nullable
M68kAsmOperands getAsmOperands();
@Nullable
PsiElement getWhiteSpace();
@Nullable
M68kAsmOperands getAsmOperands();
}

View File

@ -7,10 +7,10 @@ import org.jetbrains.annotations.Nullable;
public interface M68kAsmOp extends PsiElement {
@Nullable
M68kOperandSize getOperandSize();
@Nullable
M68kOperandSize getOperandSize();
@NotNull
PsiElement getSymbol();
@NotNull
PsiElement getMnemonic();
}

View File

@ -8,7 +8,7 @@ import java.util.List;
public interface M68kAsmOperands extends PsiElement {
@NotNull
List<M68kAddressingMode> getAddressingModeList();
@NotNull
List<M68kAddressingMode> getAddressingModeList();
}

View File

@ -3,17 +3,10 @@ package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kAssignment extends PsiElement {
@NotNull
M68kExpr getExpr();
@Nullable
PsiElement getEqu();
@NotNull
PsiElement getSymbol();
@NotNull
M68kExpr getExpr();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryAddExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryBitwiseAndExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryBitwiseOrExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryBitwiseXorExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryCmpEqExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryCmpGeExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryCmpGtExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryCmpLeExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryCmpLtExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryCmpNeExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryDivExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryLogicalAndExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryLogicalOrExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryModExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryMulExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryShiftLExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinaryShiftRExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface M68kBinarySubExpr extends M68kExpr {
@NotNull
List<M68kExpr> getExprList();
@NotNull
List<M68kExpr> getExprList();
}

View File

@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
public interface M68kDataRegister extends M68kRegister {
@NotNull
PsiElement getDreg();
@NotNull
PsiElement getDreg();
}

View File

@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
public interface M68kDataRegisterDirectAddressingMode extends M68kAddressingMode {
@NotNull
M68kDataRegister getDataRegister();
@NotNull
M68kDataRegister getDataRegister();
}

View File

@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
public interface M68kDataWidth extends PsiElement {
@NotNull
PsiElement getOpsizeWl();
@NotNull
PsiElement getOpsizeWl();
}

View File

@ -1,16 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kGlobalLabel extends PsiElement {
@NotNull
PsiElement getSymbol();
@Nullable
PsiElement getWhiteSpace();
public interface M68kGlobalLabel extends M68kLabel {
}

View File

@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
public interface M68kImmediateData extends M68kAddressingMode {
@NotNull
M68kExpr getExpr();
@NotNull
M68kExpr getExpr();
}

View File

@ -0,0 +1,15 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;
public interface M68kInstruction extends PsiElement {
@Nullable
M68kAsmInstruction getAsmInstruction();
@Nullable
M68kMacroCall getMacroCall();
}

View File

@ -2,14 +2,7 @@
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;
public interface M68kLabel extends PsiElement {
@Nullable
M68kGlobalLabel getGlobalLabel();
@Nullable
M68kLocalLabel getLocalLabel();
}

View File

@ -1,16 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kLocalLabel extends PsiElement {
@NotNull
PsiElement getSymbol();
@Nullable
PsiElement getWhiteSpace();
public interface M68kLocalLabel extends M68kLabel {
}

View File

@ -12,52 +12,10 @@ public interface M68kPreprocessorDirective extends PsiElement {
@NotNull
List<M68kExpr> getExprList();
@Nullable
PsiElement getCnopTag();
@Nullable
PsiElement getElseTag();
@Nullable
PsiElement getEndcTag();
@Nullable
PsiElement getEndTag();
@Nullable
PsiElement getEvenTag();
@Nullable
PsiElement getFailTag();
@Nullable
PsiElement getIfTag();
@Nullable
PsiElement getIncbinTag();
@Nullable
PsiElement getIncludeTag();
@Nullable
PsiElement getMacroEndTag();
@Nullable
PsiElement getMacroTag();
@Nullable
PsiElement getReptEndTag();
@Nullable
PsiElement getReptTag();
@Nullable
PsiElement getSectionTag();
@Nullable
PsiElement getSymbol();
@Nullable
PsiElement getWhiteSpace();
}

View File

@ -1,7 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
public interface M68kProgramCounterIndirectWithDisplacementNewAddressingMode extends M68kAddressingMode {
@ -9,7 +8,4 @@ public interface M68kProgramCounterIndirectWithDisplacementNewAddressingMode ext
@NotNull
M68kExpr getExpr();
@NotNull
PsiElement getPc();
}

View File

@ -1,7 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
public interface M68kProgramCounterIndirectWithDisplacementOldAddressingMode extends M68kAddressingMode {
@ -9,7 +8,4 @@ public interface M68kProgramCounterIndirectWithDisplacementOldAddressingMode ext
@NotNull
M68kExpr getExpr();
@NotNull
PsiElement getPc();
}

View File

@ -1,7 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -16,7 +15,4 @@ public interface M68kProgramCounterIndirectWithIndexNewAddressingMode extends M6
@NotNull
M68kExpr getExpr();
@NotNull
PsiElement getPc();
}

View File

@ -1,7 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -16,7 +15,4 @@ public interface M68kProgramCounterIndirectWithIndexOldAddressingMode extends M6
@NotNull
M68kExpr getExpr();
@NotNull
PsiElement getPc();
}

View File

@ -1,21 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;
public interface M68kSpecialRegister extends M68kRegister {
@Nullable
PsiElement getRegCcr();
@Nullable
PsiElement getRegSr();
@Nullable
PsiElement getRegUsp();
@Nullable
PsiElement getRegVbr();
}

View File

@ -6,6 +6,9 @@ import org.jetbrains.annotations.Nullable;
public interface M68kStatement extends PsiElement {
@Nullable
M68kAsmInstruction getAsmInstruction();
@Nullable
M68kAssignment getAssignment();
@ -13,9 +16,9 @@ public interface M68kStatement extends PsiElement {
M68kLabel getLabel();
@Nullable
M68kPreprocessorDirective getPreprocessorDirective();
M68kMacroCall getMacroCall();
@Nullable
PsiElement getWhiteSpace();
M68kPreprocessorDirective getPreprocessorDirective();
}

View File

@ -61,6 +61,7 @@ public interface M68kTypes {
IElementType PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE");
IElementType REF_EXPR = new M68kElementType("REF_EXPR");
IElementType REGISTER = new M68kElementType("REGISTER");
IElementType REGISTER_LIST_ADDRESSING_MODE = new M68kElementType("REGISTER_LIST_ADDRESSING_MODE");
IElementType SPECIAL_REGISTER = new M68kElementType("SPECIAL_REGISTER");
IElementType SPECIAL_REGISTER_DIRECT_ADDRESSING_MODE = new M68kElementType("SPECIAL_REGISTER_DIRECT_ADDRESSING_MODE");
IElementType STATEMENT = new M68kElementType("STATEMENT");
@ -71,27 +72,30 @@ public interface M68kTypes {
IElementType AREG = new M68kTokenType("AREG");
IElementType BINARY = new M68kTokenType("BINARY");
IElementType CNOP_TAG = new M68kTokenType("CNOP_TAG");
IElementType CNOP_TAG = new M68kTokenType("cnop");
IElementType COLON = new M68kTokenType(":");
IElementType COMMENT = new M68kTokenType("COMMENT");
IElementType DECIMAL = new M68kTokenType("DECIMAL");
IElementType DOLLAR = new M68kTokenType("$");
IElementType DOT = new M68kTokenType(".");
IElementType DREG = new M68kTokenType("DREG");
IElementType ELSE_TAG = new M68kTokenType("ELSE_TAG");
IElementType ENDC_TAG = new M68kTokenType("ENDC_TAG");
IElementType END_TAG = new M68kTokenType("END_TAG");
IElementType ELSE_TAG = new M68kTokenType("else");
IElementType ENDC_TAG = new M68kTokenType("endc");
IElementType END_TAG = new M68kTokenType("end");
IElementType EOL = new M68kTokenType("EOL");
IElementType EQU = new M68kTokenType("EQU");
IElementType EVEN_TAG = new M68kTokenType("EVEN_TAG");
IElementType FAIL_TAG = new M68kTokenType("FAIL_TAG");
IElementType EQU = new M68kTokenType("equ");
IElementType EVEN_TAG = new M68kTokenType("even");
IElementType FAIL_TAG = new M68kTokenType("fail");
IElementType GLOBAL_LABEL_DEF = new M68kTokenType("GLOBAL_LABEL_DEF");
IElementType HASH = new M68kTokenType("#");
IElementType HEXADECIMAL = new M68kTokenType("HEXADECIMAL");
IElementType IF_TAG = new M68kTokenType("IF_TAG");
IElementType INCBIN_TAG = new M68kTokenType("INCBIN_TAG");
IElementType INCLUDE_TAG = new M68kTokenType("INCLUDE_TAG");
IElementType MACRO_END_TAG = new M68kTokenType("MACRO_END_TAG");
IElementType MACRO_TAG = new M68kTokenType("MACRO_TAG");
IElementType INCBIN_TAG = new M68kTokenType("incbin");
IElementType INCLUDE_TAG = new M68kTokenType("include");
IElementType LOCAL_LABEL_DEF = new M68kTokenType("LOCAL_LABEL_DEF");
IElementType MACRO_END_TAG = new M68kTokenType("endm");
IElementType MACRO_TAG = new M68kTokenType("macro");
IElementType MNEMONIC = new M68kTokenType("MNEMONIC");
IElementType OCTAL = new M68kTokenType("OCTAL");
IElementType OPSIZE_BS = new M68kTokenType("OPSIZE_BS");
IElementType OPSIZE_WL = new M68kTokenType("OPSIZE_WL");
@ -110,105 +114,148 @@ public interface M68kTypes {
IElementType OP_CMP_LT = new M68kTokenType("<");
IElementType OP_CMP_LT_EQ = new M68kTokenType("<=");
IElementType OP_CMP_NOT_EQ = new M68kTokenType("!=");
IElementType OP_CMP_NOT_EQ2 = new M68kTokenType("<>");
IElementType OP_LOGICAL_AND = new M68kTokenType("&&");
IElementType OP_LOGICAL_OR = new M68kTokenType("||");
IElementType OP_MINUS = new M68kTokenType("-");
IElementType OP_PLUS = new M68kTokenType("+");
IElementType OP_UNARY_COMPL = new M68kTokenType("~");
IElementType OP_UNARY_NOT = new M68kTokenType("!");
IElementType PC = new M68kTokenType("PC");
IElementType REG_CCR = new M68kTokenType("REG_CCR");
IElementType REG_SR = new M68kTokenType("REG_SR");
IElementType REG_USP = new M68kTokenType("REG_USP");
IElementType REG_VBR = new M68kTokenType("REG_VBR");
IElementType REPT_END_TAG = new M68kTokenType("REPT_END_TAG");
IElementType REPT_TAG = new M68kTokenType("REPT_TAG");
IElementType PC = new M68kTokenType("pc");
IElementType REG_CCR = new M68kTokenType("ccr");
IElementType REG_SR = new M68kTokenType("sr");
IElementType REG_USP = new M68kTokenType("usp");
IElementType REG_VBR = new M68kTokenType("vbr");
IElementType REPT_END_TAG = new M68kTokenType("endr");
IElementType REPT_TAG = new M68kTokenType("rept");
IElementType ROUND_L = new M68kTokenType("(");
IElementType ROUND_R = new M68kTokenType(")");
IElementType SECTION_TAG = new M68kTokenType("SECTION_TAG");
IElementType SECTION_TAG = new M68kTokenType("section");
IElementType SEMICOLON = new M68kTokenType(";");
IElementType SEPARATOR = new M68kTokenType(",");
IElementType SQUARE_L = new M68kTokenType("[");
IElementType SQUARE_R = new M68kTokenType("]");
IElementType STRINGLIT = new M68kTokenType("STRINGLIT");
IElementType SYMBOL = new M68kTokenType("SYMBOL");
IElementType WHITE_SPACE = new M68kTokenType("WHITE_SPACE");
IElementType SYMBOLDEF = new M68kTokenType("SYMBOLDEF");
class Factory {
public static PsiElement createElement(ASTNode node) {
IElementType type = node.getElementType();
if (type == ABSOLUTE_ADDRESS_ADDRESSING_MODE) return new M68kAbsoluteAddressAddressingModeImpl(node);
else if (type == ADDRESS_REGISTER) return new M68kAddressRegisterImpl(node);
else if (type == ADDRESS_REGISTER_DIRECT_ADDRESSING_MODE)
if (type == ABSOLUTE_ADDRESS_ADDRESSING_MODE) {
return new M68kAbsoluteAddressAddressingModeImpl(node);
} else if (type == ADDRESS_REGISTER) {
return new M68kAddressRegisterImpl(node);
} else if (type == ADDRESS_REGISTER_DIRECT_ADDRESSING_MODE) {
return new M68kAddressRegisterDirectAddressingModeImpl(node);
else if (type == ADDRESS_REGISTER_INDIRECT_ADDRESSING_MODE)
} else if (type == ADDRESS_REGISTER_INDIRECT_ADDRESSING_MODE) {
return new M68kAddressRegisterIndirectAddressingModeImpl(node);
else if (type == ADDRESS_REGISTER_INDIRECT_POST_INC_ADDRESSING_MODE)
} else if (type == ADDRESS_REGISTER_INDIRECT_POST_INC_ADDRESSING_MODE) {
return new M68kAddressRegisterIndirectPostIncAddressingModeImpl(node);
else if (type == ADDRESS_REGISTER_INDIRECT_PRE_DEC_ADDRESSING_MODE)
} else if (type == ADDRESS_REGISTER_INDIRECT_PRE_DEC_ADDRESSING_MODE) {
return new M68kAddressRegisterIndirectPreDecAddressingModeImpl(node);
else if (type == ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE)
} else if (type == ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE) {
return new M68kAddressRegisterIndirectWithDisplacementNewAddressingModeImpl(node);
else if (type == ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE)
} else if (type == ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE) {
return new M68kAddressRegisterIndirectWithDisplacementOldAddressingModeImpl(node);
else if (type == ADDRESS_REGISTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE)
} else if (type == ADDRESS_REGISTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE) {
return new M68kAddressRegisterIndirectWithIndexNewAddressingModeImpl(node);
else if (type == ADDRESS_REGISTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE)
} else if (type == ADDRESS_REGISTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE) {
return new M68kAddressRegisterIndirectWithIndexOldAddressingModeImpl(node);
else if (type == ADDRESS_SIZE) return new M68kAddressSizeImpl(node);
else if (type == ASM_INSTRUCTION) return new M68kAsmInstructionImpl(node);
else if (type == ASM_OP) return new M68kAsmOpImpl(node);
else if (type == ASM_OPERANDS) return new M68kAsmOperandsImpl(node);
else if (type == ASSIGNMENT) return new M68kAssignmentImpl(node);
else if (type == BINARY_ADD_EXPR) return new M68kBinaryAddExprImpl(node);
else if (type == BINARY_BITWISE_AND_EXPR) return new M68kBinaryBitwiseAndExprImpl(node);
else if (type == BINARY_BITWISE_OR_EXPR) return new M68kBinaryBitwiseOrExprImpl(node);
else if (type == BINARY_BITWISE_XOR_EXPR) return new M68kBinaryBitwiseXorExprImpl(node);
else if (type == BINARY_CMP_EQ_EXPR) return new M68kBinaryCmpEqExprImpl(node);
else if (type == BINARY_CMP_GE_EXPR) return new M68kBinaryCmpGeExprImpl(node);
else if (type == BINARY_CMP_GT_EXPR) return new M68kBinaryCmpGtExprImpl(node);
else if (type == BINARY_CMP_LE_EXPR) return new M68kBinaryCmpLeExprImpl(node);
else if (type == BINARY_CMP_LT_EXPR) return new M68kBinaryCmpLtExprImpl(node);
else if (type == BINARY_CMP_NE_EXPR) return new M68kBinaryCmpNeExprImpl(node);
else if (type == BINARY_DIV_EXPR) return new M68kBinaryDivExprImpl(node);
else if (type == BINARY_LOGICAL_AND_EXPR) return new M68kBinaryLogicalAndExprImpl(node);
else if (type == BINARY_LOGICAL_OR_EXPR) return new M68kBinaryLogicalOrExprImpl(node);
else if (type == BINARY_MOD_EXPR) return new M68kBinaryModExprImpl(node);
else if (type == BINARY_MUL_EXPR) return new M68kBinaryMulExprImpl(node);
else if (type == BINARY_SHIFT_L_EXPR) return new M68kBinaryShiftLExprImpl(node);
else if (type == BINARY_SHIFT_R_EXPR) return new M68kBinaryShiftRExprImpl(node);
else if (type == BINARY_SUB_EXPR) return new M68kBinarySubExprImpl(node);
else if (type == DATA_REGISTER) return new M68kDataRegisterImpl(node);
else if (type == DATA_REGISTER_DIRECT_ADDRESSING_MODE)
} else if (type == ADDRESS_SIZE) {
return new M68kAddressSizeImpl(node);
} else if (type == ASM_INSTRUCTION) {
return new M68kAsmInstructionImpl(node);
} else if (type == ASM_OP) {
return new M68kAsmOpImpl(node);
} else if (type == ASM_OPERANDS) {
return new M68kAsmOperandsImpl(node);
} else if (type == ASSIGNMENT) {
return new M68kAssignmentImpl(node);
} else if (type == BINARY_ADD_EXPR) {
return new M68kBinaryAddExprImpl(node);
} else if (type == BINARY_BITWISE_AND_EXPR) {
return new M68kBinaryBitwiseAndExprImpl(node);
} else if (type == BINARY_BITWISE_OR_EXPR) {
return new M68kBinaryBitwiseOrExprImpl(node);
} else if (type == BINARY_BITWISE_XOR_EXPR) {
return new M68kBinaryBitwiseXorExprImpl(node);
} else if (type == BINARY_CMP_EQ_EXPR) {
return new M68kBinaryCmpEqExprImpl(node);
} else if (type == BINARY_CMP_GE_EXPR) {
return new M68kBinaryCmpGeExprImpl(node);
} else if (type == BINARY_CMP_GT_EXPR) {
return new M68kBinaryCmpGtExprImpl(node);
} else if (type == BINARY_CMP_LE_EXPR) {
return new M68kBinaryCmpLeExprImpl(node);
} else if (type == BINARY_CMP_LT_EXPR) {
return new M68kBinaryCmpLtExprImpl(node);
} else if (type == BINARY_CMP_NE_EXPR) {
return new M68kBinaryCmpNeExprImpl(node);
} else if (type == BINARY_DIV_EXPR) {
return new M68kBinaryDivExprImpl(node);
} else if (type == BINARY_LOGICAL_AND_EXPR) {
return new M68kBinaryLogicalAndExprImpl(node);
} else if (type == BINARY_LOGICAL_OR_EXPR) {
return new M68kBinaryLogicalOrExprImpl(node);
} else if (type == BINARY_MOD_EXPR) {
return new M68kBinaryModExprImpl(node);
} else if (type == BINARY_MUL_EXPR) {
return new M68kBinaryMulExprImpl(node);
} else if (type == BINARY_SHIFT_L_EXPR) {
return new M68kBinaryShiftLExprImpl(node);
} else if (type == BINARY_SHIFT_R_EXPR) {
return new M68kBinaryShiftRExprImpl(node);
} else if (type == BINARY_SUB_EXPR) {
return new M68kBinarySubExprImpl(node);
} else if (type == DATA_REGISTER) {
return new M68kDataRegisterImpl(node);
} else if (type == DATA_REGISTER_DIRECT_ADDRESSING_MODE) {
return new M68kDataRegisterDirectAddressingModeImpl(node);
else if (type == DATA_WIDTH) return new M68kDataWidthImpl(node);
else if (type == GLOBAL_LABEL) return new M68kGlobalLabelImpl(node);
else if (type == IMMEDIATE_DATA) return new M68kImmediateDataImpl(node);
else if (type == LABEL) return new M68kLabelImpl(node);
else if (type == LITERAL_EXPR) return new M68kLiteralExprImpl(node);
else if (type == LOCAL_LABEL) return new M68kLocalLabelImpl(node);
else if (type == MACRO_CALL) return new M68kMacroCallImpl(node);
else if (type == OPERAND_SIZE) return new M68kOperandSizeImpl(node);
else if (type == PAREN_EXPR) return new M68kParenExprImpl(node);
else if (type == PREPROCESSOR_DIRECTIVE) return new M68kPreprocessorDirectiveImpl(node);
else if (type == PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE)
} else if (type == DATA_WIDTH) {
return new M68kDataWidthImpl(node);
} else if (type == GLOBAL_LABEL) {
return new M68kGlobalLabelImpl(node);
} else if (type == IMMEDIATE_DATA) {
return new M68kImmediateDataImpl(node);
} else if (type == LITERAL_EXPR) {
return new M68kLiteralExprImpl(node);
} else if (type == LOCAL_LABEL) {
return new M68kLocalLabelImpl(node);
} else if (type == MACRO_CALL) {
return new M68kMacroCallImpl(node);
} else if (type == OPERAND_SIZE) {
return new M68kOperandSizeImpl(node);
} else if (type == PAREN_EXPR) {
return new M68kParenExprImpl(node);
} else if (type == PREPROCESSOR_DIRECTIVE) {
return new M68kPreprocessorDirectiveImpl(node);
} else if (type == PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE) {
return new M68kProgramCounterIndirectWithDisplacementNewAddressingModeImpl(node);
else if (type == PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE)
} else if (type == PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE) {
return new M68kProgramCounterIndirectWithDisplacementOldAddressingModeImpl(node);
else if (type == PROGRAM_COUNTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE)
} else if (type == PROGRAM_COUNTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE) {
return new M68kProgramCounterIndirectWithIndexNewAddressingModeImpl(node);
else if (type == PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE)
} else if (type == PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE) {
return new M68kProgramCounterIndirectWithIndexOldAddressingModeImpl(node);
else if (type == REF_EXPR) return new M68kRefExprImpl(node);
else if (type == SPECIAL_REGISTER) return new M68kSpecialRegisterImpl(node);
else if (type == SPECIAL_REGISTER_DIRECT_ADDRESSING_MODE)
} else if (type == REF_EXPR) {
return new M68kRefExprImpl(node);
} else if (type == REGISTER_LIST_ADDRESSING_MODE) {
return new M68kRegisterListAddressingModeImpl(node);
} else if (type == SPECIAL_REGISTER) {
return new M68kSpecialRegisterImpl(node);
} else if (type == SPECIAL_REGISTER_DIRECT_ADDRESSING_MODE) {
return new M68kSpecialRegisterDirectAddressingModeImpl(node);
else if (type == STATEMENT) return new M68kStatementImpl(node);
else if (type == UNARY_COMPL_EXPR) return new M68kUnaryComplExprImpl(node);
else if (type == UNARY_MINUS_EXPR) return new M68kUnaryMinusExprImpl(node);
else if (type == UNARY_NOT_EXPR) return new M68kUnaryNotExprImpl(node);
else if (type == UNARY_PLUS_EXPR) return new M68kUnaryPlusExprImpl(node);
} else if (type == STATEMENT) {
return new M68kStatementImpl(node);
} else if (type == UNARY_COMPL_EXPR) {
return new M68kUnaryComplExprImpl(node);
} else if (type == UNARY_MINUS_EXPR) {
return new M68kUnaryMinusExprImpl(node);
} else if (type == UNARY_NOT_EXPR) {
return new M68kUnaryNotExprImpl(node);
} else if (type == UNARY_PLUS_EXPR) {
return new M68kUnaryPlusExprImpl(node);
}
throw new AssertionError("Unknown element type: " + type);
}
}

View File

@ -84,7 +84,7 @@ public class M68kVisitor extends PsiElementVisitor {
}
public void visitGlobalLabel(@NotNull M68kGlobalLabel o) {
visitPsiElement(o);
visitLabel(o);
}
public void visitImmediateData(@NotNull M68kImmediateData o) {
@ -96,7 +96,7 @@ public class M68kVisitor extends PsiElementVisitor {
}
public void visitLocalLabel(@NotNull M68kLocalLabel o) {
visitPsiElement(o);
visitLabel(o);
}
public void visitMacroCall(@NotNull M68kMacroCall o) {
@ -131,6 +131,10 @@ public class M68kVisitor extends PsiElementVisitor {
visitPsiElement(o);
}
public void visitRegisterListAddressingMode(@NotNull M68kRegisterListAddressingMode o) {
visitAddressingMode(o);
}
public void visitSpecialRegister(@NotNull M68kSpecialRegister o) {
visitRegister(o);
}

View File

@ -3,7 +3,6 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import de.platon42.intellij.plugins.m68k.psi.M68kAsmInstruction;
import de.platon42.intellij.plugins.m68k.psi.M68kAsmOp;
@ -12,8 +11,6 @@ import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.WHITE_SPACE;
public class M68kAsmInstructionImpl extends ASTWrapperPsiElement implements M68kAsmInstruction {
public M68kAsmInstructionImpl(@NotNull ASTNode node) {
@ -42,10 +39,4 @@ public class M68kAsmInstructionImpl extends ASTWrapperPsiElement implements M68k
return findChildByClass(M68kAsmOperands.class);
}
@Override
@Nullable
public PsiElement getWhiteSpace() {
return findChildByType(WHITE_SPACE);
}
}

View File

@ -11,7 +11,7 @@ import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.SYMBOL;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.MNEMONIC;
public class M68kAsmOpImpl extends ASTWrapperPsiElement implements M68kAsmOp {
@ -37,8 +37,8 @@ public class M68kAsmOpImpl extends ASTWrapperPsiElement implements M68kAsmOp {
@Override
@NotNull
public PsiElement getSymbol() {
return findNotNullChildByType(SYMBOL);
public PsiElement getMnemonic() {
return findNotNullChildByType(MNEMONIC);
}
}

View File

@ -3,16 +3,11 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import de.platon42.intellij.plugins.m68k.psi.M68kAssignment;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.EQU;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.SYMBOL;
public class M68kAssignmentImpl extends ASTWrapperPsiElement implements M68kAssignment {
@ -36,16 +31,4 @@ public class M68kAssignmentImpl extends ASTWrapperPsiElement implements M68kAssi
return findNotNullChildByClass(M68kExpr.class);
}
@Override
@Nullable
public PsiElement getEqu() {
return findChildByType(EQU);
}
@Override
@NotNull
public PsiElement getSymbol() {
return findNotNullChildByType(SYMBOL);
}
}

View File

@ -1,24 +1,19 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabel;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.SYMBOL;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.WHITE_SPACE;
public class M68kGlobalLabelImpl extends ASTWrapperPsiElement implements M68kGlobalLabel {
public class M68kGlobalLabelImpl extends M68kLabelImpl implements M68kGlobalLabel {
public M68kGlobalLabelImpl(@NotNull ASTNode node) {
super(node);
}
@Override
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitGlobalLabel(this);
}
@ -29,16 +24,4 @@ public class M68kGlobalLabelImpl extends ASTWrapperPsiElement implements M68kGlo
else super.accept(visitor);
}
@Override
@NotNull
public PsiElement getSymbol() {
return findNotNullChildByType(SYMBOL);
}
@Override
@Nullable
public PsiElement getWhiteSpace() {
return findChildByType(WHITE_SPACE);
}
}

View File

@ -4,14 +4,11 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabel;
import de.platon42.intellij.plugins.m68k.psi.M68kLabel;
import de.platon42.intellij.plugins.m68k.psi.M68kLocalLabel;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class M68kLabelImpl extends ASTWrapperPsiElement implements M68kLabel {
public abstract class M68kLabelImpl extends ASTWrapperPsiElement implements M68kLabel {
public M68kLabelImpl(@NotNull ASTNode node) {
super(node);
@ -27,16 +24,4 @@ public class M68kLabelImpl extends ASTWrapperPsiElement implements M68kLabel {
else super.accept(visitor);
}
@Override
@Nullable
public M68kGlobalLabel getGlobalLabel() {
return findChildByClass(M68kGlobalLabel.class);
}
@Override
@Nullable
public M68kLocalLabel getLocalLabel() {
return findChildByClass(M68kLocalLabel.class);
}
}

View File

@ -1,24 +1,19 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import de.platon42.intellij.plugins.m68k.psi.M68kLocalLabel;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.SYMBOL;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.WHITE_SPACE;
public class M68kLocalLabelImpl extends ASTWrapperPsiElement implements M68kLocalLabel {
public class M68kLocalLabelImpl extends M68kLabelImpl implements M68kLocalLabel {
public M68kLocalLabelImpl(@NotNull ASTNode node) {
super(node);
}
@Override
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitLocalLabel(this);
}
@ -29,16 +24,4 @@ public class M68kLocalLabelImpl extends ASTWrapperPsiElement implements M68kLoca
else super.accept(visitor);
}
@Override
@NotNull
public PsiElement getSymbol() {
return findNotNullChildByType(SYMBOL);
}
@Override
@Nullable
public PsiElement getWhiteSpace() {
return findChildByType(WHITE_SPACE);
}
}

View File

@ -14,7 +14,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.*;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.IF_TAG;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.SYMBOL;
public class M68kPreprocessorDirectiveImpl extends ASTWrapperPsiElement implements M68kPreprocessorDirective {
@ -38,100 +39,16 @@ public class M68kPreprocessorDirectiveImpl extends ASTWrapperPsiElement implemen
return PsiTreeUtil.getChildrenOfTypeAsList(this, M68kExpr.class);
}
@Override
@Nullable
public PsiElement getCnopTag() {
return findChildByType(CNOP_TAG);
}
@Override
@Nullable
public PsiElement getElseTag() {
return findChildByType(ELSE_TAG);
}
@Override
@Nullable
public PsiElement getEndcTag() {
return findChildByType(ENDC_TAG);
}
@Override
@Nullable
public PsiElement getEndTag() {
return findChildByType(END_TAG);
}
@Override
@Nullable
public PsiElement getEvenTag() {
return findChildByType(EVEN_TAG);
}
@Override
@Nullable
public PsiElement getFailTag() {
return findChildByType(FAIL_TAG);
}
@Override
@Nullable
public PsiElement getIfTag() {
return findChildByType(IF_TAG);
}
@Override
@Nullable
public PsiElement getIncbinTag() {
return findChildByType(INCBIN_TAG);
}
@Override
@Nullable
public PsiElement getIncludeTag() {
return findChildByType(INCLUDE_TAG);
}
@Override
@Nullable
public PsiElement getMacroEndTag() {
return findChildByType(MACRO_END_TAG);
}
@Override
@Nullable
public PsiElement getMacroTag() {
return findChildByType(MACRO_TAG);
}
@Override
@Nullable
public PsiElement getReptEndTag() {
return findChildByType(REPT_END_TAG);
}
@Override
@Nullable
public PsiElement getReptTag() {
return findChildByType(REPT_TAG);
}
@Override
@Nullable
public PsiElement getSectionTag() {
return findChildByType(SECTION_TAG);
}
@Override
@Nullable
public PsiElement getSymbol() {
return findChildByType(SYMBOL);
}
@Override
@Nullable
public PsiElement getWhiteSpace() {
return findChildByType(WHITE_SPACE);
}
}

View File

@ -2,15 +2,12 @@
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kProgramCounterIndirectWithDisplacementNewAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.PC;
public class M68kProgramCounterIndirectWithDisplacementNewAddressingModeImpl extends M68kAddressingModeImpl implements M68kProgramCounterIndirectWithDisplacementNewAddressingMode {
public M68kProgramCounterIndirectWithDisplacementNewAddressingModeImpl(@NotNull ASTNode node) {
@ -34,10 +31,4 @@ public class M68kProgramCounterIndirectWithDisplacementNewAddressingModeImpl ext
return findNotNullChildByClass(M68kExpr.class);
}
@Override
@NotNull
public PsiElement getPc() {
return findNotNullChildByType(PC);
}
}

View File

@ -2,15 +2,12 @@
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kProgramCounterIndirectWithDisplacementOldAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.PC;
public class M68kProgramCounterIndirectWithDisplacementOldAddressingModeImpl extends M68kAddressingModeImpl implements M68kProgramCounterIndirectWithDisplacementOldAddressingMode {
public M68kProgramCounterIndirectWithDisplacementOldAddressingModeImpl(@NotNull ASTNode node) {
@ -34,10 +31,4 @@ public class M68kProgramCounterIndirectWithDisplacementOldAddressingModeImpl ext
return findNotNullChildByClass(M68kExpr.class);
}
@Override
@NotNull
public PsiElement getPc() {
return findNotNullChildByType(PC);
}
}

View File

@ -2,14 +2,11 @@
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.PC;
public class M68kProgramCounterIndirectWithIndexNewAddressingModeImpl extends M68kAddressingModeImpl implements M68kProgramCounterIndirectWithIndexNewAddressingMode {
public M68kProgramCounterIndirectWithIndexNewAddressingModeImpl(@NotNull ASTNode node) {
@ -45,10 +42,4 @@ public class M68kProgramCounterIndirectWithIndexNewAddressingModeImpl extends M6
return findNotNullChildByClass(M68kExpr.class);
}
@Override
@NotNull
public PsiElement getPc() {
return findNotNullChildByType(PC);
}
}

View File

@ -2,14 +2,11 @@
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.PC;
public class M68kProgramCounterIndirectWithIndexOldAddressingModeImpl extends M68kAddressingModeImpl implements M68kProgramCounterIndirectWithIndexOldAddressingMode {
public M68kProgramCounterIndirectWithIndexOldAddressingModeImpl(@NotNull ASTNode node) {
@ -45,10 +42,4 @@ public class M68kProgramCounterIndirectWithIndexOldAddressingModeImpl extends M6
return findNotNullChildByClass(M68kExpr.class);
}
@Override
@NotNull
public PsiElement getPc() {
return findNotNullChildByType(PC);
}
}

View File

@ -2,14 +2,10 @@
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import de.platon42.intellij.plugins.m68k.psi.M68kSpecialRegister;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.*;
public class M68kSpecialRegisterImpl extends M68kRegisterImpl implements M68kSpecialRegister {
@ -28,28 +24,4 @@ public class M68kSpecialRegisterImpl extends M68kRegisterImpl implements M68kSpe
else super.accept(visitor);
}
@Override
@Nullable
public PsiElement getRegCcr() {
return findChildByType(REG_CCR);
}
@Override
@Nullable
public PsiElement getRegSr() {
return findChildByType(REG_SR);
}
@Override
@Nullable
public PsiElement getRegUsp() {
return findChildByType(REG_USP);
}
@Override
@Nullable
public PsiElement getRegVbr() {
return findChildByType(REG_VBR);
}
}

View File

@ -3,14 +3,11 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.WHITE_SPACE;
public class M68kStatementImpl extends ASTWrapperPsiElement implements M68kStatement {
public M68kStatementImpl(@NotNull ASTNode node) {
@ -27,6 +24,12 @@ public class M68kStatementImpl extends ASTWrapperPsiElement implements M68kState
else super.accept(visitor);
}
@Override
@Nullable
public M68kAsmInstruction getAsmInstruction() {
return findChildByClass(M68kAsmInstruction.class);
}
@Override
@Nullable
public M68kAssignment getAssignment() {
@ -41,14 +44,14 @@ public class M68kStatementImpl extends ASTWrapperPsiElement implements M68kState
@Override
@Nullable
public M68kPreprocessorDirective getPreprocessorDirective() {
return findChildByClass(M68kPreprocessorDirective.class);
public M68kMacroCall getMacroCall() {
return findChildByClass(M68kMacroCall.class);
}
@Override
@Nullable
public PsiElement getWhiteSpace() {
return findChildByType(WHITE_SPACE);
public M68kPreprocessorDirective getPreprocessorDirective() {
return findChildByClass(M68kPreprocessorDirective.class);
}
}

View File

@ -9,7 +9,7 @@ import javax.swing.Icon
class M68kFileType private constructor() : LanguageFileType(M68kLanguage.INSTANCE, true) {
@NonNls
override fun getName(): String {
return "M68k"
return "M68k Assembler"
}
override fun getDescription(): String {

View File

@ -1,6 +0,0 @@
package de.platon42.intellij.plugins.m68k
object M68kMnemonics {
val mnemonics =
setOf("move", "moveq", "add", "addi", "adda", "addq", "sub", "sub", "subi", "suba", "subq", "rts", "jsr")
}

View File

@ -0,0 +1,121 @@
package de.platon42.intellij.plugins.m68k.asm
enum class Machine {
MC68000
}
data class IsaData(
val mnemonic: String,
val description: String,
val machine: Machine = Machine.MC68000,
val altMnemonics: List<String> = emptyList(),
val conditionCodes: List<String> = emptyList()
)
object M68kIsa {
val conditionCodes =
listOf("cc", "ls", "cs", "lt", "eq", "mi", "f", "ne", "ge", "pl", "gt", "t", "hi", "vc", "le", "vs")
val conditionCodesBcc = conditionCodes.filterNot { it == "f" || it == "t" }
val isaData = listOf(
IsaData("abcd", "Add Decimal with Extend"),
IsaData("add", "Add"),
IsaData("adda", "Add Address"),
IsaData("addi", "Add Immediate"),
IsaData("addq", "Add Quick"),
IsaData("addx", "Add with Extend"),
IsaData("and", "Logical AND"),
IsaData("andi", "Logical AND Immediate"),
IsaData("andi", "to CCR AND Immediate to Condition Code Register"),
IsaData("andi", "to SR AND Immediate to Status Register"),
IsaData("asl", "Arithmetic Shift Left"),
IsaData("asr", "Arithmetic Shift Right"),
IsaData("bCC", "Branch Conditionally", conditionCodes = conditionCodesBcc),
IsaData("bchg", "Test Bit and Change"),
IsaData("bclr", "Test Bit and Clear"),
IsaData("bra", "Branch"),
IsaData("bset", "Test Bit and Set"),
IsaData("bsr", "Branch to Subroutine"),
IsaData("btst", "Test Bit"),
IsaData("chk", "Check Register Against Bound"),
IsaData("clr", "Clear"),
IsaData("cmp", "Compare"),
IsaData("cmpa", "Compare Address"),
IsaData("cmpi", "Compare Immediate"),
IsaData("cmpm", "Compare Memory to Memory"),
IsaData(
"dbCC",
"Test Condition, Decrement, and Branch",
altMnemonics = listOf("dbra"),
conditionCodes = conditionCodes
),
IsaData("divs", "Signed Divide"),
IsaData("divu", "Unsigned Divide"),
IsaData("eor", "Logical Exclusive-OR"),
IsaData("eori", "Logical Exclusive-OR Immediate"),
IsaData("eori", "to CCR Exclusive-OR Immediate to Condition Code Register"),
IsaData("eori", "to SR Exclusive-OR Immediate to Status Register"),
IsaData("exg", "Exchange Registers"),
IsaData("ext", "Sign Extend"),
IsaData("illegal", "Take Illegal Instruction Trap"),
IsaData("jmp", "Jump"),
IsaData("jsr", "Jump to Subroutine"),
IsaData("lea", "Load Effective Address"),
IsaData("link", "Link and Allocate"),
IsaData("lsl", "Logical Shift Left"),
IsaData("lsr", "Logical Shift Right"),
IsaData("move", "Move"),
IsaData("movea", "Move Address"),
IsaData("move", "to CCR Move to Condition Code Register"),
IsaData("move", "from SR Move from Status Register"),
IsaData("move", "to SR Move to Status Register"),
IsaData("move", "USP Move User Stack Pointer"),
IsaData("movem", "Move Multiple Registers"),
IsaData("movep", "Move Peripheral"),
IsaData("moveq", "Move Quick"),
IsaData("muls", "Signed Multiply"),
IsaData("mulu", "Unsigned Multiply"),
IsaData("nbcd", "Negate Decimal with Extend"),
IsaData("neg", "Negate"),
IsaData("negx", "Negate with Extend"),
IsaData("nop", "No Operation"),
IsaData("not", "Logical Complement"),
IsaData("or", "Logical Inclusive-OR"),
IsaData("ori", "Logical Inclusive-OR Immediate"),
IsaData("ori", "to CCR Inclusive-OR Immediate to Condition Code Register"),
IsaData("ori", "to SR Inclusive-OR Immediate to Status Register"),
IsaData("pea", "Push Effective Address"),
IsaData("reset", "Reset External Devices"),
IsaData("rol", "Rotate Left"),
IsaData("ror", "Rotate Right"),
IsaData("roxl", "Rotate with Extend Left"),
IsaData("roxr", "Rotate with Extend Right"),
IsaData("rte", "Return from Exception"),
IsaData("rtr", "Return and Restore"),
IsaData("rts", "Return from Subroutine"),
IsaData("sbcd", "Subtract Decimal with Extend"),
IsaData("sCC", "Set Conditionally", conditionCodes = conditionCodes),
IsaData("stop", "Stop"),
IsaData("sub", "Subtract"),
IsaData("suba", "Subtract Address"),
IsaData("subi", "Subtract Immediate"),
IsaData("subq", "Subtract Quick"),
IsaData("subx", "Subtract with Extend"),
IsaData("swap", "Swap Register Words"),
IsaData("tas", "Test Operand and Set"),
IsaData("trap", "Trap"),
IsaData("trapv", "Trap on Overflow"),
IsaData("tst", "Test Operand"),
IsaData("unlk", "Unlink "),
)
val mnemonics =
isaData.asSequence()
.flatMap {
if (it.conditionCodes.isEmpty()) it.altMnemonics.plus(it.mnemonic) else it.altMnemonics.plus(it.conditionCodes
.map { cc ->
it.mnemonic.replace("CC", cc)
})
}
.toSet()
}

View File

@ -0,0 +1,13 @@
package de.platon42.intellij.plugins.m68k.lexer
import de.platon42.intellij.plugins.m68k.asm.M68kIsa.mnemonics
object LexerUtil {
private val ASSIGNMENT_SEPARATORS = charArrayOf('=', ' ', '\t')
@JvmStatic
fun isAsmMnemonic(text: CharSequence) = mnemonics.contains(text.toString().lowercase())
@JvmStatic
fun pushbackAssignment(text: CharSequence) = text.length - 1 - text.indexOfAny(ASSIGNMENT_SEPARATORS)
}

View File

@ -6,6 +6,7 @@ import com.intellij.psi.tree.IElementType;
import static com.intellij.psi.TokenType.BAD_CHARACTER;
import static com.intellij.psi.TokenType.WHITE_SPACE;
import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.*;
import static de.platon42.intellij.plugins.m68k.lexer.LexerUtil.*;
%%
@ -21,114 +22,199 @@ import static de.platon42.intellij.plugins.m68k.psi.M68kTypes.*;
%function advance
%type IElementType
%unicode
%ignorecase
EOL=\R
WHITE_SPACE=\s+
EOL=\R
WHITE_SPACE=\p{Blank}+
EQU=([eE][qQ][uU])
EVEN_TAG=((\p{Blank}+)?[eE][vV][eE][nN])
CNOP_TAG=((\p{Blank}+)?[cC][nN][oO][pP])
SECTION_TAG=((\p{Blank}+)?[sS][eE][cC][tT][iI][oO][nN])
INCLUDE_TAG=((\p{Blank}+)?[iI][nN][cC][lL][uU][dD][eE])
INCBIN_TAG=((\p{Blank}+)?[iI][nN][cC][bB][iI][nN])
IF_TAG=((\p{Blank}+)?[iI][fF][:letter:]*)
ELSE_TAG=((\p{Blank}+)?[eE][lL][sS][eE])
ENDC_TAG=((\p{Blank}+)?[eE][nN][dD][cC])
MACRO_TAG=((\p{Blank}+)?[mM][aA][cC][rR][oO])
MACRO_END_TAG=((\p{Blank}+)?[eE][nN][dD][mM])
REPT_TAG=((\p{Blank}+)?[rR][eE][pP][tT])
REPT_END_TAG=((\p{Blank}+)?[eE][nN][dD][rR])
FAIL_TAG=((\p{Blank}+)?[fF][aA][iI][lL])
END_TAG=((\p{Blank}+)?[eE][nN][dD]).*
AREG=(([aA][0-7])|sp|SP)
DREG=([dD][0-7])
PC=([pP][cC])
REG_CCR=([cC][cC][rR])
REG_SR=([sS][rR])
REG_USP=([uU][sS][pP])
REG_VBR=([vV][bB][rR])
SYMBOL=(([:letter:]|_)(([:letter:]|[:digit:])|_)*)
OPSIZE_BS=(\.([bB]|[sS]))
OPSIZE_WL=(\.([wW]|[lL]))
IF_TAG=(if[:letter:]*)
AREG=((a[0-7])|sp)
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:])|_)*\$:?)
LOCAL_LABEL_WC=(\.([:letter:]|_)(([:letter:]|[:digit:])|_)*:)|(([:letter:]|_)(([:letter:]|[:digit:])|_)*\$:)
GLOBAL_LABEL=(([:letter:]|_)(([:letter:]|[:digit:])|_)*:?:?)
GLOBAL_LABEL_WC=(([:letter:]|_)(([:letter:]|[:digit:])|_)*::?)
MNEMONIC=(([:letter:])+)
SYMBOL=(([:letter:]|_|.)(([:letter:]|[:digit:])|_|\$)*)
OPSIZE_BS=(\.[bs])
OPSIZE_WL=(\.[wl])
BINARY=(%[01]+)
HEXADECIMAL=(\$[0-9a-fA-F]+)
HEXADECIMAL=(\$[0-9a-f]+)
OCTAL=(@[0-7]+)
DECIMAL=([0-9]+)
STRINGLIT=(`([^`\\]|\\.)*`|'([^'\\]|\\.)*'|\"([^\"\\]|\\.)*\")|<([^`\\]|\\.)*>
COMMENT=(\p{Blank}*?[;*].*+)
COMMENT=([;].*+)
HASH_COMMENT=([#;*].*+)
%state NOSOL,INSTRPART,ASMINSTR,ASMOPS,ASSIGNMENT
%%
<YYINITIAL> {
{WHITE_SPACE} { return WHITE_SPACE; }
{WHITE_SPACE} { yybegin(NOSOL); return WHITE_SPACE; }
{EOL} { return WHITE_SPACE; }
{ASSIGNMENT} { yybegin(ASSIGNMENT); yypushback(pushbackAssignment(yytext())); return SYMBOLDEF; }
{LOCAL_LABEL} { yybegin(INSTRPART); return LOCAL_LABEL_DEF; }
{GLOBAL_LABEL} { yybegin(INSTRPART); return GLOBAL_LABEL_DEF; }
":" { return COLON; }
";" { return SEMICOLON; }
"[" { return SQUARE_L; }
"]" { return SQUARE_R; }
"(" { return ROUND_L; }
")" { return ROUND_R; }
"," { return SEPARATOR; }
"." { return DOT; }
"#" { return HASH; }
"$" { return DOLLAR; }
"=" { return OP_ASSIGN; }
"!" { return OP_UNARY_NOT; }
"~" { return OP_UNARY_COMPL; }
"+" { return OP_PLUS; }
"-" { return OP_MINUS; }
"*" { return OP_AR_MUL; }
"/" { return OP_AR_DIV; }
"%" { return OP_AR_MOD; }
"<<" { return OP_AR_SHIFT_L; }
">>" { return OP_AR_SHIFT_R; }
"&" { return OP_BITWISE_AND; }
"|" { return OP_BITWISE_OR; }
"^" { return OP_BITWISE_XOR; }
"&&" { return OP_LOGICAL_AND; }
"||" { return OP_LOGICAL_OR; }
"==" { return OP_CMP_EQ; }
"<" { return OP_CMP_LT; }
">" { return OP_CMP_GT; }
">=" { return OP_CMP_GT_EQ; }
"<=" { return OP_CMP_LT_EQ; }
"!=" { return OP_CMP_NOT_EQ; }
"<>" { return OP_CMP_NOT_EQ2; }
{HASH_COMMENT} { return COMMENT; }
}
{EOL} { return EOL; }
{WHITE_SPACE} { return WHITE_SPACE; }
{EQU} { return EQU; }
{EVEN_TAG} { return EVEN_TAG; }
{CNOP_TAG} { return CNOP_TAG; }
{SECTION_TAG} { return SECTION_TAG; }
{INCLUDE_TAG} { return INCLUDE_TAG; }
{INCBIN_TAG} { return INCBIN_TAG; }
{IF_TAG} { return IF_TAG; }
{ELSE_TAG} { return ELSE_TAG; }
{ENDC_TAG} { return ENDC_TAG; }
{MACRO_TAG} { return MACRO_TAG; }
{MACRO_END_TAG} { return MACRO_END_TAG; }
{REPT_TAG} { return REPT_TAG; }
{REPT_END_TAG} { return REPT_END_TAG; }
{FAIL_TAG} { return FAIL_TAG; }
{END_TAG} { return END_TAG; }
{AREG} { return AREG; }
{DREG} { return DREG; }
{PC} { return PC; }
{REG_CCR} { return REG_CCR; }
{REG_SR} { return REG_SR; }
{REG_USP} { return REG_USP; }
{REG_VBR} { return REG_VBR; }
{SYMBOL} { return SYMBOL; }
{OPSIZE_BS} { return OPSIZE_BS; }
{OPSIZE_WL} { return OPSIZE_WL; }
{BINARY} { return BINARY; }
{HEXADECIMAL} { return HEXADECIMAL; }
{OCTAL} { return OCTAL; }
{DECIMAL} { return DECIMAL; }
{STRINGLIT} { return STRINGLIT; }
{COMMENT} { return COMMENT; }
<NOSOL> {
{WHITE_SPACE} { return WHITE_SPACE; }
{EOL} { yybegin(YYINITIAL); return WHITE_SPACE; }
{LOCAL_LABEL_WC} { yybegin(INSTRPART); return LOCAL_LABEL_DEF; }
{GLOBAL_LABEL_WC} { yybegin(INSTRPART); return GLOBAL_LABEL_DEF; }
{MNEMONIC} { yybegin(ASMINSTR); return isAsmMnemonic(yytext()) ? MNEMONIC : SYMBOL; }
{SYMBOL} { return SYMBOL; }
{HASH_COMMENT} { yybegin(YYINITIAL); return COMMENT; }
}
<INSTRPART> {
{WHITE_SPACE} { return WHITE_SPACE; }
{EOL} { yybegin(YYINITIAL); return EOL; }
"even" { return EVEN_TAG; }
"cnop" { return CNOP_TAG; }
"section" { return SECTION_TAG; }
"include" { return INCLUDE_TAG; }
"incbin" { return INCBIN_TAG; }
"else" { return ELSE_TAG; }
"endc" { return ENDC_TAG; }
"macro" { return MACRO_TAG; }
"endm" { return MACRO_END_TAG; }
"rept" { return REPT_TAG; }
"endr" { return REPT_END_TAG; }
"fail" { return FAIL_TAG; }
"end" { return END_TAG; }
{IF_TAG} { return IF_TAG; }
{MNEMONIC} { return isAsmMnemonic(yytext()) ? MNEMONIC : SYMBOL; }
{SYMBOL} { return SYMBOL; }
{COMMENT} { yybegin(YYINITIAL); return COMMENT; }
}
<ASMINSTR> {
{WHITE_SPACE} { yybegin(ASMOPS); return WHITE_SPACE; }
{EOL} { yybegin(YYINITIAL); return EOL; }
{OPSIZE_BS} { return OPSIZE_BS; }
{OPSIZE_WL} { return OPSIZE_WL; }
{COMMENT} { yybegin(YYINITIAL); return COMMENT; }
}
<ASSIGNMENT> {
{WHITE_SPACE} { return WHITE_SPACE; } // FIXME space optionally introduces comment
{EOL} { yybegin(YYINITIAL); return EOL; }
{BINARY} { return BINARY; }
{HEXADECIMAL} { return HEXADECIMAL; }
{OCTAL} { return OCTAL; }
{DECIMAL} { return DECIMAL; }
{STRINGLIT} { return STRINGLIT; }
"equ" { return EQU; }
"set" { return EQU; }
"<<" { return OP_AR_SHIFT_L; }
">>" { return OP_AR_SHIFT_R; }
"&&" { return OP_LOGICAL_AND; }
"||" { return OP_LOGICAL_OR; }
"==" { return OP_CMP_EQ; }
"<>" { return OP_CMP_NOT_EQ; }
">=" { return OP_CMP_GT_EQ; }
"<=" { return OP_CMP_LT_EQ; }
"!=" { return OP_CMP_NOT_EQ; }
"<" { return OP_CMP_LT; }
">" { return OP_CMP_GT; }
"&" { return OP_BITWISE_AND; }
"|" { return OP_BITWISE_OR; }
"^" { return OP_BITWISE_XOR; }
":" { return COLON; }
";" { return SEMICOLON; }
"[" { return SQUARE_L; }
"]" { return SQUARE_R; }
"(" { return ROUND_L; }
")" { return ROUND_R; }
"." { return DOT; }
"$" { return DOLLAR; }
"=" { return OP_ASSIGN; }
"!" { return OP_UNARY_NOT; }
"~" { return OP_UNARY_COMPL; }
"+" { return OP_PLUS; }
"-" { return OP_MINUS; }
"*" { return OP_AR_MUL; }
"/" { return OP_AR_DIV; }
"%" { return OP_AR_MOD; }
{SYMBOL} { return SYMBOL; }
{COMMENT} { return COMMENT; }
}
<ASMOPS> {
{WHITE_SPACE} { return WHITE_SPACE; } // FIXME space optionally introduces comment
{EOL} { yybegin(YYINITIAL); return EOL; }
{BINARY} { return BINARY; }
{HEXADECIMAL} { return HEXADECIMAL; }
{OCTAL} { return OCTAL; }
{DECIMAL} { return DECIMAL; }
{STRINGLIT} { return STRINGLIT; }
{OPSIZE_BS} { return OPSIZE_BS; }
{OPSIZE_WL} { return OPSIZE_WL; }
"<<" { return OP_AR_SHIFT_L; }
">>" { return OP_AR_SHIFT_R; }
"&&" { return OP_LOGICAL_AND; }
"||" { return OP_LOGICAL_OR; }
"==" { return OP_CMP_EQ; }
"<>" { return OP_CMP_NOT_EQ; }
">=" { return OP_CMP_GT_EQ; }
"<=" { return OP_CMP_LT_EQ; }
"!=" { return OP_CMP_NOT_EQ; }
"<" { return OP_CMP_LT; }
">" { return OP_CMP_GT; }
"&" { return OP_BITWISE_AND; }
"|" { return OP_BITWISE_OR; }
"^" { return OP_BITWISE_XOR; }
":" { return COLON; }
";" { return SEMICOLON; }
"[" { return SQUARE_L; }
"]" { return SQUARE_R; }
"(" { return ROUND_L; }
")" { return ROUND_R; }
"," { return SEPARATOR; }
"." { return DOT; }
"#" { return HASH; }
"$" { return DOLLAR; }
"=" { return OP_ASSIGN; }
"!" { return OP_UNARY_NOT; }
"~" { return OP_UNARY_COMPL; }
"+" { return OP_PLUS; }
"-" { return OP_MINUS; }
"*" { return OP_AR_MUL; }
"/" { return OP_AR_DIV; }
"%" { return OP_AR_MOD; }
{AREG} { return AREG; }
{DREG} { return DREG; }
"pc" { return PC; }
"ccr" { return REG_CCR; }
"sr" { return REG_SR; }
"usp" { return REG_USP; }
"vbr" { return REG_VBR; }
{SYMBOL} { return SYMBOL; }
{COMMENT} { return COMMENT; }
}

View File

@ -30,43 +30,44 @@
EOL = 'regexp:\R'
WHITE_SPACE = 'regexp:\p{Blank}+'
EQU = 'regexp:([eE][qQ][uU])'
EQU = 'equ'
EVEN_TAG = 'regexp:((\p{Blank}+)?[eE][vV][eE][nN])'
CNOP_TAG = 'regexp:((\p{Blank}+)?[cC][nN][oO][pP])'
SECTION_TAG = 'regexp:((\p{Blank}+)?[sS][eE][cC][tT][iI][oO][nN])'
EVEN_TAG = 'even'
CNOP_TAG = 'cnop'
SECTION_TAG = 'section'
INCLUDE_TAG = 'regexp:((\p{Blank}+)?[iI][nN][cC][lL][uU][dD][eE])'
INCBIN_TAG = 'regexp:((\p{Blank}+)?[iI][nN][cC][bB][iI][nN])'
INCLUDE_TAG = 'include'
INCBIN_TAG = 'incbin'
IF_TAG = 'regexp:((\p{Blank}+)?[iI][fF]\p{Alpha}*)'
ELSE_TAG = 'regexp:((\p{Blank}+)?[eE][lL][sS][eE])'
ENDC_TAG = 'regexp:((\p{Blank}+)?[eE][nN][dD][cC])'
MACRO_TAG = 'regexp:((\p{Blank}+)?[mM][aA][cC][rR][oO])'
MACRO_END_TAG = 'regexp:((\p{Blank}+)?[eE][nN][dD][mM])'
REPT_TAG = 'regexp:((\p{Blank}+)?[rR][eE][pP][tT])'
REPT_END_TAG = 'regexp:((\p{Blank}+)?[eE][nN][dD][rR])'
FAIL_TAG = 'regexp:((\p{Blank}+)?[fF][aA][iI][lL])'
END_TAG = 'regexp:((\p{Blank}+)?[eE][nN][dD]).*'
IF_TAG = 'regexp:(if\p{Alpha}*)'
ELSE_TAG = 'else'
ENDC_TAG = 'endc'
MACRO_TAG = 'macro'
MACRO_END_TAG = 'endm'
REPT_TAG = 'rept'
REPT_END_TAG = 'endr'
FAIL_TAG = 'fail'
END_TAG = 'end'
AREG = 'regexp:(([aA][0-7])|sp|SP)'
DREG = 'regexp:([dD][0-7])'
PC = 'regexp:([pP][cC])'
REG_CCR = 'regexp:([cC][cC][rR])'
REG_SR = 'regexp:([sS][rR])'
REG_USP = 'regexp:([uU][sS][pP])'
REG_VBR = 'regexp:([vV][bB][rR])'
AREG = 'regexp:((a[0-7])|sp)'
DREG = 'regexp:(d[0-7])'
PC = 'pc'
REG_CCR = 'ccr'
REG_SR = 'sr'
REG_USP = 'usp'
REG_VBR = 'vbr'
// LOCAL_LABEL = 'regexp:(!(\p{Blank}+)\.(\p{Alpha}|_)(\p{Alnum}|_)*:?)|(!(\p{Blank}+)(\p{Alpha}|_)(\p{Alnum}|_)*\$:?)|((\p{Blank}*)?\.(\p{Alpha}|_)(\p{Alnum}|_)*:)|((\p{Blank}*)?(\p{Alpha}|_)(\p{Alnum}|_)*\$:)|(\.(\p{Alpha}|_)(\p{Alnum}|_)*:)|((\p{Alpha}|_)(\p{Alnum}|_)*\$:)'
// GLOBAL_LABEL = 'regexp:(!(\p{Blank}+)(\p{Alpha}|_)(\p{Alnum}|_)*:?:?)|((\p{Blank}*)?(\p{Alpha}|_)(\p{Alnum}|_)*::?)'
// ASSIGNMENT = 'regexp:((\p{Alpha}|_)(\p{Alnum}|_)*)((\p{Blank}+equ\p{Blank})|=)'
// LOCAL_LABEL_OC = 'regexp:(!(\p{Blank}+)\.(\p{Alpha}|_)(\p{Alnum}|_)*:?)|(!(\p{Blank}+)(\p{Alpha}|_)(\p{Alnum}|_)*\$:?)|((\p{Blank}*)?\.(\p{Alpha}|_)(\p{Alnum}|_)*:)|((\p{Blank}*)?(\p{Alpha}|_)(\p{Alnum}|_)*\$:)|(\.(\p{Alpha}|_)(\p{Alnum}|_)*:)|((\p{Alpha}|_)(\p{Alnum}|_)*\$:)'
// GLOBAL_LABEL_OC = 'regexp:(!(\p{Blank}+)(\p{Alpha}|_)(\p{Alnum}|_)*:?:?)|((\p{Blank}*)?(\p{Alpha}|_)(\p{Alnum}|_)*::?)'
// MNEMONIC = 'regexp:((\p{Alpha})+)'
MNEMONIC = 'regexp:((\p{Alpha})+)'
SYMBOL = 'regexp:((\p{Alpha}|_)(\p{Alnum}|_)*)'
OPSIZE_BS = 'regexp:(\.([bB]|[sS]))'
OPSIZE_WL = 'regexp:(\.([wW]|[lL]))'
OPSIZE_BS = 'regexp:(\.[bs])'
OPSIZE_WL = 'regexp:(\.[wl])'
BINARY = 'regexp:(%[01]+)'
HEXADECIMAL = 'regexp:(\$[0-9a-fA-F]+)'
HEXADECIMAL = 'regexp:(\$[0-9a-f]+)'
OCTAL = 'regexp:(@[0-7]+)'
DECIMAL = 'regexp:([0-9]+)'
@ -107,7 +108,7 @@
OP_CMP_GT_EQ = '>='
OP_CMP_LT_EQ = '<='
OP_CMP_NOT_EQ = '!='
OP_CMP_NOT_EQ2 = '<>'
// OP_CMP_NOT_EQ2 = '<>'
COMMENT = 'regexp:(\p{Blank}*?[;*].*+)'//|(!\s#+.*+)'
// EOL_COMMENT = 'regexp:((\p{Blank}+;.*?)|(\p{Blank}+\.*+))'
@ -116,41 +117,32 @@
M68kFile ::= line*
private BlankLine ::= WHITE_SPACE?
private line ::= !<<eof>> statement EOL
statement ::= (Assignment
| PreprocessorDirective
| LabelInsts
| BlankLine)
| LabelInsts)
{pin=1 recoverWhile=statement_recover};
private statement_recover ::= !(EOL)
Assignment ::= SYMBOL ((WHITE_SPACE? OP_ASSIGN WHITE_SPACE?)|(WHITE_SPACE EQU WHITE_SPACE)) expr
Assignment ::= SYMBOLDEF (OP_ASSIGN|EQU) expr
private LabelInsts ::= LabelOnly|LabelWithInstruction|InstructionOnly
private LabelOnly ::= Label
private LabelWithInstruction ::= Label WHITE_SPACE Instruction
private InstructionOnly ::= WHITE_SPACE Instruction
private LabelWithInstruction ::= Label Instruction
private InstructionOnly ::= Instruction
LocalLabel ::= (!WHITE_SPACE ((DOT SYMBOL)|(SYMBOL DOLLAR)) COLON?)|(WHITE_SPACE? ((DOT SYMBOL)|(SYMBOL DOLLAR)) COLON)
GlobalLabel ::= (!WHITE_SPACE SYMBOL (COLON? COLON?)?)|(WHITE_SPACE? SYMBOL COLON COLON?)
//private Label ::= LocalLabel | GlobalLabel
//private LabelInsts ::= Label|(Label? WHITE_SPACE Instruction)
//
//LocalLabel ::= LOCAL_LABEL {extends=Label}
//GlobalLabel ::= GLOBAL_LABEL {extends=Label}
LocalLabel ::= LOCAL_LABEL_DEF {extends=Label}
GlobalLabel ::= GLOBAL_LABEL_DEF {extends=Label}
Label ::= LocalLabel | GlobalLabel
OperandSize ::= (OPSIZE_BS|OPSIZE_WL)
AddressSize ::= OPSIZE_WL
DataWidth ::= OPSIZE_WL
AsmOp ::= SYMBOL OperandSize?
AsmOp ::= MNEMONIC OperandSize?
PreprocessorDirective ::= SYMBOL?
(END_TAG
@ -167,12 +159,12 @@ PreprocessorDirective ::= SYMBOL?
| REPT_TAG
| REPT_END_TAG
| FAIL_TAG)
(WHITE_SPACE PreprocessorOperands)?
PreprocessorOperands?
MacroCall ::= SYMBOL PreprocessorOperands?
AsmInstruction ::= AsmOp (WHITE_SPACE AsmOperands)?
//Instruction ::= AsmInstruction | MacroCall
external Instruction ::= parseMacroCallOrAsmInstruction
AsmInstruction ::= AsmOp AsmOperands?
private Instruction ::= AsmInstruction | MacroCall
//external Instruction ::= parseMacroCallOrAsmInstruction
AsmOperands ::= FirstAsmOperand (SEPARATOR NextAsmOperand)*
@ -207,11 +199,12 @@ AddressingMode ::= AbsoluteAddressAddressingMode
| ProgramCounterIndirectWithIndexNewAddressingMode
| AddressRegisterIndirectPreDecAddressingMode
| AddressRegisterIndirectPostIncAddressingMode
| RegisterListAddressingMode
| ImmediateData
SpecialRegisterDirectAddressingMode ::= SpecialRegister
DataRegisterDirectAddressingMode ::= DataRegister
AddressRegisterDirectAddressingMode ::= AddressRegister
DataRegisterDirectAddressingMode ::= DataRegister !(OP_MINUS|OP_AR_DIV)
AddressRegisterDirectAddressingMode ::= AddressRegister !(OP_MINUS|OP_AR_DIV)
AddressRegisterIndirectAddressingMode ::= ROUND_L AddressRegister ROUND_R !OP_PLUS
AddressRegisterIndirectPostIncAddressingMode ::= ROUND_L AddressRegister ROUND_R OP_PLUS
AddressRegisterIndirectPreDecAddressingMode ::= OP_MINUS ROUND_L AddressRegister ROUND_R
@ -224,6 +217,8 @@ ProgramCounterIndirectWithDisplacementNewAddressingMode ::= ROUND_L expr SEPARAT
ProgramCounterIndirectWithIndexOldAddressingMode ::= expr ROUND_L PC SEPARATOR DataOrAddressRegister DataWidth? ROUND_R
ProgramCounterIndirectWithIndexNewAddressingMode ::= ROUND_L expr SEPARATOR PC SEPARATOR DataOrAddressRegister DataWidth? ROUND_R
AbsoluteAddressAddressingMode ::= expr AddressSize? !ROUND_L
private RegisterRange ::= (DataOrAddressRegister OP_MINUS DataOrAddressRegister)
RegisterListAddressingMode ::= (DataOrAddressRegister|RegisterRange) (OP_AR_DIV (DataOrAddressRegister|RegisterRange))*
ImmediateData ::= HASH expr {extends=AddressingMode}
expr ::= binary_logical_or_expr
@ -268,7 +263,8 @@ binary_cmp_le_expr ::= expr OP_CMP_LT_EQ expr
binary_cmp_gt_expr ::= expr OP_CMP_GT expr
binary_cmp_ge_expr ::= expr OP_CMP_GT_EQ expr
binary_cmp_eq_expr ::= expr OP_CMP_EQ expr
binary_cmp_ne_expr ::= expr (OP_CMP_NOT_EQ|OP_CMP_NOT_EQ2) expr
binary_cmp_ne_expr ::= expr OP_CMP_NOT_EQ expr
//binary_cmp_ne_expr ::= expr (OP_CMP_NOT_EQ|OP_CMP_NOT_EQ2) expr
binary_logical_and_expr ::= expr OP_LOGICAL_AND expr
binary_logical_or_expr ::= expr OP_LOGICAL_OR expr

View File

@ -19,7 +19,6 @@ import org.jetbrains.annotations.NotNull;
public class M68kParserDefinition implements ParserDefinition {
public static final TokenSet STRING_LITERALS = TokenSet.create(M68kTypes.STRINGLIT);
public static final TokenSet COMMENTS = TokenSet.create(M68kTypes.COMMENT);
public static final TokenSet WHITE_SPACE = TokenSet.create(M68kTypes.WHITE_SPACE);
public M68kParserDefinition() {
}
@ -39,11 +38,6 @@ public class M68kParserDefinition implements ParserDefinition {
return M68kFileElementType.INSTANCE;
}
// @Override
// public @NotNull TokenSet getWhitespaceTokens() {
// return WHITE_SPACE;
// }
@Override
public @NotNull TokenSet getCommentTokens() {
return COMMENTS;

View File

@ -14,7 +14,7 @@
<depends>com.intellij.modules.lang</depends>
<extensions defaultExtensionNs="com.intellij">
<fileType name="M68k" implementationClass="de.platon42.intellij.plugins.m68k.M68kFileType"
<fileType name="M68k Assembler" implementationClass="de.platon42.intellij.plugins.m68k.M68kFileType"
fieldName="INSTANCE" language="M68k" extensions="asm;ASM;s;S;i"/>
<lang.parserDefinition language="M68k"
implementationClass="de.platon42.intellij.plugins.m68k.parser.M68kParserDefinition"/>