Compare commits

...

26 Commits
v0.7 ... main

Author SHA1 Message Date
aed9ed686d Fixed links and version number. 2024-02-20 22:54:31 +01:00
e3efc545a8 Flushing current state for a release. 2024-02-20 22:41:33 +01:00
df2a220473 WiP formatter. 2022-12-23 20:24:50 +01:00
130f6a106d Fixed version for plugin verifier. 2022-10-29 13:28:09 +02:00
def6fe306f Added assembler directives to code completion. 2022-10-29 13:10:55 +02:00
cd0bcd22ff Added folding support for functions and macro definitions. 2022-10-28 19:49:16 +02:00
f87bc7fea9 Added simple custom navigation bar. 2022-10-27 13:31:34 +02:00
64b7042208 addq/subq for address register stated it would affect the condition codes, which it in fact doesn't. 2022-10-09 17:20:41 +02:00
b785b716bb Added semantic highlighting. 2022-08-16 21:41:46 +02:00
87cca67049 Updated dependencies. Tests work again. Cosmetics, fixed warnings. 2022-08-16 10:54:57 +02:00
5e2099f019 Fixed 'Unknown op size' exception when uppercase sizes were used. 2022-04-26 10:43:07 +02:00
ae92da7878 Maintenance. Updated all dependencies to the latest versions.
Fixed condition code for asr/lsr/lsl, which is has a different behaviour for V flag than asl.
2022-04-07 10:30:12 +02:00
85b2596c64 Added some more settings for maximum parsed lines inside a macro and maximum displayed lines of code for documentation.
RegisterFlow line counting fixed.
2021-10-15 13:05:47 +02:00
e0bd6981e3 Full support for MC68010 ISA ('movec', 'moves' and new special registers 'SFC' and 'DFC'). 2021-10-11 11:32:13 +02:00
0ae17046d6 Added Language settings page with one option so far (-spaces option). Fixed lexer without -spaces option and directives. 2021-10-09 16:56:06 +02:00
031d5ff4ab Missing files and fix for optional values in Memory Indirect mode. 2021-10-08 18:04:15 +02:00
653f8dc9fc Extended ISA for 68020+ addressing modes (without adding 68020+ instructions). 2021-10-08 17:24:59 +02:00
a92630e5c7 Added Address Register Indirect with Base Displacement addressing mode. 2021-10-08 15:09:41 +02:00
3f1ef0e55a Refactored BNF for base and outer displacement to avoid ambiguity for these expressions. 2021-10-08 11:22:53 +02:00
722d4437ec Added missing support for size qualifiers for base and outer displacement. 2021-10-08 11:07:16 +02:00
f1110ac3c9 Added 68020 Memory Indirect and Program Counter Memory Indirect addressing modes. 2021-10-08 08:38:04 +02:00
7462c5b02d Added support for SCALE in index addressing modes. 2021-10-08 08:37:29 +02:00
9b93ea05fc Minor renaming & tweaks. 2021-10-07 17:11:06 +02:00
680b811e22 Macro definition / invocation documentation provider that even tries to expand macros.
Moved some util classes around.
2021-10-03 20:26:33 +02:00
cbffc3d841 Label documentation now also works for local labels and includes end-of-line comment for label, too.
Symbol definition documentation now also includes comments in the same way as the label documentation does.
Refactored some code.
2021-10-03 18:55:42 +02:00
435b30efc3 Bump to next version, updated docs due to Yann's first public release of his plugin. 2021-10-02 20:01:51 +02:00
144 changed files with 5985 additions and 991 deletions

View File

@ -1,4 +1,4 @@
# MC68000 Assembly Language Plugin [![Build Status](https://travis-ci.com/chrisly42/mc68000-asm-plugin.svg?branch=main)](https://travis-ci.com/chrisly42/mc68000-asm-plugin) [![Coverage Status](https://coveralls.io/repos/github/chrisly42/mc68000-asm-plugin/badge.svg?branch=main&kill_cache=1)](https://coveralls.io/github/chrisly42/mc68000-asm-plugin?branch=main)
# MC68000 Assembly Language Plugin
_MC68000 Assembly Language Plugin_ is plugin for Jetbrains IDEs (CLion, IntelliJ, etc.).
@ -6,16 +6,17 @@ _MC68000 Assembly Language Plugin_ is plugin for Jetbrains IDEs (CLion, IntelliJ
## Purpose
This plugin delivers support for MC68000 assembly language files ([VAsm](http://sun.hasenbraten.de/vasm/) / DevPac-Style).
This plugin delivers support for MC680xx assembly language files ([VAsm](http://sun.hasenbraten.de/vasm/) / DevPac-Style).
It adds a language parser with syntax highlighting, referencing and refactoring support, and a few more features.
I'm an Amiga retro democoder (among other things), and the lack of a plugin for M68k was the motivation to write one. Also, diving deep into custom language
plugins has a steep learning curve.
When I started the plugin in July 2021, I was not aware of the [M68k plugin efforts by Jetbrains employee Yann Cébron](https://github.com/YannCebron/m68kplugin)
who has been working on the same topic for quite some time. At the time of writing, his plugin however, has not been release yet. Nevertheless, it has a lot of
awesome features and is pretty advanced. Check it out. You can install both plugins at the same time and see what suits you more.
When I started the plugin in July 2021, I was unaware of the [M68k plugin efforts by Jetbrains employee Yann Cébron](https://github.com/YannCebron/m68kplugin)
who has been working on the same topic for quite some time. *On 01-Oct-21, he released
his [first public version](https://plugins.jetbrains.com/plugin/17712-motorola-68000-series-assembler).* Check it out. You can install both plugins at the same
time and see what suits you more.
Big kudos to Yann -- a few features were _inspired_ by his code.
@ -24,8 +25,8 @@ to get started, and I can return to demo coding with its current state.
## Features
- Parser / Lexer for MC68000 (yes, only 68000 right now!) assembly language files in VAsm / DevPac style
- Validates the assembly syntax against the 68000 ISA.
- Parser / Lexer for MC680xx assembly language files in VAsm / DevPac style
- Validates the assembly syntax against the 68000/68010 ISA and 68020+ addressing modes (no complete >68020 support yet!)
- Syntax highlighting and Color Settings Page (you should really modify the color settings to your likings!)
- Mnemonics code completion
- Symbols / labels / macros code completion
@ -89,9 +90,14 @@ weak warnings as missing macro evaluation will not resolve symbols defined via `
Provides the assigned value of a `=`, `set` or `equ` symbol definition when hovering over a symbol.
#### M68kGlobalLabel
#### M68kMacroDefinition
Shows the comments above the label and if the first statement after the label is a directive like `include` or `dc.b`, shows it, too.
When used over a macro invocation, shows the expanded macro contents (only the \1 to \9 and \a to \z are expanded according to the parameters used).
#### M68kLabelDefinition
Shows the comments above the label (local or global) and an end-of-line comment, if available. If the first statement after the label is a directive
like `include` or `dc.b`, it will be shown, too.
#### M68kRegisterFlow
@ -118,11 +124,16 @@ If the current statement has no valid syntax, the instruction details of all mat
- `Find Usages` always shows _"Unclassified"_ though it shouldn't (?)
- `END` detection was breaking parsing, so this is disabled for now until I find a working solution.
- Macro invocations are not yet evaluated, thus no referencing to symbols defined via macros (e.g. `STRUCT`).
- Scoping for global symbols and labels is currently the whole project.
- Scoping for global symbols, labels and macros is currently the whole project.
- No support for register replacement (e.g. registers replaced by `EQUR` or `EQURL` will cause syntax errors)
- While the Lexer supports the -spaces option (where a space introduces a comment), this cannot be configured yet (default is off).
- No support for other processor instructions, FPU or 68020+ address modes.
- No support for other processor instructions and FPU. Yet.
- The pretty esoteric use of `ZPC`, `ZA0-ZA7` or `ZSP` for zero (omitted) address in 68020 addressing modes is unsupported.
- Devpac allowed shuffling of (base) displacement and other parameters inside the new syntax (68020+) brackets. Well, I don't. Only strict `(bd,An,Xn*s)` or
`([bd,An],Xn*s,od)` order allowed.
- Switching the spaces option usually needs the caches to be invalidated. Find Usages word scanner always uses default settings, as it is not configurable per
project :-/
- Unit Test coverage is not as good as it could be (ahem).
- Code flow sometimes outputs "uhm?"
- Missing but planned features:
- Macro evaluation on invocation
- Folding
@ -139,9 +150,10 @@ to highlight the same address and data registers while editing (see new `View ->
## Development notice
This plugin has been written in Kotlin 1.5 using Grammar-Kit.
This plugin has been written in Kotlin 1.9 using Grammar-Kit.
It is probably the only plugin (besides [Cajon](https://github.com/chrisly42/cajon-plugin) from the same author) that uses JUnit 5 Jupiter for unit testing so
It is probably the only plugin (besides [Cajon](https://git.platon42.de/chrisly42/cajon-plugin) from the same author) that uses JUnit 5 Jupiter for unit testing
so
far (or at least the only one I'm aware of ;) ). The IntelliJ framework actually uses the JUnit 3 TestCase for plugin testing, and it took me quite a while to
make it work with JUnit 5. Feel free to use the code (in package ```de.platon42.intellij.jupiter```) for your projects (with attribution).
@ -154,6 +166,36 @@ are appreciated. It really is keeping me motivated to continue development.
## Changelog
### V0.10 (20-Feb-24)
- Decided to release some features that have been sitting on my harddrive for almost two years, but never got released,
because I was unable to get that damn formatter working in a way that was acceptable (the API and the docs are easily one
the worst abominations I've come across).
- Maintenance. Updated all dependencies to the latest versions.
- New: Added semantic highlighting. Currently available for data and address registers and local labels.
- Bugfix: addq/subq for address register stated it would affect the condition codes, which it in fact doesn't.
- New: Added simple custom navigation bar.
- New: Added folding support for functions and macro definitions.
- New: Added assembler directives to code completion (only lower-case except for other directives like IF
and MACRO, which are only suggested for upper-case).
### V0.9 (16-Aug-22)
- Maintenance. Updated all dependencies to the latest versions.
- Bugfix: Fixed condition code for `asr/lsr/lsl`, which is has a different behaviour for V flag than `asl`.
- Bugfix: Fixed 'Unknown op size' exception when uppercase sizes were used.
- Bugfix: Refactoring was broken for newer IDE versions, at least for me, this now works again by unknown magic.
### V0.8 (15-Oct-21)
- New: Support for MC68020+ addressing modes! However, MC68020+ specific instructions have not been added yet.
- New: Full support for MC68010 ISA (`movec`, `moves` and new special registers `SFC` and `DFC`).
- Enhancement: Label documentation now also works for local labels and includes end-of-line comment for label, too.
- Enhancement: Symbol definition documentation now also includes comments in the same way as the label documentation does.
- New: Macro definition / invocation documentation provider that even tries to expand macros.
- New: Added Language settings page with one option so far (-spaces option).
- New: Added some more settings for maximum parsed lines inside a macro and maximum displayed lines of code for documentation.
### V0.7 (26-Sep-21)
- Bugfix: `btst` with pc-relative and weird immediate mode was missing (courtesy of Yann).
@ -222,4 +264,4 @@ are appreciated. It really is keeping me motivated to continue development.
### V0.1 (20-Jul-21)
- Initial public release.
- Initial public release.

View File

@ -1,75 +1,64 @@
plugins {
id 'java'
id 'org.jetbrains.intellij' version '1.1.6'
id 'org.jetbrains.kotlin.jvm' version '1.5.21'
id 'org.jetbrains.intellij' version '1.17.1'
id 'org.jetbrains.kotlin.jvm' version '1.9.22'
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.12.0'
}
group = 'de.platon42'
version = '0.7'
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
version = '0.10'
sourceCompatibility = 17
targetCompatibility = 17
repositories {
mavenCentral()
}
/*
To run tests in IntelliJ use these VM Options for run configuration
To run tests in IntelliJ use these VM Options for run configuration
-ea -Didea.system.path=build/idea-sandbox/system-test -Didea.config.path=build/idea-sandbox/config-test -Didea.plugins.path=build/idea-sandbox/plugins-test
*/
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
testImplementation "org.assertj:assertj-core:3.21.0"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
testImplementation 'org.assertj:assertj-core:3.25.3'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
testImplementation "org.jetbrains.kotlin:kotlin-test"
testImplementation "org.jetbrains.kotlin:kotlin-reflect"
testImplementation 'org.junit.platform:junit-platform-launcher:1.10.2'
// testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += "-Xjvm-default=all"
}
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
intellij {
setVersion("2021.2.2") // LATEST-EAP-SNAPSHOT
setVersion("2022.3") // LATEST-EAP-SNAPSHOT
setUpdateSinceUntilBuild(false)
// setPlugins(["com.intellij.java"])
}
runPluginVerifier {
ideVersions = ["IC-203.6682.168", "IC-212.5284.40", // 2020.3 - 2021.2.2
"CL-203.5981.166", "CL-203.8084.11", // 2020.3
"CL-211.6693.114", "CL-211.7628.27", // 2021.1
"CL-212.4746.93", "CL-212.5284.51"] // 2021.2 - 2021.2.2
ideVersions = ["IC-203.6682.168", "IC-233.14015.106", // 2020.3 - 2023.3
"CL-203.8084.11", "CL-233.14015.92"] // 2020.3 - 2023.3
downloadDir = System.getProperty("user.home") + "/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/verifier"
}
patchPluginXml {
setChangeNotes("""
<p>I still got zero feedback and zero <a href="https://plugins.jetbrains.com/plugin/17268-mc68000-assembly-language-support/reviews">ratings</a> :-(</p>
<h4>V0.7 (26-Sep-21)</h4>
<h4>V0.10 (20-Feb-24)</h4>
<ul>
<li>Bugfix: 'btst' with pc-relative and weird immediate mode was missing (courtesy of Yann).
<li>Bugfix: 'movem' with pc-relative mode was missing for weird immediate mode (courtesy of Yann).
<li>Bugfix: Special registers for address mode matching only worked with lower case register names (courtesy of Yann).
<li>Enhancement: Assembler syntax with implicit immediate 1 for shifts and rotations no longer cause syntax errors (courtesy of Yann).
<li>Enhancement: Documentation for instruction with special register shows specific register expected.
<li>New: Added documentation provider info for global labels. Shows directives and comments above.
<li>Bugfix: Fixed BNF for labels with preprocessor statements.
<li>Disabled: 'END' detection was breaking parsing, causing havoc.
<li>Decided to release some features that have been sitting on my harddrive for almost two years, but never got released,
because I was unable to get that damn formatter working in a way that was acceptable (the API and the docs are easily one
the worst abominations I've come across).
<li>Maintenance. Updated all dependencies to the latest versions.
<li>New: Added semantic highlighting. Currently available for data and address registers and local labels.
<li>Bugfix: addq/subq for address register stated it would affect the condition codes, which it in fact doesn't.
<li>New: Added simple custom navigation bar.
<li>New: Added folding support for functions and macro definitions.
<li>New: Added assembler directives to code completion (only lower-case except for other directives like IF
and MACRO, which are only suggested for upper-case).
</ul>
<p>Full changelog available at <a href="https://github.com/chrisly42/mc68000-asm-plugin#changelog">Github project site</a>.</p>
<p>Full changelog available at <a href="https://git.platon42.de/chrisly42/mc68000-asm-plugin#changelog">Gitea project site</a>.</p>
""")
}
@ -80,10 +69,13 @@ test {
testLogging {
events "passed", "skipped", "failed"
}
runIde {
jvmArgs '--add-exports', 'java.base/jdk.internal.vm=ALL-UNNAMED'
}
}
jacoco {
toolVersion = '0.8.7'
toolVersion = '0.8.8'
}
jacocoTestReport {
@ -95,4 +87,4 @@ jacocoTestReport {
publishPlugin {
setToken(intellijPublishToken)
}
}

View File

@ -1,4 +1,4 @@
kotlin.code.style=official
kotlin.incremental=true
intellijPublishToken=perm:dummy
systemProp.jdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2"
systemProp.jdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2"

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

17
plans.txt Normal file
View File

@ -0,0 +1,17 @@
Formatting:
- dc.w statements: Pressing return will automatically add dc.w in next line (plus tabs)
Showing of used registers in selection
Actions:
- Replace constant by symbol (with suggestion)
- Converting of hex values into decimal values and vice versa
- convert new style to old style
- convert old style to new style
- simplify explicit mnemonics (e.g. movea)
Marker:
- go to source register setter
- go to target register setter
- Can we add "find declaration to go for registers"

View File

@ -40,8 +40,10 @@ public class M68kParser implements PsiParser, LightPsiParser {
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,
ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_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, MEMORY_INDIRECT_ADDRESSING_MODE, MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE, MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE,
PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE, PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE, PROGRAM_COUNTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE, PROGRAM_COUNTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE,
PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE, PROGRAM_COUNTER_MEMORY_INDIRECT_ADDRESSING_MODE, PROGRAM_COUNTER_MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE, PROGRAM_COUNTER_MEMORY_INDIRECT_PRE_INDEXED_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,
@ -210,6 +212,37 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
/* ********************************************************** */
// ROUND_L (internalBaseDisplacementOption1|internalBaseDisplacementOption2|internalBaseDisplacementOption3)? ROUND_R
public static boolean AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode")) return false;
if (!nextTokenIsFast(b, ROUND_L)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE, "<AddressingMode>");
r = consumeTokenFast(b, ROUND_L);
r = r && AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode_1(b, l + 1);
r = r && consumeToken(b, ROUND_R);
exit_section_(b, l, m, r, false, null);
return r;
}
// (internalBaseDisplacementOption1|internalBaseDisplacementOption2|internalBaseDisplacementOption3)?
private static boolean AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode_1")) return false;
AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode_1_0(b, l + 1);
return true;
}
// internalBaseDisplacementOption1|internalBaseDisplacementOption2|internalBaseDisplacementOption3
private static boolean AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode_1_0")) return false;
boolean r;
r = internalBaseDisplacementOption1(b, l + 1);
if (!r) r = internalBaseDisplacementOption2(b, l + 1);
if (!r) r = internalBaseDisplacementOption3(b, l + 1);
return r;
}
/* ********************************************************** */
// ROUND_L (expr SEPARATOR)? AddressRegister SEPARATOR IndexRegister ROUND_R
public static boolean AddressRegisterIndirectWithIndexNewAddressingMode(PsiBuilder b, int l) {
@ -294,6 +327,14 @@ public class M68kParser implements PsiParser, LightPsiParser {
// | ProgramCounterIndirectWithDisplacementOldAddressingMode
// | AddressRegisterIndirectWithIndexOldAddressingMode
// | ProgramCounterIndirectWithIndexOldAddressingMode
// | AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode
// | ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode
// | MemoryIndirectAddressingMode
// | ProgramCounterMemoryIndirectAddressingMode
// | MemoryIndirectPostIndexedAddressingMode
// | ProgramCounterMemoryIndirectPostIndexedAddressingMode
// | MemoryIndirectPreIndexedAddressingMode
// | ProgramCounterMemoryIndirectPreIndexedAddressingMode
// | SpecialRegisterDirectAddressingMode
// | DataRegisterDirectAddressingMode
// | AddressRegisterDirectAddressingMode
@ -315,6 +356,14 @@ public class M68kParser implements PsiParser, LightPsiParser {
if (!r) r = ProgramCounterIndirectWithDisplacementOldAddressingMode(b, l + 1);
if (!r) r = AddressRegisterIndirectWithIndexOldAddressingMode(b, l + 1);
if (!r) r = ProgramCounterIndirectWithIndexOldAddressingMode(b, l + 1);
if (!r) r = AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode(b, l + 1);
if (!r) r = ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode(b, l + 1);
if (!r) r = MemoryIndirectAddressingMode(b, l + 1);
if (!r) r = ProgramCounterMemoryIndirectAddressingMode(b, l + 1);
if (!r) r = MemoryIndirectPostIndexedAddressingMode(b, l + 1);
if (!r) r = ProgramCounterMemoryIndirectPostIndexedAddressingMode(b, l + 1);
if (!r) r = MemoryIndirectPreIndexedAddressingMode(b, l + 1);
if (!r) r = ProgramCounterMemoryIndirectPreIndexedAddressingMode(b, l + 1);
if (!r) r = SpecialRegisterDirectAddressingMode(b, l + 1);
if (!r) r = DataRegisterDirectAddressingMode(b, l + 1);
if (!r) r = AddressRegisterDirectAddressingMode(b, l + 1);
@ -425,6 +474,25 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
/* ********************************************************** */
// expr DataWidth?
public static boolean BaseDisplacement(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "BaseDisplacement")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, BASE_DISPLACEMENT, "<base displacement>");
r = expr(b, l + 1, -1);
r = r && BaseDisplacement_1(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
// DataWidth?
private static boolean BaseDisplacement_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "BaseDisplacement_1")) return false;
DataWidth(b, l + 1);
return true;
}
/* ********************************************************** */
// DataRegister | AddressRegister
static boolean DataOrAddressRegister(PsiBuilder b, int l) {
@ -532,13 +600,14 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// DataOrAddressRegister DataWidth?
// DataOrAddressRegister DataWidth? (OP_AR_MUL IndexScale)?
public static boolean IndexRegister(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "IndexRegister")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, INDEX_REGISTER, "<index register>");
r = DataOrAddressRegister(b, l + 1);
r = r && IndexRegister_1(b, l + 1);
r = r && IndexRegister_2(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
@ -550,23 +619,42 @@ public class M68kParser implements PsiParser, LightPsiParser {
return true;
}
/* ********************************************************** */
// AsmInstruction | MacroCall
static boolean Instruction(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "Instruction")) return false;
if (!nextTokenIs(b, "", MACRO_INVOCATION, MNEMONIC)) return false;
// (OP_AR_MUL IndexScale)?
private static boolean IndexRegister_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "IndexRegister_2")) return false;
IndexRegister_2_0(b, l + 1);
return true;
}
// OP_AR_MUL IndexScale
private static boolean IndexRegister_2_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "IndexRegister_2_0")) return false;
boolean r;
r = AsmInstruction(b, l + 1);
if (!r) r = MacroCall(b, l + 1);
Marker m = enter_section_(b);
r = consumeToken(b, OP_AR_MUL);
r = r && IndexScale(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// Instruction|PreprocessorDirective
static boolean InstructionOnly(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "InstructionOnly")) return false;
// expr
public static boolean IndexScale(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "IndexScale")) return false;
boolean r;
r = Instruction(b, l + 1);
Marker m = enter_section_(b, l, _NONE_, INDEX_SCALE, "<scale value>");
r = expr(b, l + 1, -1);
exit_section_(b, l, m, r, false, null);
return r;
}
/* ********************************************************** */
// AsmInstruction | MacroCall | PreprocessorDirective
static boolean Instruction(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "Instruction")) return false;
boolean r;
r = AsmInstruction(b, l + 1);
if (!r) r = MacroCall(b, l + 1);
if (!r) r = PreprocessorDirective(b, l + 1);
return r;
}
@ -583,13 +671,13 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// LabelWithInstruction | LabelOnly | InstructionOnly
// LabelWithInstruction | LabelOnly | Instruction
static boolean LabelInsts(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LabelInsts")) return false;
boolean r;
r = LabelWithInstruction(b, l + 1);
if (!r) r = LabelOnly(b, l + 1);
if (!r) r = InstructionOnly(b, l + 1);
if (!r) r = Instruction(b, l + 1);
return r;
}
@ -600,27 +688,18 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// Label (Instruction|PreprocessorDirective)
// 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 && LabelWithInstruction_1(b, l + 1);
r = r && Instruction(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// Instruction|PreprocessorDirective
private static boolean LabelWithInstruction_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "LabelWithInstruction_1")) return false;
boolean r;
r = Instruction(b, l + 1);
if (!r) r = PreprocessorDirective(b, l + 1);
return r;
}
/* ********************************************************** */
// LOCAL_LABEL_DEF COLON?
public static boolean LocalLabel(PsiBuilder b, int l) {
@ -764,6 +843,193 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
/* ********************************************************** */
// ROUND_L SQUARE_L (BaseDisplacement SEPARATOR)? AddressRegister SQUARE_R (SEPARATOR OuterDisplacement)? ROUND_R
public static boolean MemoryIndirectAddressingMode(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectAddressingMode")) return false;
if (!nextTokenIsFast(b, ROUND_L)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, MEMORY_INDIRECT_ADDRESSING_MODE, "<AddressingMode>");
r = consumeTokens(b, 0, ROUND_L, SQUARE_L);
r = r && MemoryIndirectAddressingMode_2(b, l + 1);
r = r && AddressRegister(b, l + 1);
r = r && consumeToken(b, SQUARE_R);
r = r && MemoryIndirectAddressingMode_5(b, l + 1);
r = r && consumeToken(b, ROUND_R);
exit_section_(b, l, m, r, false, null);
return r;
}
// (BaseDisplacement SEPARATOR)?
private static boolean MemoryIndirectAddressingMode_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectAddressingMode_2")) return false;
MemoryIndirectAddressingMode_2_0(b, l + 1);
return true;
}
// BaseDisplacement SEPARATOR
private static boolean MemoryIndirectAddressingMode_2_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectAddressingMode_2_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = BaseDisplacement(b, l + 1);
r = r && consumeToken(b, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
// (SEPARATOR OuterDisplacement)?
private static boolean MemoryIndirectAddressingMode_5(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectAddressingMode_5")) return false;
MemoryIndirectAddressingMode_5_0(b, l + 1);
return true;
}
// SEPARATOR OuterDisplacement
private static boolean MemoryIndirectAddressingMode_5_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectAddressingMode_5_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokenFast(b, SEPARATOR);
r = r && OuterDisplacement(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// ROUND_L (SQUARE_L (internalMemoryIndirectPostIndexedOption1|internalMemoryIndirectPostIndexedOption2) SQUARE_R SEPARATOR)? IndexRegister (SEPARATOR OuterDisplacement)? ROUND_R
public static boolean MemoryIndirectPostIndexedAddressingMode(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPostIndexedAddressingMode")) return false;
if (!nextTokenIsFast(b, ROUND_L)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE, "<AddressingMode>");
r = consumeTokenFast(b, ROUND_L);
r = r && MemoryIndirectPostIndexedAddressingMode_1(b, l + 1);
r = r && IndexRegister(b, l + 1);
r = r && MemoryIndirectPostIndexedAddressingMode_3(b, l + 1);
r = r && consumeToken(b, ROUND_R);
exit_section_(b, l, m, r, false, null);
return r;
}
// (SQUARE_L (internalMemoryIndirectPostIndexedOption1|internalMemoryIndirectPostIndexedOption2) SQUARE_R SEPARATOR)?
private static boolean MemoryIndirectPostIndexedAddressingMode_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPostIndexedAddressingMode_1")) return false;
MemoryIndirectPostIndexedAddressingMode_1_0(b, l + 1);
return true;
}
// SQUARE_L (internalMemoryIndirectPostIndexedOption1|internalMemoryIndirectPostIndexedOption2) SQUARE_R SEPARATOR
private static boolean MemoryIndirectPostIndexedAddressingMode_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPostIndexedAddressingMode_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokenFast(b, SQUARE_L);
r = r && MemoryIndirectPostIndexedAddressingMode_1_0_1(b, l + 1);
r = r && consumeTokens(b, 0, SQUARE_R, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
// internalMemoryIndirectPostIndexedOption1|internalMemoryIndirectPostIndexedOption2
private static boolean MemoryIndirectPostIndexedAddressingMode_1_0_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPostIndexedAddressingMode_1_0_1")) return false;
boolean r;
r = internalMemoryIndirectPostIndexedOption1(b, l + 1);
if (!r) r = internalMemoryIndirectPostIndexedOption2(b, l + 1);
return r;
}
// (SEPARATOR OuterDisplacement)?
private static boolean MemoryIndirectPostIndexedAddressingMode_3(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPostIndexedAddressingMode_3")) return false;
MemoryIndirectPostIndexedAddressingMode_3_0(b, l + 1);
return true;
}
// SEPARATOR OuterDisplacement
private static boolean MemoryIndirectPostIndexedAddressingMode_3_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPostIndexedAddressingMode_3_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokenFast(b, SEPARATOR);
r = r && OuterDisplacement(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// ROUND_L SQUARE_L (BaseDisplacement SEPARATOR)? (AddressRegister SEPARATOR)? IndexRegister SQUARE_R (SEPARATOR OuterDisplacement)? ROUND_R
public static boolean MemoryIndirectPreIndexedAddressingMode(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPreIndexedAddressingMode")) return false;
if (!nextTokenIsFast(b, ROUND_L)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE, "<AddressingMode>");
r = consumeTokens(b, 0, ROUND_L, SQUARE_L);
r = r && MemoryIndirectPreIndexedAddressingMode_2(b, l + 1);
r = r && MemoryIndirectPreIndexedAddressingMode_3(b, l + 1);
r = r && IndexRegister(b, l + 1);
r = r && consumeToken(b, SQUARE_R);
r = r && MemoryIndirectPreIndexedAddressingMode_6(b, l + 1);
r = r && consumeToken(b, ROUND_R);
exit_section_(b, l, m, r, false, null);
return r;
}
// (BaseDisplacement SEPARATOR)?
private static boolean MemoryIndirectPreIndexedAddressingMode_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPreIndexedAddressingMode_2")) return false;
MemoryIndirectPreIndexedAddressingMode_2_0(b, l + 1);
return true;
}
// BaseDisplacement SEPARATOR
private static boolean MemoryIndirectPreIndexedAddressingMode_2_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPreIndexedAddressingMode_2_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = BaseDisplacement(b, l + 1);
r = r && consumeToken(b, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
// (AddressRegister SEPARATOR)?
private static boolean MemoryIndirectPreIndexedAddressingMode_3(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPreIndexedAddressingMode_3")) return false;
MemoryIndirectPreIndexedAddressingMode_3_0(b, l + 1);
return true;
}
// AddressRegister SEPARATOR
private static boolean MemoryIndirectPreIndexedAddressingMode_3_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPreIndexedAddressingMode_3_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = AddressRegister(b, l + 1);
r = r && consumeToken(b, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
// (SEPARATOR OuterDisplacement)?
private static boolean MemoryIndirectPreIndexedAddressingMode_6(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPreIndexedAddressingMode_6")) return false;
MemoryIndirectPreIndexedAddressingMode_6_0(b, l + 1);
return true;
}
// SEPARATOR OuterDisplacement
private static boolean MemoryIndirectPreIndexedAddressingMode_6_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MemoryIndirectPreIndexedAddressingMode_6_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokenFast(b, SEPARATOR);
r = r && OuterDisplacement(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// OPSIZE_BS|OPSIZE_W|OPSIZE_L
public static boolean OperandSize(PsiBuilder b, int l) {
@ -777,6 +1043,25 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
/* ********************************************************** */
// expr DataWidth?
public static boolean OuterDisplacement(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "OuterDisplacement")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, OUTER_DISPLACEMENT, "<outer displacement>");
r = expr(b, l + 1, -1);
r = r && OuterDisplacement_1(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
// DataWidth?
private static boolean OuterDisplacement_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "OuterDisplacement_1")) return false;
DataWidth(b, l + 1);
return true;
}
/* ********************************************************** */
// (expr|AddressingMode) (SEPARATOR (expr|AddressingMode))*
static boolean PlainOperands(PsiBuilder b, int l) {
@ -949,6 +1234,58 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
/* ********************************************************** */
// ROUND_L (BaseDisplacement SEPARATOR)? PC (SEPARATOR IndexRegister)? ROUND_R
public static boolean ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode")) return false;
if (!nextTokenIsFast(b, ROUND_L)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, PROGRAM_COUNTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE, "<AddressingMode>");
r = consumeTokenFast(b, ROUND_L);
r = r && ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_1(b, l + 1);
r = r && consumeToken(b, PC);
r = r && ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_3(b, l + 1);
r = r && consumeToken(b, ROUND_R);
exit_section_(b, l, m, r, false, null);
return r;
}
// (BaseDisplacement SEPARATOR)?
private static boolean ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_1")) return false;
ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_1_0(b, l + 1);
return true;
}
// BaseDisplacement SEPARATOR
private static boolean ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = BaseDisplacement(b, l + 1);
r = r && consumeToken(b, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
// (SEPARATOR IndexRegister)?
private static boolean ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_3(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_3")) return false;
ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_3_0(b, l + 1);
return true;
}
// SEPARATOR IndexRegister
private static boolean ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_3_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_3_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokenFast(b, SEPARATOR);
r = r && IndexRegister(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// ROUND_L (expr SEPARATOR)? PC SEPARATOR IndexRegister ROUND_R
public static boolean ProgramCounterIndirectWithIndexNewAddressingMode(PsiBuilder b, int l) {
@ -1004,6 +1341,183 @@ public class M68kParser implements PsiParser, LightPsiParser {
return true;
}
/* ********************************************************** */
// ROUND_L SQUARE_L (BaseDisplacement SEPARATOR)? PC SQUARE_R (SEPARATOR OuterDisplacement)? ROUND_R
public static boolean ProgramCounterMemoryIndirectAddressingMode(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectAddressingMode")) return false;
if (!nextTokenIsFast(b, ROUND_L)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, PROGRAM_COUNTER_MEMORY_INDIRECT_ADDRESSING_MODE, "<AddressingMode>");
r = consumeTokens(b, 0, ROUND_L, SQUARE_L);
r = r && ProgramCounterMemoryIndirectAddressingMode_2(b, l + 1);
r = r && consumeTokens(b, 0, PC, SQUARE_R);
r = r && ProgramCounterMemoryIndirectAddressingMode_5(b, l + 1);
r = r && consumeToken(b, ROUND_R);
exit_section_(b, l, m, r, false, null);
return r;
}
// (BaseDisplacement SEPARATOR)?
private static boolean ProgramCounterMemoryIndirectAddressingMode_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectAddressingMode_2")) return false;
ProgramCounterMemoryIndirectAddressingMode_2_0(b, l + 1);
return true;
}
// BaseDisplacement SEPARATOR
private static boolean ProgramCounterMemoryIndirectAddressingMode_2_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectAddressingMode_2_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = BaseDisplacement(b, l + 1);
r = r && consumeToken(b, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
// (SEPARATOR OuterDisplacement)?
private static boolean ProgramCounterMemoryIndirectAddressingMode_5(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectAddressingMode_5")) return false;
ProgramCounterMemoryIndirectAddressingMode_5_0(b, l + 1);
return true;
}
// SEPARATOR OuterDisplacement
private static boolean ProgramCounterMemoryIndirectAddressingMode_5_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectAddressingMode_5_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokenFast(b, SEPARATOR);
r = r && OuterDisplacement(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// ROUND_L (SQUARE_L (BaseDisplacement SEPARATOR)? PC SQUARE_R SEPARATOR)? IndexRegister (SEPARATOR OuterDisplacement)? ROUND_R
public static boolean ProgramCounterMemoryIndirectPostIndexedAddressingMode(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectPostIndexedAddressingMode")) return false;
if (!nextTokenIsFast(b, ROUND_L)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, PROGRAM_COUNTER_MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE, "<AddressingMode>");
r = consumeTokenFast(b, ROUND_L);
r = r && ProgramCounterMemoryIndirectPostIndexedAddressingMode_1(b, l + 1);
r = r && IndexRegister(b, l + 1);
r = r && ProgramCounterMemoryIndirectPostIndexedAddressingMode_3(b, l + 1);
r = r && consumeToken(b, ROUND_R);
exit_section_(b, l, m, r, false, null);
return r;
}
// (SQUARE_L (BaseDisplacement SEPARATOR)? PC SQUARE_R SEPARATOR)?
private static boolean ProgramCounterMemoryIndirectPostIndexedAddressingMode_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectPostIndexedAddressingMode_1")) return false;
ProgramCounterMemoryIndirectPostIndexedAddressingMode_1_0(b, l + 1);
return true;
}
// SQUARE_L (BaseDisplacement SEPARATOR)? PC SQUARE_R SEPARATOR
private static boolean ProgramCounterMemoryIndirectPostIndexedAddressingMode_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectPostIndexedAddressingMode_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokenFast(b, SQUARE_L);
r = r && ProgramCounterMemoryIndirectPostIndexedAddressingMode_1_0_1(b, l + 1);
r = r && consumeTokens(b, 0, PC, SQUARE_R, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
// (BaseDisplacement SEPARATOR)?
private static boolean ProgramCounterMemoryIndirectPostIndexedAddressingMode_1_0_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectPostIndexedAddressingMode_1_0_1")) return false;
ProgramCounterMemoryIndirectPostIndexedAddressingMode_1_0_1_0(b, l + 1);
return true;
}
// BaseDisplacement SEPARATOR
private static boolean ProgramCounterMemoryIndirectPostIndexedAddressingMode_1_0_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectPostIndexedAddressingMode_1_0_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = BaseDisplacement(b, l + 1);
r = r && consumeToken(b, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
// (SEPARATOR OuterDisplacement)?
private static boolean ProgramCounterMemoryIndirectPostIndexedAddressingMode_3(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectPostIndexedAddressingMode_3")) return false;
ProgramCounterMemoryIndirectPostIndexedAddressingMode_3_0(b, l + 1);
return true;
}
// SEPARATOR OuterDisplacement
private static boolean ProgramCounterMemoryIndirectPostIndexedAddressingMode_3_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectPostIndexedAddressingMode_3_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokenFast(b, SEPARATOR);
r = r && OuterDisplacement(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// ROUND_L SQUARE_L (BaseDisplacement SEPARATOR)? PC SEPARATOR IndexRegister SQUARE_R (SEPARATOR OuterDisplacement)? ROUND_R
public static boolean ProgramCounterMemoryIndirectPreIndexedAddressingMode(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectPreIndexedAddressingMode")) return false;
if (!nextTokenIsFast(b, ROUND_L)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, PROGRAM_COUNTER_MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE, "<AddressingMode>");
r = consumeTokens(b, 0, ROUND_L, SQUARE_L);
r = r && ProgramCounterMemoryIndirectPreIndexedAddressingMode_2(b, l + 1);
r = r && consumeTokens(b, 0, PC, SEPARATOR);
r = r && IndexRegister(b, l + 1);
r = r && consumeToken(b, SQUARE_R);
r = r && ProgramCounterMemoryIndirectPreIndexedAddressingMode_7(b, l + 1);
r = r && consumeToken(b, ROUND_R);
exit_section_(b, l, m, r, false, null);
return r;
}
// (BaseDisplacement SEPARATOR)?
private static boolean ProgramCounterMemoryIndirectPreIndexedAddressingMode_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectPreIndexedAddressingMode_2")) return false;
ProgramCounterMemoryIndirectPreIndexedAddressingMode_2_0(b, l + 1);
return true;
}
// BaseDisplacement SEPARATOR
private static boolean ProgramCounterMemoryIndirectPreIndexedAddressingMode_2_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectPreIndexedAddressingMode_2_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = BaseDisplacement(b, l + 1);
r = r && consumeToken(b, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
// (SEPARATOR OuterDisplacement)?
private static boolean ProgramCounterMemoryIndirectPreIndexedAddressingMode_7(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectPreIndexedAddressingMode_7")) return false;
ProgramCounterMemoryIndirectPreIndexedAddressingMode_7_0(b, l + 1);
return true;
}
// SEPARATOR OuterDisplacement
private static boolean ProgramCounterMemoryIndirectPreIndexedAddressingMode_7_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "ProgramCounterMemoryIndirectPreIndexedAddressingMode_7_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeTokenFast(b, SEPARATOR);
r = r && OuterDisplacement(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// CURRENT_PC_SYMBOL
public static boolean ProgramCounterReference(PsiBuilder b, int l) {
@ -1131,7 +1645,7 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// REG_CCR | REG_SR | REG_USP | REG_VBR
// REG_CCR | REG_SR | REG_USP | REG_VBR | REG_SFC | REG_DFC
public static boolean SpecialRegister(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "SpecialRegister")) return false;
boolean r;
@ -1140,6 +1654,8 @@ public class M68kParser implements PsiParser, LightPsiParser {
if (!r) r = consumeToken(b, REG_SR);
if (!r) r = consumeToken(b, REG_USP);
if (!r) r = consumeToken(b, REG_VBR);
if (!r) r = consumeToken(b, REG_SFC);
if (!r) r = consumeToken(b, REG_DFC);
exit_section_(b, l, m, r, false, null);
return r;
}
@ -1179,6 +1695,213 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
/* ********************************************************** */
// (BaseDisplacement SEPARATOR)? (AddressRegister SEPARATOR)? IndexRegister
static boolean internalBaseDisplacementOption1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption1")) return false;
boolean r;
Marker m = enter_section_(b);
r = internalBaseDisplacementOption1_0(b, l + 1);
r = r && internalBaseDisplacementOption1_1(b, l + 1);
r = r && IndexRegister(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// (BaseDisplacement SEPARATOR)?
private static boolean internalBaseDisplacementOption1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption1_0")) return false;
internalBaseDisplacementOption1_0_0(b, l + 1);
return true;
}
// BaseDisplacement SEPARATOR
private static boolean internalBaseDisplacementOption1_0_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption1_0_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = BaseDisplacement(b, l + 1);
r = r && consumeToken(b, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
// (AddressRegister SEPARATOR)?
private static boolean internalBaseDisplacementOption1_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption1_1")) return false;
internalBaseDisplacementOption1_1_0(b, l + 1);
return true;
}
// AddressRegister SEPARATOR
private static boolean internalBaseDisplacementOption1_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption1_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = AddressRegister(b, l + 1);
r = r && consumeToken(b, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// (BaseDisplacement SEPARATOR)? AddressRegister (SEPARATOR IndexRegister)?
static boolean internalBaseDisplacementOption2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption2")) return false;
boolean r;
Marker m = enter_section_(b);
r = internalBaseDisplacementOption2_0(b, l + 1);
r = r && AddressRegister(b, l + 1);
r = r && internalBaseDisplacementOption2_2(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// (BaseDisplacement SEPARATOR)?
private static boolean internalBaseDisplacementOption2_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption2_0")) return false;
internalBaseDisplacementOption2_0_0(b, l + 1);
return true;
}
// BaseDisplacement SEPARATOR
private static boolean internalBaseDisplacementOption2_0_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption2_0_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = BaseDisplacement(b, l + 1);
r = r && consumeToken(b, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
// (SEPARATOR IndexRegister)?
private static boolean internalBaseDisplacementOption2_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption2_2")) return false;
internalBaseDisplacementOption2_2_0(b, l + 1);
return true;
}
// SEPARATOR IndexRegister
private static boolean internalBaseDisplacementOption2_2_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption2_2_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, SEPARATOR);
r = r && IndexRegister(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// BaseDisplacement (SEPARATOR AddressRegister)? (SEPARATOR IndexRegister)?
static boolean internalBaseDisplacementOption3(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption3")) return false;
boolean r;
Marker m = enter_section_(b);
r = BaseDisplacement(b, l + 1);
r = r && internalBaseDisplacementOption3_1(b, l + 1);
r = r && internalBaseDisplacementOption3_2(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// (SEPARATOR AddressRegister)?
private static boolean internalBaseDisplacementOption3_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption3_1")) return false;
internalBaseDisplacementOption3_1_0(b, l + 1);
return true;
}
// SEPARATOR AddressRegister
private static boolean internalBaseDisplacementOption3_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption3_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, SEPARATOR);
r = r && AddressRegister(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// (SEPARATOR IndexRegister)?
private static boolean internalBaseDisplacementOption3_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption3_2")) return false;
internalBaseDisplacementOption3_2_0(b, l + 1);
return true;
}
// SEPARATOR IndexRegister
private static boolean internalBaseDisplacementOption3_2_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalBaseDisplacementOption3_2_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, SEPARATOR);
r = r && IndexRegister(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// (BaseDisplacement SEPARATOR)? AddressRegister
static boolean internalMemoryIndirectPostIndexedOption1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalMemoryIndirectPostIndexedOption1")) return false;
boolean r;
Marker m = enter_section_(b);
r = internalMemoryIndirectPostIndexedOption1_0(b, l + 1);
r = r && AddressRegister(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// (BaseDisplacement SEPARATOR)?
private static boolean internalMemoryIndirectPostIndexedOption1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalMemoryIndirectPostIndexedOption1_0")) return false;
internalMemoryIndirectPostIndexedOption1_0_0(b, l + 1);
return true;
}
// BaseDisplacement SEPARATOR
private static boolean internalMemoryIndirectPostIndexedOption1_0_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalMemoryIndirectPostIndexedOption1_0_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = BaseDisplacement(b, l + 1);
r = r && consumeToken(b, SEPARATOR);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// BaseDisplacement (SEPARATOR AddressRegister)?
static boolean internalMemoryIndirectPostIndexedOption2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalMemoryIndirectPostIndexedOption2")) return false;
boolean r;
Marker m = enter_section_(b);
r = BaseDisplacement(b, l + 1);
r = r && internalMemoryIndirectPostIndexedOption2_1(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// (SEPARATOR AddressRegister)?
private static boolean internalMemoryIndirectPostIndexedOption2_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalMemoryIndirectPostIndexedOption2_1")) return false;
internalMemoryIndirectPostIndexedOption2_1_0(b, l + 1);
return true;
}
// SEPARATOR AddressRegister
private static boolean internalMemoryIndirectPostIndexedOption2_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "internalMemoryIndirectPostIndexedOption2_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, SEPARATOR);
r = r && AddressRegister(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// !<<eof>> (MacroDefinition | statement) (<<eof>>|EOL)
static boolean line(PsiBuilder b, int l) {

View File

@ -0,0 +1,17 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import org.jetbrains.annotations.Nullable;
public interface M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingMode extends M68kAddressingMode, M68kWithOptionalAddressRegisterIndirect, M68kWithBaseDisplacement, M68kWithOptionalIndexRegister {
@Nullable
M68kAddressRegister getAddressRegister();
@Nullable
M68kIndexRegister getIndexRegister();
@Nullable
M68kBaseDisplacement getBaseDisplacement();
}

View File

@ -0,0 +1,15 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kBaseDisplacement extends M68kPsiElement {
@Nullable
M68kDataWidth getDataWidth();
@NotNull
M68kExpr getExpr();
}

View File

@ -9,6 +9,9 @@ public interface M68kIndexRegister extends M68kPsiElement {
@Nullable
M68kDataWidth getDataWidth();
@Nullable
M68kIndexScale getIndexScale();
@NotNull
M68kRegister getRegister();

View File

@ -0,0 +1,11 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import org.jetbrains.annotations.NotNull;
public interface M68kIndexScale extends M68kPsiElement {
@NotNull
M68kExpr getIndexScale();
}

View File

@ -0,0 +1,18 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kMemoryIndirectAddressingMode extends M68kAddressingMode, M68kWithAddressRegisterIndirect, M68kWithBaseDisplacement, M68kWithOuterDisplacement {
@NotNull
M68kAddressRegister getAddressRegister();
@Nullable
M68kBaseDisplacement getBaseDisplacement();
@Nullable
M68kOuterDisplacement getOuterDisplacement();
}

View File

@ -0,0 +1,21 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kMemoryIndirectPostIndexedAddressingMode extends M68kAddressingMode, M68kWithOptionalAddressRegisterIndirect, M68kWithBaseDisplacement, M68kWithIndexRegister, M68kWithOuterDisplacement {
@Nullable
M68kAddressRegister getAddressRegister();
@NotNull
M68kIndexRegister getIndexRegister();
@Nullable
M68kBaseDisplacement getBaseDisplacement();
@Nullable
M68kOuterDisplacement getOuterDisplacement();
}

View File

@ -0,0 +1,21 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kMemoryIndirectPreIndexedAddressingMode extends M68kAddressingMode, M68kWithOptionalAddressRegisterIndirect, M68kWithBaseDisplacement, M68kWithIndexRegister, M68kWithOuterDisplacement {
@Nullable
M68kAddressRegister getAddressRegister();
@NotNull
M68kIndexRegister getIndexRegister();
@Nullable
M68kBaseDisplacement getBaseDisplacement();
@Nullable
M68kOuterDisplacement getOuterDisplacement();
}

View File

@ -0,0 +1,15 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kOuterDisplacement extends M68kPsiElement {
@Nullable
M68kDataWidth getDataWidth();
@NotNull
M68kExpr getExpr();
}

View File

@ -0,0 +1,14 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import org.jetbrains.annotations.Nullable;
public interface M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingMode extends M68kAddressingMode, M68kWithBaseDisplacement, M68kWithOptionalIndexRegister {
@Nullable
M68kIndexRegister getIndexRegister();
@Nullable
M68kBaseDisplacement getBaseDisplacement();
}

View File

@ -0,0 +1,14 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import org.jetbrains.annotations.Nullable;
public interface M68kProgramCounterMemoryIndirectAddressingMode extends M68kAddressingMode, M68kWithBaseDisplacement, M68kWithOuterDisplacement {
@Nullable
M68kBaseDisplacement getBaseDisplacement();
@Nullable
M68kOuterDisplacement getOuterDisplacement();
}

View File

@ -0,0 +1,18 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kProgramCounterMemoryIndirectPostIndexedAddressingMode extends M68kAddressingMode, M68kWithBaseDisplacement, M68kWithIndexRegister, M68kWithOuterDisplacement {
@NotNull
M68kIndexRegister getIndexRegister();
@Nullable
M68kBaseDisplacement getBaseDisplacement();
@Nullable
M68kOuterDisplacement getOuterDisplacement();
}

View File

@ -0,0 +1,18 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kProgramCounterMemoryIndirectPreIndexedAddressingMode extends M68kAddressingMode, M68kWithBaseDisplacement, M68kWithIndexRegister, M68kWithOuterDisplacement {
@NotNull
M68kIndexRegister getIndexRegister();
@Nullable
M68kBaseDisplacement getBaseDisplacement();
@Nullable
M68kOuterDisplacement getOuterDisplacement();
}

View File

@ -18,12 +18,14 @@ public interface M68kTypes {
IElementType ADDRESS_REGISTER_INDIRECT_PRE_DEC_ADDRESSING_MODE = new M68kElementType("ADDRESS_REGISTER_INDIRECT_PRE_DEC_ADDRESSING_MODE");
IElementType ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE = new M68kElementType("ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE");
IElementType ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE = new M68kElementType("ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE");
IElementType ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE = new M68kElementType("ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE");
IElementType ADDRESS_REGISTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE = new M68kElementType("ADDRESS_REGISTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE");
IElementType ADDRESS_REGISTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE = new M68kElementType("ADDRESS_REGISTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE");
IElementType ADDRESS_SIZE = new M68kElementType("ADDRESS_SIZE");
IElementType ASM_INSTRUCTION = new M68kElementType("ASM_INSTRUCTION");
IElementType ASM_OP = new M68kElementType("ASM_OP");
IElementType ASSIGNMENT = new M68kElementType("ASSIGNMENT");
IElementType BASE_DISPLACEMENT = new M68kElementType("BASE_DISPLACEMENT");
IElementType BINARY_ADD_EXPR = new M68kElementType("BINARY_ADD_EXPR");
IElementType BINARY_BITWISE_AND_EXPR = new M68kElementType("BINARY_BITWISE_AND_EXPR");
IElementType BINARY_BITWISE_OR_EXPR = new M68kElementType("BINARY_BITWISE_OR_EXPR");
@ -49,20 +51,29 @@ public interface M68kTypes {
IElementType GLOBAL_LABEL = M68kStubElementTypeFactory.stubFactory("GLOBAL_LABEL");
IElementType IMMEDIATE_DATA = new M68kElementType("IMMEDIATE_DATA");
IElementType INDEX_REGISTER = new M68kElementType("INDEX_REGISTER");
IElementType INDEX_SCALE = new M68kElementType("INDEX_SCALE");
IElementType LITERAL_EXPR = new M68kElementType("LITERAL_EXPR");
IElementType LOCAL_LABEL = new M68kElementType("LOCAL_LABEL");
IElementType MACRO_CALL = new M68kElementType("MACRO_CALL");
IElementType MACRO_DEFINITION = M68kStubElementTypeFactory.stubFactory("MACRO_DEFINITION");
IElementType MACRO_NAME_DEFINITION = new M68kElementType("MACRO_NAME_DEFINITION");
IElementType MACRO_PLAIN_LINE = new M68kElementType("MACRO_PLAIN_LINE");
IElementType MEMORY_INDIRECT_ADDRESSING_MODE = new M68kElementType("MEMORY_INDIRECT_ADDRESSING_MODE");
IElementType MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE = new M68kElementType("MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE");
IElementType MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE = new M68kElementType("MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE");
IElementType OPERAND_SIZE = new M68kElementType("OPERAND_SIZE");
IElementType OUTER_DISPLACEMENT = new M68kElementType("OUTER_DISPLACEMENT");
IElementType PAREN_EXPR = new M68kElementType("PAREN_EXPR");
IElementType PREPROCESSOR_DIRECTIVE = new M68kElementType("PREPROCESSOR_DIRECTIVE");
IElementType PREPROCESSOR_KEYWORD = new M68kElementType("PREPROCESSOR_KEYWORD");
IElementType PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE");
IElementType PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE");
IElementType PROGRAM_COUNTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE");
IElementType PROGRAM_COUNTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE");
IElementType PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE");
IElementType PROGRAM_COUNTER_MEMORY_INDIRECT_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_MEMORY_INDIRECT_ADDRESSING_MODE");
IElementType PROGRAM_COUNTER_MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE");
IElementType PROGRAM_COUNTER_MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE");
IElementType PROGRAM_COUNTER_REFERENCE = new M68kElementType("PROGRAM_COUNTER_REFERENCE");
IElementType REF_EXPR = new M68kElementType("REF_EXPR");
IElementType REGISTER = new M68kElementType("REGISTER");
@ -126,6 +137,8 @@ public interface M68kTypes {
IElementType OTHER_DIRECTIVE = new M68kTokenType("OTHER_DIRECTIVE");
IElementType PC = new M68kTokenType("PC");
IElementType REG_CCR = new M68kTokenType("REG_CCR");
IElementType REG_DFC = new M68kTokenType("REG_DFC");
IElementType REG_SFC = new M68kTokenType("REG_SFC");
IElementType REG_SP = new M68kTokenType("REG_SP");
IElementType REG_SR = new M68kTokenType("REG_SR");
IElementType REG_USP = new M68kTokenType("REG_USP");
@ -133,6 +146,8 @@ public interface M68kTypes {
IElementType ROUND_L = new M68kTokenType("ROUND_L");
IElementType ROUND_R = new M68kTokenType("ROUND_R");
IElementType SEPARATOR = new M68kTokenType("SEPARATOR");
IElementType SQUARE_L = new M68kTokenType("SQUARE_L");
IElementType SQUARE_R = new M68kTokenType("SQUARE_R");
IElementType STRINGLIT = new M68kTokenType("STRINGLIT");
IElementType SYMBOL = new M68kTokenType("SYMBOL");
IElementType SYMBOLDEF = new M68kTokenType("SYMBOLDEF");
@ -156,6 +171,8 @@ public interface M68kTypes {
return new M68kAddressRegisterIndirectWithDisplacementNewAddressingModeImpl(node);
} else if (type == ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE) {
return new M68kAddressRegisterIndirectWithDisplacementOldAddressingModeImpl(node);
} else if (type == ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) {
return new M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingModeImpl(node);
} 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) {
@ -168,6 +185,8 @@ public interface M68kTypes {
return new M68kAsmOpImpl(node);
} else if (type == ASSIGNMENT) {
return new M68kAssignmentImpl(node);
} else if (type == BASE_DISPLACEMENT) {
return new M68kBaseDisplacementImpl(node);
} else if (type == BINARY_ADD_EXPR) {
return new M68kBinaryAddExprImpl(node);
} else if (type == BINARY_BITWISE_AND_EXPR) {
@ -216,6 +235,8 @@ public interface M68kTypes {
return new M68kImmediateDataImpl(node);
} else if (type == INDEX_REGISTER) {
return new M68kIndexRegisterImpl(node);
} else if (type == INDEX_SCALE) {
return new M68kIndexScaleImpl(node);
} else if (type == LITERAL_EXPR) {
return new M68kLiteralExprImpl(node);
} else if (type == LOCAL_LABEL) {
@ -228,8 +249,16 @@ public interface M68kTypes {
return new M68kMacroNameDefinitionImpl(node);
} else if (type == MACRO_PLAIN_LINE) {
return new M68kMacroPlainLineImpl(node);
} else if (type == MEMORY_INDIRECT_ADDRESSING_MODE) {
return new M68kMemoryIndirectAddressingModeImpl(node);
} else if (type == MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE) {
return new M68kMemoryIndirectPostIndexedAddressingModeImpl(node);
} else if (type == MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE) {
return new M68kMemoryIndirectPreIndexedAddressingModeImpl(node);
} else if (type == OPERAND_SIZE) {
return new M68kOperandSizeImpl(node);
} else if (type == OUTER_DISPLACEMENT) {
return new M68kOuterDisplacementImpl(node);
} else if (type == PAREN_EXPR) {
return new M68kParenExprImpl(node);
} else if (type == PREPROCESSOR_DIRECTIVE) {
@ -240,10 +269,18 @@ public interface M68kTypes {
return new M68kProgramCounterIndirectWithDisplacementNewAddressingModeImpl(node);
} else if (type == PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE) {
return new M68kProgramCounterIndirectWithDisplacementOldAddressingModeImpl(node);
} else if (type == PROGRAM_COUNTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) {
return new M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingModeImpl(node);
} 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) {
return new M68kProgramCounterIndirectWithIndexOldAddressingModeImpl(node);
} else if (type == PROGRAM_COUNTER_MEMORY_INDIRECT_ADDRESSING_MODE) {
return new M68kProgramCounterMemoryIndirectAddressingModeImpl(node);
} else if (type == PROGRAM_COUNTER_MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE) {
return new M68kProgramCounterMemoryIndirectPostIndexedAddressingModeImpl(node);
} else if (type == PROGRAM_COUNTER_MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE) {
return new M68kProgramCounterMemoryIndirectPreIndexedAddressingModeImpl(node);
} else if (type == PROGRAM_COUNTER_REFERENCE) {
return new M68kProgramCounterReferenceImpl(node);
} else if (type == REF_EXPR) {

View File

@ -45,6 +45,13 @@ public class M68kVisitor extends PsiElementVisitor {
// visitWithDisplacement(o);
}
public void visitAddressRegisterIndirectWithIndexBaseDisplacementAddressingMode(@NotNull M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingMode o) {
visitAddressingMode(o);
// visitWithOptionalAddressRegisterIndirect(o);
// visitWithBaseDisplacement(o);
// visitWithOptionalIndexRegister(o);
}
public void visitAddressRegisterIndirectWithIndexNewAddressingMode(@NotNull M68kAddressRegisterIndirectWithIndexNewAddressingMode o) {
visitAddressingMode(o);
// visitWithAddressRegisterIndirect(o);
@ -79,6 +86,10 @@ public class M68kVisitor extends PsiElementVisitor {
visitPsiElement(o);
}
public void visitBaseDisplacement(@NotNull M68kBaseDisplacement o) {
visitPsiElement(o);
}
public void visitDataRegister(@NotNull M68kDataRegister o) {
visitRegister(o);
}
@ -103,6 +114,10 @@ public class M68kVisitor extends PsiElementVisitor {
visitPsiElement(o);
}
public void visitIndexScale(@NotNull M68kIndexScale o) {
visitPsiElement(o);
}
public void visitLocalLabel(@NotNull M68kLocalLabel o) {
visitNamedElement(o);
}
@ -123,10 +138,37 @@ public class M68kVisitor extends PsiElementVisitor {
visitPsiElement(o);
}
public void visitMemoryIndirectAddressingMode(@NotNull M68kMemoryIndirectAddressingMode o) {
visitAddressingMode(o);
// visitWithAddressRegisterIndirect(o);
// visitWithBaseDisplacement(o);
// visitWithOuterDisplacement(o);
}
public void visitMemoryIndirectPostIndexedAddressingMode(@NotNull M68kMemoryIndirectPostIndexedAddressingMode o) {
visitAddressingMode(o);
// visitWithOptionalAddressRegisterIndirect(o);
// visitWithBaseDisplacement(o);
// visitWithIndexRegister(o);
// visitWithOuterDisplacement(o);
}
public void visitMemoryIndirectPreIndexedAddressingMode(@NotNull M68kMemoryIndirectPreIndexedAddressingMode o) {
visitAddressingMode(o);
// visitWithOptionalAddressRegisterIndirect(o);
// visitWithBaseDisplacement(o);
// visitWithIndexRegister(o);
// visitWithOuterDisplacement(o);
}
public void visitOperandSize(@NotNull M68kOperandSize o) {
visitPsiElement(o);
}
public void visitOuterDisplacement(@NotNull M68kOuterDisplacement o) {
visitPsiElement(o);
}
public void visitPreprocessorDirective(@NotNull M68kPreprocessorDirective o) {
visitPsiElement(o);
}
@ -145,6 +187,12 @@ public class M68kVisitor extends PsiElementVisitor {
// visitWithDisplacement(o);
}
public void visitProgramCounterIndirectWithIndexBaseDisplacementAddressingMode(@NotNull M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingMode o) {
visitAddressingMode(o);
// visitWithBaseDisplacement(o);
// visitWithOptionalIndexRegister(o);
}
public void visitProgramCounterIndirectWithIndexNewAddressingMode(@NotNull M68kProgramCounterIndirectWithIndexNewAddressingMode o) {
visitAddressingMode(o);
// visitWithDisplacement(o);
@ -157,6 +205,26 @@ public class M68kVisitor extends PsiElementVisitor {
// visitWithIndexRegister(o);
}
public void visitProgramCounterMemoryIndirectAddressingMode(@NotNull M68kProgramCounterMemoryIndirectAddressingMode o) {
visitAddressingMode(o);
// visitWithBaseDisplacement(o);
// visitWithOuterDisplacement(o);
}
public void visitProgramCounterMemoryIndirectPostIndexedAddressingMode(@NotNull M68kProgramCounterMemoryIndirectPostIndexedAddressingMode o) {
visitAddressingMode(o);
// visitWithBaseDisplacement(o);
// visitWithIndexRegister(o);
// visitWithOuterDisplacement(o);
}
public void visitProgramCounterMemoryIndirectPreIndexedAddressingMode(@NotNull M68kProgramCounterMemoryIndirectPreIndexedAddressingMode o) {
visitAddressingMode(o);
// visitWithBaseDisplacement(o);
// visitWithIndexRegister(o);
// visitWithOuterDisplacement(o);
}
public void visitProgramCounterReference(@NotNull M68kProgramCounterReference o) {
visitPsiElement(o);
}

View File

@ -0,0 +1,46 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingModeImpl extends M68kAddressingModeImpl implements M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingMode {
public M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingModeImpl(@NotNull ASTNode node) {
super(node);
}
@Override
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitAddressRegisterIndirectWithIndexBaseDisplacementAddressingMode(this);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
@Override
@Nullable
public M68kAddressRegister getAddressRegister() {
return PsiTreeUtil.getChildOfType(this, M68kAddressRegister.class);
}
@Override
@Nullable
public M68kIndexRegister getIndexRegister() {
return PsiTreeUtil.getChildOfType(this, M68kIndexRegister.class);
}
@Override
@Nullable
public M68kBaseDisplacement getBaseDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kBaseDisplacement.class);
}
}

View File

@ -0,0 +1,43 @@
// 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.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kBaseDisplacement;
import de.platon42.intellij.plugins.m68k.psi.M68kDataWidth;
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;
public class M68kBaseDisplacementImpl extends ASTWrapperPsiElement implements M68kBaseDisplacement {
public M68kBaseDisplacementImpl(@NotNull ASTNode node) {
super(node);
}
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitBaseDisplacement(this);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
@Override
@Nullable
public M68kDataWidth getDataWidth() {
return PsiTreeUtil.getChildOfType(this, M68kDataWidth.class);
}
@Override
@NotNull
public M68kExpr getExpr() {
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kExpr.class));
}
}

View File

@ -19,8 +19,8 @@ public class M68kGlobalLabelImpl extends M68kGlobalLabelMixin implements M68kGlo
super(node);
}
public M68kGlobalLabelImpl(@NotNull M68kGlobalLabelStub stub, @NotNull IStubElementType<?, ?> nodeType) {
super(stub, nodeType);
public M68kGlobalLabelImpl(@NotNull M68kGlobalLabelStub stub, @NotNull IStubElementType<?, ?> type) {
super(stub, type);
}
public void accept(@NotNull M68kVisitor visitor) {

View File

@ -31,6 +31,12 @@ public class M68kIndexRegisterImpl extends ASTWrapperPsiElement implements M68kI
return PsiTreeUtil.getChildOfType(this, M68kDataWidth.class);
}
@Override
@Nullable
public M68kIndexScale getIndexScale() {
return PsiTreeUtil.getChildOfType(this, M68kIndexScale.class);
}
@Override
@NotNull
public M68kRegister getRegister() {

View File

@ -0,0 +1,35 @@
// 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.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kIndexScale;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
public class M68kIndexScaleImpl extends ASTWrapperPsiElement implements M68kIndexScale {
public M68kIndexScaleImpl(@NotNull ASTNode node) {
super(node);
}
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitIndexScale(this);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
@Override
@NotNull
public M68kExpr getIndexScale() {
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kExpr.class));
}
}

View File

@ -19,8 +19,8 @@ public class M68kMacroDefinitionImpl extends M68kMacroDefinitionMixin implements
super(node);
}
public M68kMacroDefinitionImpl(@NotNull M68kMacroDefinitionStub stub, @NotNull IStubElementType<?, ?> nodeType) {
super(stub, nodeType);
public M68kMacroDefinitionImpl(@NotNull M68kMacroDefinitionStub stub, @NotNull IStubElementType<?, ?> type) {
super(stub, type);
}
public void accept(@NotNull M68kVisitor visitor) {

View File

@ -0,0 +1,46 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class M68kMemoryIndirectAddressingModeImpl extends M68kAddressingModeImpl implements M68kMemoryIndirectAddressingMode {
public M68kMemoryIndirectAddressingModeImpl(@NotNull ASTNode node) {
super(node);
}
@Override
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitMemoryIndirectAddressingMode(this);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
@Override
@NotNull
public M68kAddressRegister getAddressRegister() {
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kAddressRegister.class));
}
@Override
@Nullable
public M68kBaseDisplacement getBaseDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kBaseDisplacement.class);
}
@Override
@Nullable
public M68kOuterDisplacement getOuterDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kOuterDisplacement.class);
}
}

View File

@ -0,0 +1,52 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class M68kMemoryIndirectPostIndexedAddressingModeImpl extends M68kAddressingModeImpl implements M68kMemoryIndirectPostIndexedAddressingMode {
public M68kMemoryIndirectPostIndexedAddressingModeImpl(@NotNull ASTNode node) {
super(node);
}
@Override
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitMemoryIndirectPostIndexedAddressingMode(this);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
@Override
@Nullable
public M68kAddressRegister getAddressRegister() {
return PsiTreeUtil.getChildOfType(this, M68kAddressRegister.class);
}
@Override
@NotNull
public M68kIndexRegister getIndexRegister() {
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kIndexRegister.class));
}
@Override
@Nullable
public M68kBaseDisplacement getBaseDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kBaseDisplacement.class);
}
@Override
@Nullable
public M68kOuterDisplacement getOuterDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kOuterDisplacement.class);
}
}

View File

@ -0,0 +1,52 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class M68kMemoryIndirectPreIndexedAddressingModeImpl extends M68kAddressingModeImpl implements M68kMemoryIndirectPreIndexedAddressingMode {
public M68kMemoryIndirectPreIndexedAddressingModeImpl(@NotNull ASTNode node) {
super(node);
}
@Override
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitMemoryIndirectPreIndexedAddressingMode(this);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
@Override
@Nullable
public M68kAddressRegister getAddressRegister() {
return PsiTreeUtil.getChildOfType(this, M68kAddressRegister.class);
}
@Override
@NotNull
public M68kIndexRegister getIndexRegister() {
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kIndexRegister.class));
}
@Override
@Nullable
public M68kBaseDisplacement getBaseDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kBaseDisplacement.class);
}
@Override
@Nullable
public M68kOuterDisplacement getOuterDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kOuterDisplacement.class);
}
}

View File

@ -0,0 +1,43 @@
// 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.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kDataWidth;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kOuterDisplacement;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class M68kOuterDisplacementImpl extends ASTWrapperPsiElement implements M68kOuterDisplacement {
public M68kOuterDisplacementImpl(@NotNull ASTNode node) {
super(node);
}
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitOuterDisplacement(this);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
@Override
@Nullable
public M68kDataWidth getDataWidth() {
return PsiTreeUtil.getChildOfType(this, M68kDataWidth.class);
}
@Override
@NotNull
public M68kExpr getExpr() {
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kExpr.class));
}
}

View File

@ -0,0 +1,43 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kBaseDisplacement;
import de.platon42.intellij.plugins.m68k.psi.M68kIndexRegister;
import de.platon42.intellij.plugins.m68k.psi.M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingModeImpl extends M68kAddressingModeImpl implements M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingMode {
public M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingModeImpl(@NotNull ASTNode node) {
super(node);
}
@Override
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitProgramCounterIndirectWithIndexBaseDisplacementAddressingMode(this);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
@Override
@Nullable
public M68kIndexRegister getIndexRegister() {
return PsiTreeUtil.getChildOfType(this, M68kIndexRegister.class);
}
@Override
@Nullable
public M68kBaseDisplacement getBaseDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kBaseDisplacement.class);
}
}

View File

@ -0,0 +1,43 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kBaseDisplacement;
import de.platon42.intellij.plugins.m68k.psi.M68kOuterDisplacement;
import de.platon42.intellij.plugins.m68k.psi.M68kProgramCounterMemoryIndirectAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class M68kProgramCounterMemoryIndirectAddressingModeImpl extends M68kAddressingModeImpl implements M68kProgramCounterMemoryIndirectAddressingMode {
public M68kProgramCounterMemoryIndirectAddressingModeImpl(@NotNull ASTNode node) {
super(node);
}
@Override
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitProgramCounterMemoryIndirectAddressingMode(this);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
@Override
@Nullable
public M68kBaseDisplacement getBaseDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kBaseDisplacement.class);
}
@Override
@Nullable
public M68kOuterDisplacement getOuterDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kOuterDisplacement.class);
}
}

View File

@ -0,0 +1,46 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class M68kProgramCounterMemoryIndirectPostIndexedAddressingModeImpl extends M68kAddressingModeImpl implements M68kProgramCounterMemoryIndirectPostIndexedAddressingMode {
public M68kProgramCounterMemoryIndirectPostIndexedAddressingModeImpl(@NotNull ASTNode node) {
super(node);
}
@Override
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitProgramCounterMemoryIndirectPostIndexedAddressingMode(this);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
@Override
@NotNull
public M68kIndexRegister getIndexRegister() {
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kIndexRegister.class));
}
@Override
@Nullable
public M68kBaseDisplacement getBaseDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kBaseDisplacement.class);
}
@Override
@Nullable
public M68kOuterDisplacement getOuterDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kOuterDisplacement.class);
}
}

View File

@ -0,0 +1,46 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class M68kProgramCounterMemoryIndirectPreIndexedAddressingModeImpl extends M68kAddressingModeImpl implements M68kProgramCounterMemoryIndirectPreIndexedAddressingMode {
public M68kProgramCounterMemoryIndirectPreIndexedAddressingModeImpl(@NotNull ASTNode node) {
super(node);
}
@Override
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitProgramCounterMemoryIndirectPreIndexedAddressingMode(this);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
@Override
@NotNull
public M68kIndexRegister getIndexRegister() {
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kIndexRegister.class));
}
@Override
@Nullable
public M68kBaseDisplacement getBaseDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kBaseDisplacement.class);
}
@Override
@Nullable
public M68kOuterDisplacement getOuterDisplacement() {
return PsiTreeUtil.getChildOfType(this, M68kOuterDisplacement.class);
}
}

View File

@ -19,8 +19,8 @@ public class M68kSymbolDefinitionImpl extends M68kSymbolDefinitionMixin implemen
super(node);
}
public M68kSymbolDefinitionImpl(@NotNull M68kSymbolDefinitionStub stub, @NotNull IStubElementType<?, ?> nodeType) {
super(stub, nodeType);
public M68kSymbolDefinitionImpl(@NotNull M68kSymbolDefinitionStub stub, @NotNull IStubElementType<?, ?> type) {
super(stub, type);
}
public void accept(@NotNull M68kVisitor visitor) {

View File

@ -10,7 +10,7 @@ class M68kFileElementType private constructor() : ILightStubFileElementType<PsiF
@JvmField
val INSTANCE = M68kFileElementType()
const val STUB_VERSION = 6
const val STUB_VERSION = 8
const val STUB_EXTERNAL_ID_PREFIX = "MC68000."
const val EXTERNAL_ID = STUB_EXTERNAL_ID_PREFIX + "FILE"
}

View File

@ -19,7 +19,9 @@ object AssemblerDirectives {
"align", "even", "odd", "cnop", "long", "dphrase", "phrase", "qphrase",
"cargs", "comm", "comment",
"rsset", "clrfo", "clrso", "setfo", "setso"
"rsset", "clrfo", "clrso", "setfo", "setso",
"rsreset", "rs.b", "rs.w", "rs.l"
)
val plainDirectives: Set<String> = setOf(

View File

@ -0,0 +1,27 @@
package de.platon42.intellij.plugins.m68k.asm
import com.intellij.codeInsight.completion.*
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.patterns.PlatformPatterns
import com.intellij.util.ProcessingContext
import de.platon42.intellij.plugins.m68k.M68kIcons
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
class M68kDirectiveCompletionContributor : CompletionContributor() {
companion object {
val DIRECTIVES =
listOf(AssemblerDirectives.dataDirectives, AssemblerDirectives.plainDirectives, AssemblerDirectives.otherDirectives.map(String::uppercase))
.flatten()
.toSortedSet()
.map { PrioritizedLookupElement.withPriority(LookupElementBuilder.create(it).withIcon(M68kIcons.MNEMONIC), 1.5) }
}
init {
extend(CompletionType.BASIC, PlatformPatterns.psiElement(M68kTypes.MACRO_INVOCATION), object : CompletionProvider<CompletionParameters>() {
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, resultSet: CompletionResultSet) {
resultSet.addAllElements(DIRECTIVES)
}
})
}
}

View File

@ -0,0 +1,39 @@
package de.platon42.intellij.plugins.m68k.documentation
import com.intellij.lang.documentation.AbstractDocumentationProvider
import com.intellij.lang.documentation.DocumentationMarkup
import com.intellij.openapi.util.text.HtmlBuilder
import com.intellij.openapi.util.text.HtmlChunk
import com.intellij.psi.PsiElement
import de.platon42.intellij.plugins.m68k.lexer.M68kLexerPrefs
import de.platon42.intellij.plugins.m68k.psi.M68kNamedElement
import de.platon42.intellij.plugins.m68k.psi.utils.M68kPsiWalkUtil
import de.platon42.intellij.plugins.m68k.settings.M68kProjectSettings
abstract class AbstractM68kDocumentationProvider : AbstractDocumentationProvider() {
fun getSettings(element: PsiElement): M68kLexerPrefs = element.project.getService(M68kProjectSettings::class.java).settings
fun getComments(element: PsiElement): HtmlChunk {
val builder = HtmlBuilder()
val comments = M68kPsiWalkUtil.collectRelatedComments(element).map { HtmlChunk.text(it.text) }
builder.appendWithSeparators(HtmlChunk.br(), comments)
return if (comments.isNotEmpty()) builder.wrapWith(HtmlChunk.span().attr("class", "grayed")) else HtmlChunk.empty()
}
fun getDefinition(element: M68kNamedElement) = getDefinition(HtmlChunk.text(element.name!!).code())
fun getDefinition(value: String) = getDefinition(HtmlChunk.text(value))
fun getDefinition(chunk: HtmlChunk) =
HtmlBuilder().append(chunk).wrapWith(DocumentationMarkup.DEFINITION_ELEMENT)
fun getContent(element: PsiElement) =
HtmlBuilder().append(HtmlChunk.text(element.text).code()).wrapWith(DocumentationMarkup.CONTENT_ELEMENT)
fun getContent(chunk: HtmlChunk) =
HtmlBuilder().append(chunk).wrapWith(DocumentationMarkup.CONTENT_ELEMENT)
fun getContent(value: String) =
HtmlBuilder().append(value).wrapWith(DocumentationMarkup.CONTENT_ELEMENT)
}

View File

@ -1,47 +0,0 @@
package de.platon42.intellij.plugins.m68k.documentation
import com.intellij.lang.documentation.AbstractDocumentationProvider
import com.intellij.lang.documentation.DocumentationMarkup
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiComment
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.SmartList
import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabel
import de.platon42.intellij.plugins.m68k.psi.M68kStatement
class M68kGlobalLabelDocumentationProvider : AbstractDocumentationProvider() {
override fun getQuickNavigateInfo(element: PsiElement, originalElement: PsiElement?): String? {
return generateDoc(element, originalElement)
}
override fun generateDoc(element: PsiElement, originalElement: PsiElement?): String? {
return if (element is M68kGlobalLabel) {
// TODO find out how we can generate inner links for more symbol references inside the expression (DocumentationManagerUtil)
val statement = element.parent as M68kStatement
var preprocessorDirective = statement.preprocessorDirective
if ((preprocessorDirective == null) && (statement.asmInstruction == null) && (statement.macroCall == null)) {
val nextLineStatement = PsiTreeUtil.skipWhitespacesAndCommentsForward(PsiTreeUtil.skipWhitespacesAndCommentsForward(statement))
as? M68kStatement
preprocessorDirective = nextLineStatement?.preprocessorDirective
}
val content = if (preprocessorDirective != null)
DocumentationMarkup.CONTENT_START + StringUtil.escapeXmlEntities(preprocessorDirective.text) + DocumentationMarkup.CONTENT_END
else ""
val comments = SmartList<String>()
var prevToken: PsiElement? = statement
do {
prevToken = PsiTreeUtil.skipWhitespacesBackward(prevToken)
if (prevToken !is PsiComment) break
comments.add(prevToken.text)
} while (true)
val commentpart =
if (comments.isNotEmpty()) comments.asReversed().joinToString("<br>", DocumentationMarkup.GRAYED_START, DocumentationMarkup.GRAYED_END) else ""
commentpart +
DocumentationMarkup.DEFINITION_START + StringUtil.escapeXmlEntities(element.name!!) + DocumentationMarkup.DEFINITION_END +
content
} else null
}
}

View File

@ -0,0 +1,34 @@
package de.platon42.intellij.plugins.m68k.documentation
import com.intellij.openapi.util.text.HtmlBuilder
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabel
import de.platon42.intellij.plugins.m68k.psi.M68kLocalLabel
import de.platon42.intellij.plugins.m68k.psi.M68kNamedElement
import de.platon42.intellij.plugins.m68k.psi.M68kStatement
class M68kLabelDefinitionDocumentationProvider : AbstractM68kDocumentationProvider() {
override fun getQuickNavigateInfo(element: PsiElement, originalElement: PsiElement?): String? {
return generateDoc(element, originalElement)
}
override fun generateDoc(element: PsiElement, originalElement: PsiElement?): String? {
return if (element is M68kGlobalLabel || element is M68kLocalLabel) {
// TODO find out how we can generate inner links for more symbol references inside the expression (DocumentationManagerUtil)
val statement = element.parent as M68kStatement
var preprocessorDirective = statement.preprocessorDirective
if ((preprocessorDirective == null) && (statement.asmInstruction == null) && (statement.macroCall == null)) {
val nextLineStatement = PsiTreeUtil.skipWhitespacesAndCommentsForward(PsiTreeUtil.skipWhitespacesAndCommentsForward(statement))
as? M68kStatement
preprocessorDirective = nextLineStatement?.preprocessorDirective
}
val builder = HtmlBuilder()
builder.append(getComments(statement))
builder.append(getDefinition(element as M68kNamedElement))
if (preprocessorDirective != null) builder.append(getContent(preprocessorDirective))
builder.toString()
} else null
}
}

View File

@ -0,0 +1,42 @@
package de.platon42.intellij.plugins.m68k.documentation
import com.intellij.openapi.util.text.HtmlBuilder
import com.intellij.openapi.util.text.HtmlChunk
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import de.platon42.intellij.plugins.m68k.psi.M68kMacroCall
import de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinition
import de.platon42.intellij.plugins.m68k.psi.utils.M68kMacroExpansionUtil
class M68kMacroDefinitionDocumentationProvider : AbstractM68kDocumentationProvider() {
override fun getQuickNavigateInfo(element: PsiElement, originalElement: PsiElement?): String? {
return generateDoc(element, originalElement)
}
override fun generateDoc(element: PsiElement, originalElement: PsiElement?): String? {
return if (element is M68kMacroDefinition) createDoc(element, originalElement, getSettings(element).maxLongDocumentationLines) else null
}
override fun generateHoverDoc(element: PsiElement, originalElement: PsiElement?): String? {
return if (element is M68kMacroDefinition) createDoc(element, originalElement, getSettings(element).maxShortDocumentationLines) else null
}
private fun createDoc(macrodef: M68kMacroDefinition, originalElement: PsiElement?, linesLimit: Int): String {
val macroCall = PsiTreeUtil.getParentOfType(originalElement, M68kMacroCall::class.java)
val expandedMacro = M68kMacroExpansionUtil.expandMacro(macrodef, macroCall)
val builder = HtmlBuilder()
return builder
.append(getComments(macrodef))
.append(getDefinition(HtmlChunk.text(macrodef.name!!).code()))
.append(
getContent(
HtmlBuilder().appendWithSeparators(
HtmlChunk.br(),
expandedMacro.take(linesLimit).map { HtmlChunk.text(it).code() }.toList()
).toFragment()
)
)
.toString()
}
}

View File

@ -1,6 +1,5 @@
package de.platon42.intellij.plugins.m68k.documentation
import com.intellij.lang.documentation.AbstractDocumentationProvider
import com.intellij.lang.documentation.DocumentationMarkup
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.util.text.HtmlBuilder
@ -19,18 +18,18 @@ import de.platon42.intellij.plugins.m68k.utils.M68kIsaUtil.findExactIsaDataAndAl
import de.platon42.intellij.plugins.m68k.utils.M68kIsaUtil.getOpSizeOrDefault
import de.platon42.intellij.plugins.m68k.utils.M68kIsaUtil.modifyRwmWithOpsize
class M68kRegisterFlowDocumentationProvider : AbstractDocumentationProvider() {
class M68kRegisterFlowDocumentationProvider : AbstractM68kDocumentationProvider() {
override fun generateDoc(element: PsiElement, originalElement: PsiElement?): String? {
if (element is M68kDataRegister || element is M68kAddressRegister) {
return createDoc(element as M68kRegister, 100) // TODO make this configurable
return createDoc(element as M68kRegister, getSettings(element).maxLongDocumentationLines)
}
return null
}
override fun generateHoverDoc(element: PsiElement, originalElement: PsiElement?): String? {
if (element is M68kDataRegister || element is M68kAddressRegister) {
return createDoc(element as M68kRegister, 4) // TODO make this configurable
return createDoc(element as M68kRegister, getSettings(element).maxShortDocumentationLines)
}
return null
}
@ -82,15 +81,16 @@ class M68kRegisterFlowDocumentationProvider : AbstractDocumentationProvider() {
PsiTreeUtil.getPrevSiblingOfType(it, M68kStatement::class.java)
})
backtrace.reverse()
val remLines = linesLimit - backtrace.size.coerceAtLeast(1)
val traceBits = (cursorRwm or (cursorRwm ushr RWM_MODIFY_SHIFT) or (cursorRwm ushr RWM_READ_SHIFT)) and RWM_SIZE_MASK
backtrace.addAll(analyseFlow(register, traceBits, false, initialStatement, linesLimit) {
backtrace.addAll(analyseFlow(register, traceBits, false, initialStatement, remLines) {
PsiTreeUtil.getNextSiblingOfType(it, M68kStatement::class.java)
})
val statementRows = HtmlBuilder()
backtrace.forEach(statementRows::append)
val builder = HtmlBuilder()
builder.append(HtmlChunk.text(thisInfo).wrapWith(DocumentationMarkup.DEFINITION_ELEMENT))
builder.append(getDefinition(thisInfo))
builder.append(statementRows.wrapWith(DocumentationMarkup.SECTIONS_TABLE.style("padding-left: 8pt; padding-right: 8pt")))
return builder.toString()
}

View File

@ -1,13 +1,11 @@
package de.platon42.intellij.plugins.m68k.documentation
import com.intellij.lang.documentation.AbstractDocumentationProvider
import com.intellij.lang.documentation.DocumentationMarkup
import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.util.text.HtmlBuilder
import com.intellij.psi.PsiElement
import de.platon42.intellij.plugins.m68k.psi.M68kAssignment
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition
class M68kSymbolDefinitionDocumentationProvider : AbstractDocumentationProvider() {
class M68kSymbolDefinitionDocumentationProvider : AbstractM68kDocumentationProvider() {
override fun getQuickNavigateInfo(element: PsiElement, originalElement: PsiElement?): String? {
return generateDoc(element, originalElement)
@ -16,9 +14,12 @@ class M68kSymbolDefinitionDocumentationProvider : AbstractDocumentationProvider(
override fun generateDoc(element: PsiElement, originalElement: PsiElement?): String? {
return if (element is M68kSymbolDefinition) {
// TODO find out how we can generate inner links for more symbol references inside the expression (DocumentationManagerUtil)
val value = (element.parent as M68kAssignment).expr.text
DocumentationMarkup.DEFINITION_START + StringUtil.escapeXmlEntities(element.name!!) + DocumentationMarkup.DEFINITION_END +
DocumentationMarkup.CONTENT_START + StringUtil.escapeXmlEntities(value) + DocumentationMarkup.CONTENT_END
val assignment = element.parent as M68kAssignment
HtmlBuilder()
.append(getComments(assignment.parent))
.append(getDefinition(element))
.append(getContent(assignment.expr))
.toString()
} else null
}
}

View File

@ -0,0 +1,67 @@
package de.platon42.intellij.plugins.m68k.folding
import com.intellij.lang.ASTNode
import com.intellij.lang.folding.FoldingBuilderEx
import com.intellij.lang.folding.FoldingDescriptor
import com.intellij.openapi.editor.Document
import com.intellij.openapi.project.DumbAware
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.refactoring.suggested.endOffset
import com.intellij.refactoring.suggested.startOffset
import de.platon42.intellij.plugins.m68k.psi.M68kFile
import de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinition
import de.platon42.intellij.plugins.m68k.psi.M68kStatement
import de.platon42.intellij.plugins.m68k.psi.utils.M68kPsiWalkUtil.getBeginningOfRelatedComment
import de.platon42.intellij.plugins.m68k.psi.utils.M68kPsiWalkUtil.isSignificantLine
class M68kFoldingBuilder : FoldingBuilderEx(), DumbAware {
override fun buildFoldRegions(root: PsiElement, document: Document, quick: Boolean): Array<FoldingDescriptor> {
if (root !is M68kFile) return FoldingDescriptor.EMPTY
val descriptors = ArrayList<FoldingDescriptor>()
var lineElement = root.firstChild
var foldingOpen = false
var foldingStart: PsiElement? = null
var foldingName: String? = null
var lastStatement = lineElement as? M68kStatement
while (lineElement != null) {
if (lineElement is M68kMacroDefinition) {
val fd = FoldingDescriptor(lineElement, lineElement.startOffset, lineElement.endOffset, null, "[[[ MACRO " + lineElement.name!! + " ]]]")
descriptors.add(fd)
}
if (lineElement is M68kStatement) {
val label = lineElement.globalLabel
if (label != null) {
foldingOpen = true
foldingStart = getBeginningOfRelatedComment(lineElement)
foldingName = "[[[ ${label.name} ]]]"
}
lastStatement = lineElement
}
lineElement = PsiTreeUtil.skipWhitespacesAndCommentsForward(lineElement)
if (foldingOpen) {
val stopIt = (lineElement == null) || isSignificantLine(lineElement)
if (stopIt) {
val fd = FoldingDescriptor(
foldingStart!!.parent!!,
foldingStart.startOffsetInParent, lastStatement!!.textRangeInParent.endOffset,
null, foldingName!!
)
descriptors.add(fd)
foldingOpen = false
}
}
}
return descriptors.toArray(FoldingDescriptor.EMPTY)
}
override fun getPlaceholderText(node: ASTNode): String? {
return "..."
}
override fun isCollapsedByDefault(node: ASTNode): Boolean {
return false
}
}

View File

@ -0,0 +1,23 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.formatting.Alignment
import com.intellij.formatting.Block
import com.intellij.formatting.Spacing
import com.intellij.formatting.Wrap
import com.intellij.lang.ASTNode
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.formatter.common.AbstractBlock
class M68kAsmAssignmentBlock(
node: ASTNode, wrap: Wrap?, alignment: Alignment?,
private val codeStyleSettings: CodeStyleSettings
) : AbstractBlock(node, wrap, alignment) {
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
return Spacing.getReadOnlySpacing()
}
override fun isLeaf() = true
override fun buildChildren() = emptyList<Block>()
}

View File

@ -0,0 +1,62 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.formatting.Alignment
import com.intellij.formatting.Block
import com.intellij.formatting.Spacing
import com.intellij.formatting.Wrap
import com.intellij.lang.ASTNode
import com.intellij.psi.TokenType
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.formatter.common.AbstractBlock
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
class M68kAsmBlock(
node: ASTNode, wrap: Wrap?, alignment: Alignment?,
val column: Int,
private val codeStyleSettings: CodeStyleSettings
) : AbstractBlock(node, wrap, alignment) {
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
if (child1 is M68kAsmBlock && child2 is M68kAsmBlock) {
val columnDiff = child2.column - child1.column
if (columnDiff > 0) {
var minSpaces = columnDiff * codeStyleSettings.indentOptions.INDENT_SIZE - child1.node.textLength
while (minSpaces < 1) {
minSpaces += codeStyleSettings.indentOptions.INDENT_SIZE
}
return Spacing.createSpacing(minSpaces, minSpaces, 0, false, 0)
}
}
return null
}
override fun isLeaf() = (node.firstChildNode == null)
override fun buildChildren(): List<Block> {
val subBlocks = ArrayList<Block>()
if (myNode.elementType == M68kTypes.ASM_OP) {
return subBlocks
}
var child = myNode.firstChildNode
var newColumn = column
while (child != null) {
if (child.elementType != TokenType.WHITE_SPACE) {
subBlocks.add(
M68kAsmBlock(
child,
null,
null,
newColumn,
codeStyleSettings
)
)
if (child.elementType == M68kTypes.ASM_OP) {
newColumn += 2
}
}
child = child.treeNext
}
return subBlocks
}
}

View File

@ -0,0 +1,7 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.codeStyle.CustomCodeStyleSettings
class M68kAsmCodeStyleSettings(container: CodeStyleSettings) : CustomCodeStyleSettings("MC68000AsmCodeStyleSettings", container) {
}

View File

@ -0,0 +1,31 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.application.options.CodeStyleAbstractConfigurable
import com.intellij.application.options.CodeStyleAbstractPanel
import com.intellij.application.options.TabbedLanguageCodeStylePanel
import com.intellij.psi.codeStyle.CodeStyleConfigurable
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.codeStyle.CodeStyleSettingsProvider
import com.intellij.psi.codeStyle.CustomCodeStyleSettings
import de.platon42.intellij.plugins.m68k.MC68000Language
class M68kAsmCodeStyleSettingsProvider : CodeStyleSettingsProvider() {
override fun createCustomSettings(settings: CodeStyleSettings): CustomCodeStyleSettings {
return M68kAsmCodeStyleSettings(settings)
}
override fun createConfigurable(settings: CodeStyleSettings, modelSettings: CodeStyleSettings): CodeStyleConfigurable {
return object : CodeStyleAbstractConfigurable(settings, modelSettings, configurableDisplayName) {
override fun createPanel(settings: CodeStyleSettings): CodeStyleAbstractPanel {
return M68kAsmCodeStyleMainPanel(currentSettings, settings)
}
}
}
override fun getConfigurableDisplayName() = "M68k"
private class M68kAsmCodeStyleMainPanel(currentSettings: CodeStyleSettings, settings: CodeStyleSettings) :
TabbedLanguageCodeStylePanel(MC68000Language.INSTANCE, currentSettings, settings)
}

View File

@ -0,0 +1,21 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.formatting.Block
import com.intellij.formatting.Spacing
import com.intellij.lang.ASTNode
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.formatter.common.AbstractBlock
class M68kAsmCommentBlock(
node: ASTNode,
private val codeStyleSettings: CodeStyleSettings
) : AbstractBlock(node, null, null) {
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
return Spacing.getReadOnlySpacing()
}
override fun isLeaf() = true
override fun buildChildren() = emptyList<Block>()
}

View File

@ -0,0 +1,14 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.formatting.Block
import com.intellij.lang.ASTNode
import com.intellij.psi.formatter.common.AbstractBlock
class M68kAsmEolBlock(node: ASTNode) : AbstractBlock(node, null, null) {
override fun getSpacing(child1: Block?, child2: Block) = null
override fun isLeaf() = true
override fun buildChildren() = emptyList<Block>()
}

View File

@ -0,0 +1,19 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.formatting.FormattingContext
import com.intellij.formatting.FormattingModel
import com.intellij.formatting.FormattingModelBuilder
import com.intellij.formatting.FormattingModelProvider
class M68kAsmFormattingModelBuilder : FormattingModelBuilder {
override fun createModel(formattingContext: FormattingContext): FormattingModel {
val codeStyleSettings = formattingContext.codeStyleSettings
return FormattingModelProvider.createFormattingModelForPsiFile(
formattingContext.containingFile,
M68kAsmRootBlock(formattingContext.node, codeStyleSettings),
codeStyleSettings
)
}
}

View File

@ -0,0 +1,23 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.formatting.Alignment
import com.intellij.formatting.Block
import com.intellij.formatting.Spacing
import com.intellij.formatting.Wrap
import com.intellij.lang.ASTNode
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.formatter.common.AbstractBlock
class M68kAsmLabelBlock(
node: ASTNode, wrap: Wrap?, alignment: Alignment?,
private val codeStyleSettings: CodeStyleSettings
) : AbstractBlock(node, wrap, alignment) {
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
return Spacing.getReadOnlySpacing()
}
override fun isLeaf() = true
override fun buildChildren() = emptyList<Block>()
}

View File

@ -0,0 +1,21 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.formatting.Block
import com.intellij.formatting.Spacing
import com.intellij.lang.ASTNode
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.formatter.common.AbstractBlock
class M68kAsmMacroDefBlock(
node: ASTNode,
private val codeStyleSettings: CodeStyleSettings
) : AbstractBlock(node, null, null) {
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
return Spacing.getReadOnlySpacing()
}
override fun isLeaf() = true
override fun buildChildren() = emptyList<Block>()
}

View File

@ -0,0 +1,70 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.formatting.Block
import com.intellij.formatting.Indent
import com.intellij.formatting.Spacing
import com.intellij.lang.ASTNode
import com.intellij.psi.PsiComment
import com.intellij.psi.TokenType
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.formatter.common.AbstractBlock
import de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinition
import de.platon42.intellij.plugins.m68k.psi.M68kStatement
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
class M68kAsmRootBlock(node: ASTNode, private val codeStyleSettings: CodeStyleSettings) : AbstractBlock(node, null, null) {
override fun getIndent(): Indent? {
return Indent.getAbsoluteNoneIndent()
}
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
if (child2 is M68kAsmEolBlock) {
return Spacing.createSpacing(0, 0, 0, false, 0)
//return null
}
if (child2 is M68kAsmMacroDefBlock) {
return child2.getSpacing(child1, child2)
}
if (child2 is M68kAsmCommentBlock) {
if (child1 is M68kAsmStatementBlock) {
val indentSize = codeStyleSettings.indentOptions.INDENT_SIZE
val oddIdent = indentSize - (child1.node.textLength % indentSize)
return Spacing.createSpacing(oddIdent, Integer.MAX_VALUE, 0, false, 0)
} else {
return Spacing.getReadOnlySpacing()
}
}
if (child2.subBlocks.isNotEmpty()) {
return child2.getSpacing(child1, child2.subBlocks.first())
}
return null
}
override fun isLeaf(): Boolean {
return false
}
override fun buildChildren(): List<Block> {
val subBlocks = ArrayList<Block>()
var child = myNode.firstChildNode
while (child != null) {
if (child.elementType == M68kTypes.EOL) {
subBlocks.add(M68kAsmEolBlock(child))
} else if (child.elementType != TokenType.WHITE_SPACE) {
if (child.psi is M68kStatement) {
subBlocks.add(M68kAsmStatementBlock(child, codeStyleSettings))
} else if (child.psi is M68kMacroDefinition) {
subBlocks.add(M68kAsmMacroDefBlock(child, codeStyleSettings))
} else if (child.psi is PsiComment) {
subBlocks.add(M68kAsmCommentBlock(child, codeStyleSettings))
} else {
subBlocks.add(M68kAsmBlock(child, null, null, 0, codeStyleSettings))
}
}
child = child.treeNext
}
return subBlocks
}
}

View File

@ -0,0 +1,74 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.formatting.Block
import com.intellij.formatting.Indent
import com.intellij.formatting.Spacing
import com.intellij.lang.ASTNode
import com.intellij.psi.TokenType
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.formatter.common.AbstractBlock
import de.platon42.intellij.plugins.m68k.psi.*
class M68kAsmStatementBlock(node: ASTNode, private val codeStyleSettings: CodeStyleSettings) :
AbstractBlock(node, null, null) {
override fun getIndent(): Indent? {
val statement = myNode.psi as M68kStatement
if (((statement.asmInstruction != null) || (statement.asmInstruction != null) || (statement.preprocessorDirective != null)
|| (statement.macroCall != null))
&& ((statement.localLabel == null) && (statement.globalLabel == null))
) {
return null
} else {
return Indent.getAbsoluteNoneIndent()
}
}
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
if (child2 is M68kAsmBlock) {
val indentSize = codeStyleSettings.indentOptions.INDENT_SIZE * child2.column
if (child1 is M68kAsmEolBlock || child1 is M68kAsmCommentBlock) {
return Spacing.createSpacing(indentSize, indentSize, 0, true, 0)
}
if (child1 is M68kAsmLabelBlock) {
val spacesLeft = indentSize - child1.node.textLength
if (spacesLeft <= 0) {
return Spacing.createSpacing(0, 0, 1, true, 0)
} else {
return Spacing.createSpacing(spacesLeft, spacesLeft, 0, true, 0)
}
}
return Spacing.createSpacing(indentSize, indentSize, 0, true, 0)
}
if (child2 is M68kAsmLabelBlock || child2 is M68kAsmAssignmentBlock) {
return Spacing.createSpacing(0, 0, 0, true, 0)
}
return null
}
override fun isLeaf() = false
override fun buildChildren(): List<Block> {
val subBlocks = ArrayList<Block>()
var child = myNode.firstChildNode
while (child != null) {
if (child.elementType != TokenType.WHITE_SPACE) {
val element = child.psi
when (element) {
is M68kAssignment -> subBlocks.add(M68kAsmAssignmentBlock(child, null, null, codeStyleSettings))
is M68kAsmInstruction, is M68kPreprocessorDirective, is M68kMacroCall ->
subBlocks.add(M68kAsmBlock(child, null, null, 2, codeStyleSettings))
is M68kGlobalLabel, is M68kLocalLabel ->
subBlocks.add(M68kAsmLabelBlock(child, null, null, codeStyleSettings))
else -> subBlocks.add(M68kAsmBlock(child, null, null, 1, codeStyleSettings))
}
}
child = child.treeNext
}
return subBlocks
}
}

View File

@ -0,0 +1,41 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider
import de.platon42.intellij.plugins.m68k.MC68000Language
class M68kLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvider() {
override fun getLanguage() = MC68000Language.INSTANCE
override fun getCodeSample(settingsType: SettingsType) = """; This is an example assembly language program
PIC_HEIGHT = 256
include "../includes/hardware/custom.i"
BLTHOGON MACRO ; macro definition
move.w #DMAF_SETCLR|DMAF_BLITHOG,dmacon(a5) ; hog!
ENDM
demo_init ; global label
tst.w d1
beq.s .skip
PUSHM d0-d7/a0-a6 ; this is a macro call
lea hello(pc),a1
lea pd_ModViewTable(a4,d1.w),a0
moveq.l #0,d0
move.w #PIC_HEIGHT-1,d7
.loop move.l d0,(a0)+ ; local label
dbra d7,.loop
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
"""
}

View File

@ -29,7 +29,7 @@ class M68kUnresolvedReferenceInspection : AbstractBaseM68kLocalInspectionTool()
}
override fun visitSymbolReference(symbolReference: M68kSymbolReference) {
val references = symbolReference.references ?: return
val references = symbolReference.references
if (references.isEmpty()) return
val resolve = references.mapNotNull { it as? PsiPolyVariantReference }
.firstNotNullOfOrNull { it.multiResolve(false).ifEmpty { null } }

View File

@ -4,5 +4,8 @@ data class M68kLexerPrefs(
var spaceIntroducesComment: Boolean = false,
var maxLinesPerMacro: Int = 250,
var macroSectionUnparsed: Boolean = false,
var macroParametersUnparsed: Boolean = true
var macroParametersUnparsed: Boolean = true,
var maxShortDocumentationLines: Int = 5,
var maxLongDocumentationLines: Int = 100,
)

View File

@ -118,9 +118,9 @@ PLAIN_MACRO_LINE=[^;\r\n]+
if(isAsmMnemonicWithSize(yytext())) { yybegin(ASMINSTR); yypushback(2); return MNEMONIC; }
if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; }
//if(isEndDirective(yytext())) { yybegin(YYINITIAL); zzAtEOF = true; return null; }
if(isDataDirective(yytext())) { startExpr(EXPR, EXPR_OP); return DATA_DIRECTIVE; }
if(isPlainDirective(yytext())) { yybegin(PLAINPARAMS); return OTHER_DIRECTIVE; }
if(isOtherDirective(yytext())) { startExpr(EXPR, EXPR_OP); return OTHER_DIRECTIVE; }
if(isDataDirective(yytext())) { eatOneWhitespace = true; startExpr(EXPR, EXPR_OP); return DATA_DIRECTIVE; }
if(isPlainDirective(yytext())) { eatOneWhitespace = true; yybegin(PLAINPARAMS); return OTHER_DIRECTIVE; }
if(isOtherDirective(yytext())) { eatOneWhitespace = true; startExpr(EXPR, EXPR_OP); return OTHER_DIRECTIVE; }
return handleMacroMode(this);
}
{MACRONAME} { return handleMacroMode(this); }
@ -168,7 +168,6 @@ PLAIN_MACRO_LINE=[^;\r\n]+
"+" { return OP_PLUS; }
"-" { return OP_MINUS; }
"*" { yybegin(exprOpState); return CURRENT_PC_SYMBOL; }
}
<EXPR> {
@ -216,8 +215,12 @@ PLAIN_MACRO_LINE=[^;\r\n]+
"sr" { yybegin(exprOpState); return REG_SR; }
"usp" { yybegin(exprOpState); return REG_USP; }
"vbr" { yybegin(exprOpState); return REG_VBR; }
"dfc" { yybegin(exprOpState); return REG_DFC; }
"sfc" { yybegin(exprOpState); return REG_SFC; }
"#" { return HASH; }
"\[" { return SQUARE_L; }
// "\]" { return SQUARE_R; }
{SYMBOL} { yybegin(exprOpState); return SYMBOL; }
}
@ -226,6 +229,8 @@ PLAIN_MACRO_LINE=[^;\r\n]+
{OPSIZE_BS} { return OPSIZE_BS; }
{OPSIZE_W} { return OPSIZE_W; }
{OPSIZE_L} { return OPSIZE_L; }
"\[" { return SQUARE_L; }
"\]" { return SQUARE_R; }
}
<WAITEOL>

View File

@ -136,11 +136,10 @@ SymbolDefinition ::= SYMBOLDEF {
Assignment ::= SymbolDefinition COLON? (OP_ASSIGN|EQU) expr
private LabelInsts ::= LabelWithInstruction | LabelOnly | InstructionOnly
private LabelInsts ::= LabelWithInstruction | LabelOnly | Instruction
private LabelOnly ::= Label
private LabelWithInstruction ::= Label (Instruction|PreprocessorDirective)
private InstructionOnly ::= (Instruction|PreprocessorDirective)
private LabelWithInstruction ::= Label Instruction
LocalLabel ::= LOCAL_LABEL_DEF COLON? {
name = "local label"
@ -164,6 +163,7 @@ OperandSize ::= (OPSIZE_BS|OPSIZE_W|OPSIZE_L) {
name = ".s|.b|.w|.l"
methods = [getSize]
}
AddressSize ::= (OPSIZE_W|OPSIZE_L) { name = ".w|.l" }
DataWidth ::= (OPSIZE_W|OPSIZE_L) { name = ".w|.l" }
@ -198,7 +198,7 @@ MacroCall ::= MACRO_INVOCATION PlainOperands? {
}
AsmInstruction ::= AsmOp AsmOperands?
private Instruction ::= AsmInstruction | MacroCall
private Instruction ::= AsmInstruction | MacroCall | PreprocessorDirective
//external Instruction ::= parseMacroCallOrAsmInstruction
private AsmOperands ::= AddressingMode (SEPARATOR AddressingMode)?
@ -227,7 +227,7 @@ AddressRegister ::= AREG | REG_SP {
extends = Register
}
SpecialRegister ::= REG_CCR | REG_SR | REG_USP | REG_VBR {
SpecialRegister ::= REG_CCR | REG_SR | REG_USP | REG_VBR | REG_SFC | REG_DFC {
name = "special register"
extends = Register
}
@ -236,14 +236,26 @@ Register ::= DataRegister | AddressRegister | SpecialRegister
private DataOrAddressRegister ::= DataRegister | AddressRegister { name = "data or address register"}
IndexRegister ::= DataOrAddressRegister DataWidth?
BaseDisplacement ::= expr DataWidth?
OuterDisplacement ::= expr DataWidth?
IndexRegister ::= DataOrAddressRegister DataWidth? (OP_AR_MUL IndexScale)?
{
name = "index register"
methods = [
indexRegister = "DataOrAddressRegister"
isLongWidth
]
}
IndexScale ::= expr
{
name = "scale value"
methods = [
indexScale = "expr"
]
}
AddressingMode ::= ImmediateData
| AddressRegisterIndirectPreDecAddressingMode
| AddressRegisterIndirectPostIncAddressingMode
@ -256,6 +268,14 @@ AddressingMode ::= ImmediateData
| ProgramCounterIndirectWithDisplacementOldAddressingMode
| AddressRegisterIndirectWithIndexOldAddressingMode
| ProgramCounterIndirectWithIndexOldAddressingMode
| AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode
| ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode
| MemoryIndirectAddressingMode
| ProgramCounterMemoryIndirectAddressingMode
| MemoryIndirectPostIndexedAddressingMode
| ProgramCounterMemoryIndirectPostIndexedAddressingMode
| MemoryIndirectPreIndexedAddressingMode
| ProgramCounterMemoryIndirectPreIndexedAddressingMode
| SpecialRegisterDirectAddressingMode
| DataRegisterDirectAddressingMode
| AddressRegisterDirectAddressingMode
@ -268,6 +288,7 @@ AddressRegisterDirectAddressingMode ::= AddressRegister !(OP_MINUS|OP_AR_DIV)
AddressRegisterIndirectAddressingMode ::= ROUND_L AddressRegister ROUND_R !OP_PLUS { implements = "de.platon42.intellij.plugins.m68k.psi.M68kWithAddressRegisterIndirect" }
AddressRegisterIndirectPostIncAddressingMode ::= ROUND_L AddressRegister ROUND_R OP_PLUS { implements = "de.platon42.intellij.plugins.m68k.psi.M68kWithAddressRegisterIndirect" }
AddressRegisterIndirectPreDecAddressingMode ::= OP_MINUS ROUND_L AddressRegister ROUND_R { implements = "de.platon42.intellij.plugins.m68k.psi.M68kWithAddressRegisterIndirect" }
AddressRegisterIndirectWithDisplacementOldAddressingMode ::= expr ROUND_L AddressRegister ROUND_R
{
implements = [
@ -278,6 +299,7 @@ AddressRegisterIndirectWithDisplacementOldAddressingMode ::= expr ROUND_L Addres
displacement = "expr"
]
}
AddressRegisterIndirectWithDisplacementNewAddressingMode ::= ROUND_L expr SEPARATOR AddressRegister ROUND_R
{
implements = [
@ -313,6 +335,77 @@ AddressRegisterIndirectWithIndexNewAddressingMode ::= ROUND_L (expr SEPARATOR)?
]
}
private internalBaseDisplacementOption1 ::= (BaseDisplacement SEPARATOR)? (AddressRegister SEPARATOR)? IndexRegister
private internalBaseDisplacementOption2 ::= (BaseDisplacement SEPARATOR)? AddressRegister (SEPARATOR IndexRegister)?
private internalBaseDisplacementOption3 ::= BaseDisplacement (SEPARATOR AddressRegister)? (SEPARATOR IndexRegister)?
AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode ::= ROUND_L (internalBaseDisplacementOption1|internalBaseDisplacementOption2|internalBaseDisplacementOption3)? ROUND_R
{
implements = [
"de.platon42.intellij.plugins.m68k.psi.M68kWithOptionalAddressRegisterIndirect"
"de.platon42.intellij.plugins.m68k.psi.M68kWithBaseDisplacement"
"de.platon42.intellij.plugins.m68k.psi.M68kWithOptionalIndexRegister"
]
methods = [
baseDisplacement = "BaseDisplacement"
]
}
ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode ::= ROUND_L (BaseDisplacement SEPARATOR)? PC (SEPARATOR IndexRegister)? ROUND_R
{
implements = [
"de.platon42.intellij.plugins.m68k.psi.M68kWithBaseDisplacement"
"de.platon42.intellij.plugins.m68k.psi.M68kWithOptionalIndexRegister"
]
methods = [
baseDisplacement = "BaseDisplacement"
]
}
MemoryIndirectAddressingMode ::= ROUND_L SQUARE_L (BaseDisplacement SEPARATOR)? AddressRegister SQUARE_R (SEPARATOR OuterDisplacement)? ROUND_R
{
implements = [
"de.platon42.intellij.plugins.m68k.psi.M68kWithAddressRegisterIndirect"
"de.platon42.intellij.plugins.m68k.psi.M68kWithBaseDisplacement"
"de.platon42.intellij.plugins.m68k.psi.M68kWithOuterDisplacement"
]
methods = [
baseDisplacement = "BaseDisplacement"
outerDisplacement = "OuterDisplacement"
]
}
private internalMemoryIndirectPostIndexedOption1 ::= (BaseDisplacement SEPARATOR)? AddressRegister
private internalMemoryIndirectPostIndexedOption2 ::= BaseDisplacement (SEPARATOR AddressRegister)?
MemoryIndirectPostIndexedAddressingMode ::= ROUND_L (SQUARE_L (internalMemoryIndirectPostIndexedOption1|internalMemoryIndirectPostIndexedOption2) SQUARE_R SEPARATOR)? IndexRegister (SEPARATOR OuterDisplacement)? ROUND_R
{
implements = [
"de.platon42.intellij.plugins.m68k.psi.M68kWithOptionalAddressRegisterIndirect"
"de.platon42.intellij.plugins.m68k.psi.M68kWithBaseDisplacement"
"de.platon42.intellij.plugins.m68k.psi.M68kWithIndexRegister"
"de.platon42.intellij.plugins.m68k.psi.M68kWithOuterDisplacement"
]
methods = [
baseDisplacement = "BaseDisplacement"
outerDisplacement = "OuterDisplacement"
]
}
MemoryIndirectPreIndexedAddressingMode ::= ROUND_L SQUARE_L (BaseDisplacement SEPARATOR)? (AddressRegister SEPARATOR)? IndexRegister SQUARE_R (SEPARATOR OuterDisplacement)? ROUND_R
{
implements = [
"de.platon42.intellij.plugins.m68k.psi.M68kWithOptionalAddressRegisterIndirect"
"de.platon42.intellij.plugins.m68k.psi.M68kWithBaseDisplacement"
"de.platon42.intellij.plugins.m68k.psi.M68kWithIndexRegister"
"de.platon42.intellij.plugins.m68k.psi.M68kWithOuterDisplacement"
]
methods = [
baseDisplacement = "BaseDisplacement"
outerDisplacement = "OuterDisplacement"
]
}
ProgramCounterIndirectWithDisplacementOldAddressingMode ::= (ROUND_L PC ROUND_R) | (expr ROUND_L PC ROUND_R)
{
implements = ["de.platon42.intellij.plugins.m68k.psi.M68kWithDisplacement"]
@ -351,6 +444,44 @@ ProgramCounterIndirectWithIndexNewAddressingMode ::= ROUND_L (expr SEPARATOR)? P
]
}
ProgramCounterMemoryIndirectAddressingMode ::= ROUND_L SQUARE_L (BaseDisplacement SEPARATOR)? PC SQUARE_R (SEPARATOR OuterDisplacement)? ROUND_R
{
implements = [
"de.platon42.intellij.plugins.m68k.psi.M68kWithBaseDisplacement"
"de.platon42.intellij.plugins.m68k.psi.M68kWithOuterDisplacement"
]
methods = [
baseDisplacement = "BaseDisplacement"
outerDisplacement = "OuterDisplacement"
]
}
ProgramCounterMemoryIndirectPostIndexedAddressingMode ::= ROUND_L (SQUARE_L (BaseDisplacement SEPARATOR)? PC SQUARE_R SEPARATOR)? IndexRegister (SEPARATOR OuterDisplacement)? ROUND_R
{
implements = [
"de.platon42.intellij.plugins.m68k.psi.M68kWithBaseDisplacement"
"de.platon42.intellij.plugins.m68k.psi.M68kWithIndexRegister"
"de.platon42.intellij.plugins.m68k.psi.M68kWithOuterDisplacement"
]
methods = [
baseDisplacement = "BaseDisplacement"
outerDisplacement = "OuterDisplacement"
]
}
ProgramCounterMemoryIndirectPreIndexedAddressingMode ::= ROUND_L SQUARE_L (BaseDisplacement SEPARATOR)? PC SEPARATOR IndexRegister SQUARE_R (SEPARATOR OuterDisplacement)? ROUND_R
{
implements = [
"de.platon42.intellij.plugins.m68k.psi.M68kWithBaseDisplacement"
"de.platon42.intellij.plugins.m68k.psi.M68kWithIndexRegister"
"de.platon42.intellij.plugins.m68k.psi.M68kWithOuterDisplacement"
]
methods = [
baseDisplacement = "BaseDisplacement"
outerDisplacement = "OuterDisplacement"
]
}
AbsoluteAddressAddressingMode ::= expr AddressSize? !ROUND_L
RegisterRange ::= (DataRegister OP_MINUS DataRegister) | (AddressRegister OP_MINUS AddressRegister) | (DataRegister OP_MINUS AddressRegister) {

View File

@ -0,0 +1,75 @@
package de.platon42.intellij.plugins.m68k.navigation
import com.intellij.ide.navigationToolbar.AbstractNavBarModelExtension
import com.intellij.ide.ui.UISettings
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.project.IndexNotReadyException
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import de.platon42.intellij.plugins.m68k.M68kIcons
import de.platon42.intellij.plugins.m68k.MC68000Language
import de.platon42.intellij.plugins.m68k.psi.*
import de.platon42.intellij.plugins.m68k.psi.utils.M68kPsiWalkUtil.findStatementForElement
import org.jetbrains.annotations.Nullable
import javax.swing.Icon
class M68kStructureAwareNavbar : AbstractNavBarModelExtension() {
override fun getLeafElement(dataContext: DataContext): PsiElement? {
if (UISettings.getInstance().showMembersInNavigationBar) {
val psiFile = CommonDataKeys.PSI_FILE.getData(dataContext)
val editor = CommonDataKeys.EDITOR.getData(dataContext)
if (psiFile == null || !psiFile.isValid || editor == null) return null
val psiElement = psiFile.findElementAt(editor.caretModel.offset)
if (isAcceptableLanguage(psiElement)) {
try {
var statement = findStatementForElement(psiElement!!) ?: return null
do {
if (statement.localLabel != null) return statement.localLabel
if (statement.globalLabel != null) return statement.globalLabel
statement = PsiTreeUtil.getPrevSiblingOfType(statement, M68kStatement::class.java) ?: return null
} while (true)
} catch (ignored: IndexNotReadyException) {
}
}
}
return null
}
private fun isAcceptableLanguage(psiElement: @Nullable PsiElement?) = psiElement?.language == MC68000Language.INSTANCE
override fun getPresentableText(obj: Any?): String? {
return when (obj) {
is M68kFile -> obj.name
is M68kGlobalLabel -> obj.name
is M68kLocalLabel -> obj.name
is M68kSymbolDefinition -> obj.name
is M68kMacroDefinition -> obj.macroNameDefinition.text
else -> null
}
}
override fun getParent(psiElement: PsiElement): PsiElement? {
if (!isAcceptableLanguage(psiElement)) return null
var statement = findStatementForElement(psiElement) ?: return null
if (statement.localLabel != null) {
do {
if (statement.globalLabel != null) return statement.globalLabel
statement = PsiTreeUtil.getPrevSiblingOfType(statement, M68kStatement::class.java) ?: return null
} while (true)
}
return psiElement.containingFile
}
override fun getIcon(obj: Any?): Icon? {
return when (obj) {
is M68kFile -> M68kIcons.FILE
is M68kGlobalLabel -> M68kIcons.GLOBAL_LABEL
is M68kLocalLabel -> M68kIcons.LOCAL_LABEL
is M68kSymbolDefinition -> M68kIcons.SYMBOL_DEF
is M68kMacroDefinition -> M68kIcons.MACRO_DEF
else -> null
}
}
}

View File

@ -10,15 +10,14 @@ import de.platon42.intellij.plugins.m68k.lexer.M68kLexer
import de.platon42.intellij.plugins.m68k.lexer.M68kLexerPrefs
import de.platon42.intellij.plugins.m68k.psi.M68kFile
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
import de.platon42.intellij.plugins.m68k.settings.M68kProjectSettings
import de.platon42.intellij.plugins.m68k.stubs.M68kElementTypes
class M68kParserDefinition : ParserDefinition {
val lexerPrefs = M68kLexerPrefs() // TODO make this configurable
override fun createLexer(project: Project): Lexer {
// TODO take prefs from project somehow
return M68kLexer(lexerPrefs)
val settings = project.getService(M68kProjectSettings::class.java)
return M68kLexer(settings?.settings ?: M68kLexerPrefs())
}
override fun createParser(project: Project) = M68kParser()

View File

@ -12,12 +12,20 @@ object M68kAddressModeUtil {
is M68kAddressRegisterIndirectPreDecAddressingMode -> AddressMode.ADDRESS_REGISTER_INDIRECT_PRE_DEC
is M68kAddressRegisterIndirectWithDisplacementNewAddressingMode -> AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT
is M68kAddressRegisterIndirectWithDisplacementOldAddressingMode -> AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT
is M68kAddressRegisterIndirectWithIndexNewAddressingMode -> AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_INDEX
is M68kAddressRegisterIndirectWithIndexOldAddressingMode -> AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_INDEX
is M68kAddressRegisterIndirectWithIndexNewAddressingMode -> if (hasScale(addressingMode)) AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_SCALED_INDEX else AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_INDEX
is M68kAddressRegisterIndirectWithIndexOldAddressingMode -> if (hasScale(addressingMode)) AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_SCALED_INDEX else AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_INDEX
is M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingMode -> AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_BASE_DISPLACEMENT
is M68kProgramCounterIndirectWithDisplacementNewAddressingMode -> AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT
is M68kProgramCounterIndirectWithDisplacementOldAddressingMode -> AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT
is M68kProgramCounterIndirectWithIndexNewAddressingMode -> AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_INDEX
is M68kProgramCounterIndirectWithIndexOldAddressingMode -> AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_INDEX
is M68kProgramCounterIndirectWithIndexNewAddressingMode -> if (hasScale(addressingMode)) AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_SCALED_INDEX else AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_INDEX
is M68kProgramCounterIndirectWithIndexOldAddressingMode -> if (hasScale(addressingMode)) AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_SCALED_INDEX else AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_INDEX
is M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingMode -> AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_BASE_DISPLACEMENT
is M68kMemoryIndirectAddressingMode -> AddressMode.MEMORY_INDIRECT
is M68kMemoryIndirectPreIndexedAddressingMode -> AddressMode.MEMORY_INDIRECT_PREINDEXED
is M68kMemoryIndirectPostIndexedAddressingMode -> AddressMode.MEMORY_INDIRECT_POSTINDEXED
is M68kProgramCounterMemoryIndirectAddressingMode -> AddressMode.PROGRAM_COUNTER_MEMORY_INDIRECT
is M68kProgramCounterMemoryIndirectPreIndexedAddressingMode -> AddressMode.PROGRAM_COUNTER_MEMORY_INDIRECT_PREINDEXED
is M68kProgramCounterMemoryIndirectPostIndexedAddressingMode -> AddressMode.PROGRAM_COUNTER_MEMORY_INDIRECT_POSTINDEXED
is M68kSpecialRegisterDirectAddressingMode -> AddressMode.SPECIAL_REGISTER_DIRECT
is M68kDataRegisterDirectAddressingMode -> AddressMode.DATA_REGISTER_DIRECT
is M68kAddressRegisterDirectAddressingMode -> AddressMode.ADDRESS_REGISTER_DIRECT
@ -27,6 +35,9 @@ object M68kAddressModeUtil {
}
}
// TODO add evaluation of constant expressions and allow scale == 1 as false
private fun hasScale(addressingMode: M68kWithIndexRegister) = addressingMode.indexRegister.indexScale != null
fun getOtherReadWriteModifyRegisters(rwm: Int): List<Pair<Register, Int>> {
if (rwm and RWM_MODIFY_STACK > 0) {
return listOf(Register.A7 to RWM_MODIFY_L)
@ -37,29 +48,20 @@ object M68kAddressModeUtil {
fun getReadWriteModifyRegisters(addressingMode: M68kAddressingMode?, rwm: Int): List<Pair<Register, Int>> {
if (addressingMode == null) return emptyList()
return when (addressingMode) {
is M68kImmediateData,
is M68kSpecialRegisterDirectAddressingMode,
is M68kProgramCounterIndirectWithDisplacementNewAddressingMode,
is M68kProgramCounterIndirectWithDisplacementOldAddressingMode,
is M68kAbsoluteAddressAddressingMode -> emptyList()
is M68kAddressRegisterIndirectPostIncAddressingMode -> listOf(Register.getRegFromName(addressingMode.addressRegister.text) to (RWM_READ_L or RWM_MODIFY_L))
is M68kAddressRegisterIndirectPreDecAddressingMode -> listOf(Register.getRegFromName(addressingMode.addressRegister.text) to (RWM_READ_L or RWM_MODIFY_L))
is M68kWithAddressRegisterIndirect -> {
if (addressingMode is M68kWithIndexRegister) {
listOf(
Register.getRegFromName(addressingMode.addressRegister.text) to RWM_READ_L,
Register.getRegFromName(addressingMode.indexRegister.register.text) to if (addressingMode.indexRegister.isLongWidth) RWM_READ_L else RWM_READ_W
)
} else {
listOf(Register.getRegFromName(addressingMode.addressRegister.text) to RWM_READ_L)
}
}
is M68kWithIndexRegister -> listOf(Register.getRegFromName(addressingMode.indexRegister.register.text) to if (addressingMode.indexRegister.isLongWidth) RWM_READ_L else RWM_READ_W)
is M68kWithAddressRegisterIndirect -> listOf(Register.getRegFromName(addressingMode.addressRegister.text) to RWM_READ_L)
is M68kWithOptionalAddressRegisterIndirect -> if (addressingMode.addressRegister != null) listOf(Register.getRegFromName(addressingMode.addressRegister!!.text) to RWM_READ_L) else emptyList()
is M68kDataRegisterDirectAddressingMode -> listOf(Register.getRegFromName(addressingMode.dataRegister.text) to rwm)
is M68kAddressRegisterDirectAddressingMode -> listOf(Register.getRegFromName(addressingMode.addressRegister.text) to rwm)
is M68kRegisterListAddressingMode -> addressingMode.registers.map { it to rwm }
else -> throw IllegalArgumentException("Unknown addressing mode $addressingMode")
}
else -> emptyList()
}.plus(
when (addressingMode) {
is M68kWithIndexRegister -> listOf(Register.getRegFromName(addressingMode.indexRegister.register.text) to if (addressingMode.indexRegister.isLongWidth) RWM_READ_L else RWM_READ_W)
is M68kWithOptionalIndexRegister -> if (addressingMode.indexRegister != null) listOf(Register.getRegFromName(addressingMode.indexRegister!!.register.text) to if (addressingMode.indexRegister!!.isLongWidth) RWM_READ_L else RWM_READ_W) else emptyList()
else -> emptyList()
}
)
}
}

View File

@ -105,7 +105,7 @@ object M68kPsiImplUtil {
// OperandSize
@JvmStatic
fun getSize(element: M68kOperandSize): Int =
when (element.text) {
when (element.text?.lowercase()) {
null -> OP_UNSIZED
".w" -> OP_SIZE_W
".l" -> OP_SIZE_L

View File

@ -0,0 +1,6 @@
package de.platon42.intellij.plugins.m68k.psi
interface M68kWithBaseDisplacement : M68kAddressingMode {
val baseDisplacement: M68kBaseDisplacement?
}

View File

@ -0,0 +1,6 @@
package de.platon42.intellij.plugins.m68k.psi
interface M68kWithOptionalAddressRegisterIndirect : M68kAddressingMode {
val addressRegister: M68kAddressRegister?
}

View File

@ -0,0 +1,6 @@
package de.platon42.intellij.plugins.m68k.psi
interface M68kWithOptionalIndexRegister : M68kAddressingMode {
val indexRegister: M68kIndexRegister?
}

View File

@ -0,0 +1,6 @@
package de.platon42.intellij.plugins.m68k.psi
interface M68kWithOuterDisplacement : M68kAddressingMode {
val outerDisplacement: M68kOuterDisplacement?
}

View File

@ -1,9 +1,10 @@
package de.platon42.intellij.plugins.m68k.psi
package de.platon42.intellij.plugins.m68k.psi.utils
import com.intellij.openapi.project.Project
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.stubs.StubIndex
import com.intellij.psi.util.PsiTreeUtil
import de.platon42.intellij.plugins.m68k.psi.*
import de.platon42.intellij.plugins.m68k.stubs.M68kGlobalLabelStubIndex
import de.platon42.intellij.plugins.m68k.stubs.M68kMacroDefinitionStubIndex
import de.platon42.intellij.plugins.m68k.stubs.M68kSymbolDefinitionStubIndex

View File

@ -0,0 +1,25 @@
package de.platon42.intellij.plugins.m68k.psi.utils
import de.platon42.intellij.plugins.m68k.psi.M68kMacroCall
import de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinition
object M68kMacroExpansionUtil {
fun expandMacro(macroDefinition: M68kMacroDefinition, macroCall: M68kMacroCall?): List<String> {
val params = macroCall?.exprList?.map { it.text }?.toTypedArray() ?: emptyArray()
if (params.isEmpty()) return macroDefinition.macroPlainLineList.map { it.text }
val originalContent = macroDefinition.macroPlainLineList.joinToString("\n", transform = { it.text })
var modifiedContent = originalContent
for (param in params.withIndex()) {
val paramRef = when (param.index) {
in 0..8 -> "\\" + (param.index + 1)
in 9..34 -> "\\" + ('a' + (param.index - 9))
else -> "seriously?"
}
modifiedContent = modifiedContent.replace(paramRef, param.value)
}
return modifiedContent.split("\n")
}
}

View File

@ -0,0 +1,67 @@
package de.platon42.intellij.plugins.m68k.psi.utils
import com.intellij.psi.PsiComment
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.SmartList
import com.intellij.util.containers.addIfNotNull
import de.platon42.intellij.plugins.m68k.psi.M68kFile
import de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinition
import de.platon42.intellij.plugins.m68k.psi.M68kStatement
object M68kPsiWalkUtil {
fun collectRelatedComments(element: PsiElement): List<PsiComment> {
val comments = SmartList<PsiComment>()
val eolComment = if (element is M68kMacroDefinition) {
// macro definition needs special handling of EOL comments
PsiTreeUtil.findChildOfType(element, PsiComment::class.java)
} else {
PsiTreeUtil.skipWhitespacesForward(element) as? PsiComment
}
comments.addIfNotNull(eolComment)
var prevToken: PsiElement? = element
do {
prevToken = PsiTreeUtil.skipWhitespacesBackward(prevToken)
if (prevToken !is PsiComment) break
comments.add(prevToken)
} while (true)
return comments.reversed()
}
fun getBeginningOfRelatedComment(lineElement: PsiElement): PsiElement {
// go back to catch comments that are not more than one empty line away
var relStart = lineElement
var prevLine = relStart.prevSibling ?: return lineElement
var eolCount = 2
do {
if (prevLine is PsiComment) {
relStart = prevLine
eolCount = 1
} else if (prevLine is PsiWhiteSpace) {
if (--eolCount < 0) break
} else {
break
}
prevLine = prevLine.prevSibling ?: break
} while (true)
return relStart
}
fun isSignificantLine(element: PsiElement) = when (element) {
is M68kStatement -> (element.assignment != null) || (element.globalLabel != null)
is M68kMacroDefinition -> true
else -> false
}
fun findStatementForElement(psiElement: PsiElement): M68kStatement? {
if (psiElement is M68kStatement) return psiElement
if (psiElement.parent is M68kFile) {
return PsiTreeUtil.getPrevSiblingOfType(psiElement, M68kStatement::class.java)
}
return PsiTreeUtil.getParentOfType(psiElement, M68kStatement::class.java);
}
}

View File

@ -6,8 +6,8 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.patterns.PlatformPatterns
import com.intellij.util.ProcessingContext
import de.platon42.intellij.plugins.m68k.M68kIcons
import de.platon42.intellij.plugins.m68k.psi.M68kLookupUtil
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
import de.platon42.intellij.plugins.m68k.psi.utils.M68kLookupUtil
class M68kGlobalLabelSymbolCompletionContributor : CompletionContributor() {

View File

@ -32,7 +32,7 @@ class M68kLocalLabelDefCompletionContributor : CompletionContributor() {
}
referencedLocalLabels.removeAll(definedLocalLabels)
resultSet.addAllElements(
if (parameters.originalPosition?.text == ".") {
if (parameters.originalPosition?.text?.startsWith(".") == true) {
referencedLocalLabels.map { LookupElementBuilder.create(it.removePrefix(".")) }
} else {
referencedLocalLabels.map(LookupElementBuilder::create)

View File

@ -4,8 +4,8 @@ import com.intellij.codeInsight.completion.*
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.patterns.PlatformPatterns
import com.intellij.util.ProcessingContext
import de.platon42.intellij.plugins.m68k.psi.M68kLookupUtil
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
import de.platon42.intellij.plugins.m68k.psi.utils.M68kLookupUtil
class M68kMacroCallCompletionContributor : CompletionContributor() {

View File

@ -0,0 +1,19 @@
package de.platon42.intellij.plugins.m68k.settings
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.openapi.components.StoragePathMacros
import de.platon42.intellij.plugins.m68k.lexer.M68kLexerPrefs
@State(name = "M68k.Settings", storages = [Storage(StoragePathMacros.WORKSPACE_FILE)])
class M68kProjectSettings : PersistentStateComponent<M68kLexerPrefs> {
var settings: M68kLexerPrefs = M68kLexerPrefs()
override fun getState() = settings
override fun loadState(state: M68kLexerPrefs) {
settings = state
}
}

View File

@ -0,0 +1,91 @@
package de.platon42.intellij.plugins.m68k.settings
import com.intellij.openapi.options.Configurable
import com.intellij.openapi.options.ConfigurationException
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.NlsContexts.ConfigurableName
import com.intellij.ui.components.JBCheckBox
import com.intellij.uiDesigner.core.Spacer
import com.intellij.util.ui.FormBuilder
import com.intellij.util.ui.UIUtil
import de.platon42.intellij.plugins.m68k.lexer.M68kLexerPrefs
import java.text.NumberFormat
import java.text.ParseException
import javax.swing.JComponent
import javax.swing.JFormattedTextField
import javax.swing.JLabel
import javax.swing.text.DefaultFormatterFactory
import javax.swing.text.NumberFormatter
class M68kProjectSettingsConfigurable(project: Project?) : Configurable {
private val settings = project?.getService(M68kProjectSettings::class.java)
private val spacesOptionField = JBCheckBox("Space introduces comment (-spaces)", settings?.settings?.spaceIntroducesComment ?: false)
private val maxLinesPerMacroField = createNumberField(settings?.settings?.maxLinesPerMacro)
private val maxShortDocumentationLinesField = createNumberField(settings?.settings?.maxShortDocumentationLines)
private val maxLongDocumentationLinesField = createNumberField(settings?.settings?.maxLongDocumentationLines)
override fun getDisplayName(): @ConfigurableName String = "M68k"
override fun createComponent(): JComponent? {
return FormBuilder.createFormBuilder()
.setAlignLabelOnRight(false)
.setHorizontalGap(UIUtil.DEFAULT_HGAP)
.setVerticalGap(UIUtil.DEFAULT_VGAP)
.addComponent(spacesOptionField)
.addLabeledComponent(JLabel("Maximum lines parsed inside macro"), maxLinesPerMacroField)
.addSeparator()
.addLabeledComponent(JLabel("Lines of code in hovered documentation"), maxShortDocumentationLinesField)
.addLabeledComponent(JLabel("Lines of code in full documentation"), maxLongDocumentationLinesField)
.addComponentFillVertically(Spacer(), 0)
.panel
}
private fun createNumberField(value: Any?): JFormattedTextField {
val valueField = JFormattedTextField()
valueField.columns = 4
val formatter = NumberFormat.getIntegerInstance()
formatter.isParseIntegerOnly = true
valueField.formatterFactory = DefaultFormatterFactory(NumberFormatter(formatter))
valueField.value = value
return valueField
}
override fun isModified(): Boolean {
val prefs = settings?.settings ?: return false
return prefs.spaceIntroducesComment != spacesOptionField.isSelected
|| fieldDiffers(maxLinesPerMacroField, prefs.maxLinesPerMacro)
|| fieldDiffers(maxShortDocumentationLinesField, prefs.maxShortDocumentationLines)
|| fieldDiffers(maxLongDocumentationLinesField, prefs.maxLongDocumentationLines)
}
@Throws(ConfigurationException::class)
override fun apply() {
val prefs = settings?.settings ?: return
prefs.spaceIntroducesComment = spacesOptionField.isSelected
getFieldValue(maxLinesPerMacroField).let { if (it != null) prefs.maxLinesPerMacro = it }
getFieldValue(maxShortDocumentationLinesField).let { if (it != null) prefs.maxShortDocumentationLines = it }
getFieldValue(maxLongDocumentationLinesField).let { if (it != null) prefs.maxLongDocumentationLines = it }
}
private fun fieldDiffers(field: JFormattedTextField, value: Int?): Boolean {
val fieldValue = getFieldValue(field)
return (fieldValue != null) && (value != null) && (fieldValue != value)
}
private fun getFieldValue(field: JFormattedTextField): Int? {
return try {
val value = field.value
(value as Number).toInt()
} catch (ex: ParseException) {
null
}
}
override fun reset() {
settings?.settings = M68kLexerPrefs()
}
}

View File

@ -6,8 +6,8 @@ import com.intellij.navigation.ItemPresentation
import com.intellij.psi.NavigatablePsiElement
import de.platon42.intellij.plugins.m68k.psi.M68kFile
import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabel
import de.platon42.intellij.plugins.m68k.psi.M68kLookupUtil
import de.platon42.intellij.plugins.m68k.psi.M68kLookupUtil.findAllLocalLabels
import de.platon42.intellij.plugins.m68k.psi.utils.M68kLookupUtil
import de.platon42.intellij.plugins.m68k.psi.utils.M68kLookupUtil.findAllLocalLabels
class M68kStructureViewElement(private val myElement: NavigatablePsiElement) : StructureViewTreeElement {
override fun getValue(): Any = myElement

View File

@ -1,11 +1,13 @@
package de.platon42.intellij.plugins.m68k.syntax
import com.intellij.codeHighlighting.RainbowHighlighter
import com.intellij.openapi.editor.colors.TextAttributesKey
import com.intellij.openapi.fileTypes.SyntaxHighlighter
import com.intellij.openapi.options.colors.AttributesDescriptor
import com.intellij.openapi.options.colors.ColorDescriptor
import com.intellij.openapi.options.colors.ColorSettingsPage
import com.intellij.openapi.options.colors.RainbowColorSettingsPage
import de.platon42.intellij.plugins.m68k.M68kIcons.FILE
import de.platon42.intellij.plugins.m68k.MC68000Language
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.AREG
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.BAD_CHARACTER
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.COLON
@ -34,7 +36,9 @@ import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.
import org.jetbrains.annotations.NonNls
import javax.swing.Icon
class M68kColorSettingsPage : ColorSettingsPage {
class M68kColorSettingsPage : RainbowColorSettingsPage {
override fun getLanguage() = MC68000Language.INSTANCE
override fun getIcon(): Icon {
return FILE
@ -49,6 +53,8 @@ class M68kColorSettingsPage : ColorSettingsPage {
return """; This is an example assembly language program
PIC_HEIGHT = 256
* Semantic highlighting is available for registers and local labels
include "../includes/hardware/custom.i"
BLTHOGON MACRO ; macro definition
@ -80,23 +86,21 @@ hello: dc.b 'Hello World!',10,0
"""
}
override fun getAdditionalHighlightingTagToDescriptorMap(): Map<String, TextAttributesKey>? {
return null
override fun getAdditionalHighlightingTagToDescriptorMap(): Map<String, TextAttributesKey> {
return RainbowHighlighter.createRainbowHLM()
}
override fun getAttributeDescriptors(): Array<AttributesDescriptor> {
return DESCRIPTORS
}
override fun isRainbowType(type: TextAttributesKey) = RAINBOW_TYPES.contains(type)
override fun getColorDescriptors(): Array<ColorDescriptor> {
return ColorDescriptor.EMPTY_ARRAY
}
override fun getAttributeDescriptors() = DESCRIPTORS
override fun getDisplayName(): String {
return "M68k Assembly"
}
override fun getColorDescriptors() = ColorDescriptor.EMPTY_ARRAY
override fun getDisplayName() = "M68k Assembly"
companion object {
private val RAINBOW_TYPES = setOf(AREG, DREG, LOCAL_LABEL)
private val DESCRIPTORS = arrayOf(
AttributesDescriptor("Global labels", GLOBAL_LABEL),
AttributesDescriptor("Local labels", LOCAL_LABEL),

View File

@ -0,0 +1,28 @@
package de.platon42.intellij.plugins.m68k.syntax
import com.intellij.codeInsight.daemon.RainbowVisitor
import com.intellij.codeInsight.daemon.impl.HighlightVisitor
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegister
import de.platon42.intellij.plugins.m68k.psi.M68kDataRegister
import de.platon42.intellij.plugins.m68k.psi.M68kFile
import de.platon42.intellij.plugins.m68k.psi.M68kLocalLabel
class M68kRainbowVisitor : RainbowVisitor() {
override fun suitableForFile(file: PsiFile): Boolean = file is M68kFile
override fun visit(element: PsiElement) {
when (element) {
is M68kAddressRegister -> addInfo(getInfo(element.containingFile, element, element.text, M68kSyntaxHighlighter.AREG))
is M68kDataRegister -> addInfo(getInfo(element.containingFile, element, element.text, M68kSyntaxHighlighter.DREG))
// is M68kGlobalLabel -> addInfo(getInfo(element.containingFile, element, element.text, M68kSyntaxHighlighter.GLOBAL_LABEL))
is M68kLocalLabel -> addInfo(getInfo(element.containingFile, element, element.text, M68kSyntaxHighlighter.LOCAL_LABEL))
// is M68kMacroCall -> addInfo(getInfo(element.containingFile, element.firstChild, element.macroName, M68kSyntaxHighlighter.MACRO_CALL))
}
}
override fun clone(): HighlightVisitor = M68kRainbowVisitor()
}

View File

@ -11,15 +11,13 @@ import com.intellij.psi.tree.IElementType
import de.platon42.intellij.plugins.m68k.lexer.M68kLexer
import de.platon42.intellij.plugins.m68k.lexer.M68kLexerPrefs
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
import de.platon42.intellij.plugins.m68k.settings.M68kProjectSettings
class M68kSyntaxHighlighter(val project: Project?) : SyntaxHighlighterBase() {
private val settings = project?.getService(M68kProjectSettings::class.java)
override fun getHighlightingLexer(): Lexer {
if (project == null) {
return M68kLexer(M68kLexerPrefs()) // Use some defaults
} else {
// FIXME Where do we get the prefs from?
return M68kLexer(M68kLexerPrefs())
}
return M68kLexer(settings?.settings ?: M68kLexerPrefs()) // Use some defaults
}
override fun getTokenHighlights(tokenType: IElementType): Array<TextAttributesKey> {
@ -44,7 +42,7 @@ class M68kSyntaxHighlighter(val project: Project?) : SyntaxHighlighterBase() {
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.REG_USP, M68kTypes.REG_SR, M68kTypes.REG_CCR, M68kTypes.REG_VBR, M68kTypes.REG_SFC, M68kTypes.REG_DFC -> arrayOf(SPECIAL_REG)
M68kTypes.COMMENT -> arrayOf(COMMENT)
M68kTypes.DECIMAL, M68kTypes.HEXADECIMAL, M68kTypes.OCTAL -> arrayOf(NUMBER)
M68kTypes.STRINGLIT -> arrayOf(STRING)

View File

@ -1,14 +1,14 @@
<idea-plugin>
<id>de.platon42.m68k</id>
<name>MC68000 Assembly Language Support</name>
<vendor email="chrisly@platon42.de" url="https://github.com/chrisly42/mc68000-asm-plugin">Chris 'platon42' Hodges
<vendor email="chrisly@platon42.de" url="https://git.platon42.de/chrisly42/mc68000-asm-plugin">Chris 'platon42' Hodges
</vendor>
<description><![CDATA[
MC68000 Assembly Language Plugin adds language support for Motorola 68000 (M68k) assembly language files (asm).
It provides syntax highlighting and refactoring possibilities among other things.
<p>
<a href="https://github.com/chrisly42/mc68000-asm-plugin/blob/main/README.md">Full documentation here...</a>
<a href="https://git.platon42.de/chrisly42/mc68000-asm-plugin/blob/main/README.md">Full documentation here...</a>
]]></description>
<idea-version since-build="203.5981.166"/>
@ -21,8 +21,17 @@
implementationClass="de.platon42.intellij.plugins.m68k.parser.M68kParserDefinition"/>
<lang.syntaxHighlighterFactory language="MC68000"
implementationClass="de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighterFactory"/>
<lang.foldingBuilder language="MC68000"
implementationClass="de.platon42.intellij.plugins.m68k.folding.M68kFoldingBuilder"/>
<!--lang.formatter language="MC68000"
implementationClass="de.platon42.intellij.plugins.m68k.formatter.M68kAsmFormattingModelBuilder"/-->
<codeStyleSettingsProvider implementation="de.platon42.intellij.plugins.m68k.formatter.M68kAsmCodeStyleSettingsProvider"/>
<langCodeStyleSettingsProvider implementation="de.platon42.intellij.plugins.m68k.formatter.M68kLanguageCodeStyleSettingsProvider"/>
<navbar implementation="de.platon42.intellij.plugins.m68k.navigation.M68kStructureAwareNavbar"/>
<highlightVisitor implementation="de.platon42.intellij.plugins.m68k.syntax.M68kRainbowVisitor"/>
<colorSettingsPage implementation="de.platon42.intellij.plugins.m68k.syntax.M68kColorSettingsPage"/>
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.asm.M68kMnemonicCompletionContributor"/>
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.asm.M68kDirectiveCompletionContributor"/>
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.refs.M68kGlobalLabelSymbolCompletionContributor"/>
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.refs.M68kLocalLabelDefCompletionContributor"/>
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.refs.M68kMacroCallCompletionContributor"/>
@ -40,7 +49,9 @@
<lang.documentationProvider language="MC68000"
implementationClass="de.platon42.intellij.plugins.m68k.documentation.M68kSymbolDefinitionDocumentationProvider"/>
<lang.documentationProvider language="MC68000"
implementationClass="de.platon42.intellij.plugins.m68k.documentation.M68kGlobalLabelDocumentationProvider"/>
implementationClass="de.platon42.intellij.plugins.m68k.documentation.M68kLabelDefinitionDocumentationProvider"/>
<lang.documentationProvider language="MC68000"
implementationClass="de.platon42.intellij.plugins.m68k.documentation.M68kMacroDefinitionDocumentationProvider"/>
<lang.documentationProvider language="MC68000"
implementationClass="de.platon42.intellij.plugins.m68k.documentation.M68kRegisterFlowDocumentationProvider"/>
<lang.documentationProvider language="MC68000"
@ -66,8 +77,14 @@
<localInspection implementationClass="de.platon42.intellij.plugins.m68k.inspections.M68kUnresolvedReferenceInspection"
displayName="Unresolved label/symbol/macro reference" groupName="M68k"
enabledByDefault="true" level="WARNING"/>
<projectService serviceImplementation="de.platon42.intellij.plugins.m68k.settings.M68kProjectSettings"/>
<projectConfigurable parentId="language" instance="de.platon42.intellij.plugins.m68k.settings.M68kProjectSettingsConfigurable"
id="de.platon42.intellij.plugins.m68k.settings.M68kProjectSettingsConfigurable" displayName="M68k"
nonDefaultProject="true"/>
</extensions>
<actions>
</actions>
</idea-plugin>
</idea-plugin>

View File

@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.extension.*;
import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
import org.junit.jupiter.api.extension.ExtensionContext.Store;
import org.junit.runner.Description;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
@ -34,8 +35,11 @@ public class LightCodeInsightExtension implements ParameterResolver, AfterTestEx
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
LightCodeInsightFixtureTestCaseWrapper testCase = getWrapper(extensionContext);
Parameter parameter = parameterContext.getParameter();
if (parameter.isAnnotationPresent(MyFixture.class)) return testCase.getMyFixture();
else if (parameter.isAnnotationPresent(MyTestCase.class)) return testCase;
if (parameter.isAnnotationPresent(MyFixture.class)) {
return testCase.getMyFixture();
} else if (parameter.isAnnotationPresent(MyTestCase.class)) {
return testCase;
}
return null;
}
@ -68,14 +72,15 @@ public class LightCodeInsightExtension implements ParameterResolver, AfterTestEx
@Override
public void interceptTestMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
Throwable[] throwables = new Throwable[1];
Description testDescription = Description.createTestDescription(extensionContext.getRequiredTestClass(), getWrapper(extensionContext).getName());
Runnable runnable = () -> {
try {
TestLoggerFactory.onTestStarted();
invocation.proceed();
TestLoggerFactory.onTestFinished(true);
TestLoggerFactory.onTestFinished(true, testDescription);
} catch (Throwable e) {
TestLoggerFactory.onTestFinished(false);
TestLoggerFactory.onTestFinished(false, testDescription);
throwables[0] = e;
}
};

View File

@ -2,17 +2,17 @@ package de.platon42.intellij.jupiter;
import com.intellij.lang.ParserDefinition;
import com.intellij.mock.MockProjectEx;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.util.Disposer;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.EdtTestUtilKt;
import com.intellij.testFramework.ParsingTestCase;
import com.intellij.testFramework.TestLoggerFactory;
import com.intellij.testFramework.fixtures.IdeaTestExecutionPolicy;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.extension.*;
import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
import org.junit.jupiter.api.extension.ExtensionContext.Store;
import org.junit.runner.Description;
import java.io.IOException;
import java.lang.annotation.Annotation;
@ -80,39 +80,26 @@ public class ParsingTestExtension implements ParameterResolver, AfterTestExecuti
@Override
public void interceptTestMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
Throwable[] throwables = new Throwable[1];
Description testDescription = Description.createTestDescription(extensionContext.getRequiredTestClass(), getWrapper(extensionContext).getName());
Runnable runnable = () -> {
try {
TestLoggerFactory.onTestStarted();
invocation.proceed();
TestLoggerFactory.onTestFinished(true);
} catch (Throwable e) {
TestLoggerFactory.onTestFinished(false);
throwables[0] = e;
}
};
invokeTestRunnable(runnable);
try {
TestLoggerFactory.onTestStarted();
invocation.proceed();
TestLoggerFactory.onTestFinished(true, testDescription);
} catch (Throwable e) {
TestLoggerFactory.onTestFinished(false, testDescription);
throwables[0] = e;
}
if (throwables[0] != null) {
throw throwables[0];
}
}
private static void invokeTestRunnable(@NotNull Runnable runnable) {
IdeaTestExecutionPolicy policy = IdeaTestExecutionPolicy.current();
if (policy != null && !policy.runInDispatchThread()) {
runnable.run();
} else {
EdtTestUtilKt.runInEdtAndWait(() -> {
runnable.run();
return null;
});
}
}
public interface IParsingTestCase {
MockProjectEx getProject();
ParserDefinition getParserDefinition();
void ensureNoErrorElements();

View File

@ -0,0 +1,63 @@
package de.platon42.intellij.plugins.m68k.asm
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
import de.platon42.intellij.jupiter.LightCodeInsightExtension
import de.platon42.intellij.jupiter.MyFixture
import de.platon42.intellij.plugins.m68k.AbstractM68kTest
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
@ExtendWith(LightCodeInsightExtension::class)
internal class M68kDirectiveCompletionContributorTest : AbstractM68kTest() {
@Test
internal fun completion_shows_plain_directive(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText(
"completeme.asm", """
inc<caret>
"""
)
myFixture.completeBasic()
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder("include", "incbin", "incdir")
}
@Test
internal fun completion_shows_other_directive(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText(
"completeme.asm", """
IF<caret>
"""
)
myFixture.completeBasic()
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder(
"IF",
"IFB",
"IFC",
"IFD",
"IFEQ",
"IFGE",
"IFGT",
"IFLE",
"IFLT",
"IFMACROD",
"IFMACROND",
"IFNB",
"IFNC",
"IFND",
"IFNE",
"ENDIF"
)
}
@Test
internal fun completion_shows_data_directives(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText(
"completeme.asm", """
dc<caret>
"""
)
myFixture.completeBasic()
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder("dc", "dc.b", "dc.w", "dc.l", "dcb", "dcb.b", "dcb.w", "dcb.l", "data_c")
}
}

View File

@ -13,28 +13,34 @@ internal class M68kMnemonicCompletionContributorTest : AbstractM68kTest() {
@Test
internal fun completion_shows_all_move_mnemonics_after_first_letters(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText("completeme.asm", """
myFixture.configureByText(
"completeme.asm", """
mo<caret>
""")
"""
)
myFixture.completeBasic()
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder("move", "moveq", "movea", "movem", "movep")
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder("move", "moveq", "movea", "movem", "movep", "movec", "moves")
}
@Test
internal fun completion_shows_all_mnemonics_after_label(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText("completeme.asm", """
myFixture.configureByText(
"completeme.asm", """
label: <caret>
""")
"""
)
myFixture.completeBasic()
assertThat(myFixture.lookupElementStrings).hasSameElementsAs(M68kIsa.mnemonics)
assertThat(myFixture.lookupElementStrings).containsAnyElementsOf(M68kIsa.mnemonics)
}
@Test
internal fun completion_shows_all_mnemonics_after_space(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText("completeme.asm", """
myFixture.configureByText(
"completeme.asm", """
<caret>
""")
"""
)
myFixture.completeBasic()
assertThat(myFixture.lookupElementStrings).hasSameElementsAs(M68kIsa.mnemonics)
assertThat(myFixture.lookupElementStrings).containsAnyElementsOf(M68kIsa.mnemonics)
}
}

View File

@ -12,6 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith
abstract class AbstractDocumentationProviderTest : AbstractM68kTest() {
fun generateDocumentation(myFixture: CodeInsightTestFixture): String? {
// FIXME migrate to DocumentationTarget
val docElement = DocumentationManager.getInstance(myFixture.project).findTargetElement(myFixture.editor, myFixture.file)
val provider = DocumentationManager.getProviderFromElement(docElement)

View File

@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
@ExtendWith(LightCodeInsightExtension::class)
internal class M68kGlobalLabelDocumentationProviderTest : AbstractDocumentationProviderTest() {
internal class M68kLabelDocumentationProviderTest : AbstractDocumentationProviderTest() {
@Test
internal fun check_documentation_for_a_label_definition(@MyFixture myFixture: CodeInsightTestFixture) {
@ -18,13 +18,13 @@ internal class M68kGlobalLabelDocumentationProviderTest : AbstractDocumentationP
; inputs: d0 = number
; output: d0 = square
squareme: include "fancysquarecode.asm"
squareme: include "fancysquarecode.asm" ; code -> cool!
rts
bsr square<caret>me
"""
)
assertThat(generateDocumentation(myFixture))
.isEqualTo("<span class='grayed'>; inputs: d0 = number<br>; output: d0 = square</span><div class='definition'><pre>squareme</pre></div><div class='content'>include &quot;fancysquarecode.asm&quot;</div>")
.isEqualTo("<span class=\"grayed\">; inputs: d0 = number<br/>; output: d0 = square<br/>; code -&gt; cool!</span><div class=\"definition\"><code>squareme</code></div><div class=\"content\"><code>include &quot;fancysquarecode.asm&quot;</code></div>")
}
@Test
@ -32,12 +32,12 @@ squareme: include "fancysquarecode.asm"
myFixture.configureByText(
"documentme.asm", """
; output: d0 = square
square<caret>me:
.square<caret>me:
; oh man
include "fancysquarecode.asm"
"""
)
assertThat(generateDocumentation(myFixture))
.isEqualTo("<span class='grayed'>; output: d0 = square</span><div class='definition'><pre>squareme</pre></div><div class='content'>include &quot;fancysquarecode.asm&quot;</div>")
.isEqualTo("<span class=\"grayed\">; output: d0 = square</span><div class=\"definition\"><code>.squareme</code></div><div class=\"content\"><code>include &quot;fancysquarecode.asm&quot;</code></div>")
}
}

View File

@ -0,0 +1,58 @@
package de.platon42.intellij.plugins.m68k.documentation
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
import de.platon42.intellij.jupiter.LightCodeInsightExtension
import de.platon42.intellij.jupiter.MyFixture
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
@ExtendWith(LightCodeInsightExtension::class)
internal class M68kMacroDefinitionDocumentationProviderTest : AbstractDocumentationProviderTest() {
@Test
internal fun check_expanded_documentation_for_a_macro_definition(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText(
"documentme.asm", """
MOLV<caret>ANIA MACRO ; the bestest macro
move.l \1,d0
mulu d0,d0
ENDM
"""
)
assertThat(generateDocumentation(myFixture))
.isEqualTo("<span class=\"grayed\">; the bestest macro</span><div class=\"definition\"><code>MOLVANIA</code></div><div class=\"content\"><code> move.l \\1,d0</code><br/><code> mulu d0,d0</code></div>")
}
@Test
internal fun check_expanded_documentation_for_a_macro_invocation(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText(
"documentme.asm", """
MOLVANIA MACRO ; the bestest macro
move.l \1,d0
mulu d0,d0
ENDM
MOLV<caret>ANIA d1
"""
)
assertThat(generateDocumentation(myFixture))
.isEqualTo("<span class=\"grayed\">; the bestest macro</span><div class=\"definition\"><code>MOLVANIA</code></div><div class=\"content\"><code> move.l d1,d0</code><br/><code> mulu d0,d0</code></div>")
}
@Test
internal fun check_expanded_documentation_for_a_macro_invocation_with_lots_of_params(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText(
"documentme.asm", """
; compress nibbles
DTW MACRO
dc.b ((\1)<<4)|(\2),((\3)<<4)|(\4),((\5)<<4)|(\6),((\7)<<4)|(\8),((\9)<<4)|(\a),((\b)<<4)|(\c),((\d)<<4)|(\e),((\f)<<4)|(\g)
ENDM
DTW<caret> 15,14,14,10,1,2,3,4,10,11,10,12,5,3,9,10
"""
)
assertThat(generateDocumentation(myFixture))
.isEqualTo("<span class=\"grayed\">; compress nibbles</span><div class=\"definition\"><code>DTW</code></div><div class=\"content\"><code> dc.b ((15)&lt;&lt;4)|(14),((14)&lt;&lt;4)|(10),((1)&lt;&lt;4)|(2),((3)&lt;&lt;4)|(4),((10)&lt;&lt;4)|(11),((10)&lt;&lt;4)|(12),((5)&lt;&lt;4)|(3),((9)&lt;&lt;4)|(10)</code></div>")
}
}

View File

@ -100,7 +100,6 @@ nextlabel
)
}
@Test
internal fun check_documentation_for_a_written_register_in_code_flow(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText(
@ -177,6 +176,42 @@ nextlabel
<td valign="top"> ; <font color="#00ff00">sets d1.l</font></td>
</tr>
</table>
"""
)
}
@Test
internal fun check_documentation_for_68020_address_modes(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText(
"documentme.asm", """
moveq.l #0,d0
lea foobar(pc),a0
move.l ([100.w,a0,a0.w*4],124.w),($42.w,a0,d0.l*4)
move.l a<caret>0,a1
"""
)
assertThat(generateDocumentation(myFixture))
.isEqualToIgnoringWhitespace(
"""
<div class="definition">movea instruction uses a0.l</div>
<table class="sections" style="padding-left: 8pt; padding-right: 8pt">
<tr>
<td valign="top">        </td>
<td valign="top"><code>lea foobar(pc),<font color="#ffc800">a0</font></code></td>
<td valign="top"> ; <font color="#00ff00">sets a0.l</font></td>
</tr>
<tr>
<td valign="top">        </td>
<td valign="top"><code>move.l ([100.w,<font color="#ffc800">a0</font>,<font color="#ffc800">a0</font>.w*4],124.w),(${'$'}42.w,<font color="#ffc800">a0</font>,d0.l*4)</code>
</td>
<td valign="top"> ; uses a0.l, uses a0.w</td>
</tr>
<tr>
<td valign="top">--&gt;</td>
<td valign="top"><b><code>move.l <font color="#ffc800">a0</font>,a1</code></b></td>
<td valign="top"> ; &lt;--</td>
</tr>
</table>
"""
)
}

View File

@ -14,11 +14,11 @@ internal class M68kSymbolDefinitionDocumentationProviderTest : AbstractDocumenta
internal fun check_documentation_for_a_symbol_definition(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText(
"documentme.asm", """
PIC_WIDTH = 320
PIC_WIDTH = 320 ; width of picture
move.w #PIC_WIDT<caret>H,d0
"""
)
assertThat(generateDocumentation(myFixture))
.isEqualTo("<div class='definition'><pre>PIC_WIDTH</pre></div><div class='content'>320</div>")
.isEqualTo("<span class=\"grayed\">; width of picture</span><div class=\"definition\"><code>PIC_WIDTH</code></div><div class=\"content\"><code>320</code></div>")
}
}

View File

@ -0,0 +1,19 @@
package de.platon42.intellij.plugins.m68k.folding
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
import de.platon42.intellij.jupiter.LightCodeInsightExtension
import de.platon42.intellij.jupiter.MyFixture
import de.platon42.intellij.jupiter.TestDataPath
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
@TestDataPath("src/test/resources/folding")
@ExtendWith(LightCodeInsightExtension::class)
internal class M68kFoldingBuilderTest {
@Test
internal fun check_documentation_for_a_symbol_definition(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.testFolding(myFixture.testDataPath + "/folding.asm")
}
}

View File

@ -0,0 +1,52 @@
package de.platon42.intellij.plugins.m68k.formatter
import com.intellij.application.options.CodeStyle
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.psi.codeStyle.CodeStyleManager
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
import com.intellij.util.containers.ContainerUtil
import de.platon42.intellij.jupiter.LightCodeInsightExtension
import de.platon42.intellij.jupiter.MyFixture
import de.platon42.intellij.jupiter.TestDataPath
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
@TestDataPath("src/test/resources/formatting")
@ExtendWith(LightCodeInsightExtension::class)
internal class M68kAsmFormatterTest {
@Test
@Disabled
internal fun check_if_formatting_works_as_expected(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByFile("basic_before.asm")
val settings = CodeStyle.getLanguageSettings(myFixture.file)
settings.indentOptions?.INDENT_SIZE = 6
settings.indentOptions?.CONTINUATION_INDENT_SIZE = 9
WriteCommandAction.runWriteCommandAction(myFixture.project)
{
CodeStyleManager.getInstance(myFixture.project).reformatText(
myFixture.file,
ContainerUtil.newArrayList(myFixture.file.textRange)
)
}
myFixture.checkResultByFile("basic_after.asm")
}
@Test
internal fun check_formatting_for_mnemonics(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByFile("mnemonics_before.asm")
val settings = CodeStyle.getLanguageSettings(myFixture.file)
settings.indentOptions?.INDENT_SIZE = 8
WriteCommandAction.runWriteCommandAction(myFixture.project)
{
CodeStyleManager.getInstance(myFixture.project).reformatText(
myFixture.file,
ContainerUtil.newArrayList(myFixture.file.textRange)
)
}
myFixture.checkResultByFile("mnemonics_after.asm")
}
}

View File

@ -63,7 +63,7 @@ internal class M68kInspectionSuppressorTest : AbstractInspectionTest() {
val quickFixPair = highlightInfos[0].quickFixActionRanges[0]
val intentionActionDescriptor = quickFixPair.first
val element = myFixture.file.findElementAt(quickFixPair.second.startOffset)!!
val suppressQuickFix = intentionActionDescriptor.getOptions(element, myFixture.editor)!!
val suppressQuickFix = intentionActionDescriptor.getOptions(element, myFixture.editor)
.first { it.text == suppressAction }
myFixture.launchAction(suppressQuickFix)
}

View File

@ -14,7 +14,7 @@ internal class AddressingModesTest : AbstractParsingTest() {
@Test
internal fun register_direct(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l d0,a7\n")
testGoodSyntax(testCase, " MOVE.L d0,a7\n")
}
@Test
@ -52,6 +52,16 @@ internal class AddressingModesTest : AbstractParsingTest() {
testGoodSyntax(testCase, " move.l (sp,d0.w),(a1,a3)\n")
}
@Test
internal fun register_indirect_with_scaled_index_and_offset_old_syntax(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l -4+foo(sp,d0.w*8),(10*20+4)(a1,a3*4)\n")
}
@Test
internal fun register_indirect_with_scaled_index_and_offset_new_syntax(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l (-4+foo,sp,a0*1),((10*20+4),a1,d5.l*2)\n")
}
@Test
internal fun pc_indirect_with_offset_old_syntax(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l -4*4(pc),+4(pc)\n")
@ -82,6 +92,181 @@ internal class AddressingModesTest : AbstractParsingTest() {
testGoodSyntax(testCase, " move.l (pc,d0.w),(pc,a3)\n")
}
@Test
internal fun memory_indirect_with_all_params(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234.w,a1],124),([-12.w,a0],-120)\n")
}
@Test
internal fun memory_indirect_without_base_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([a1],124.l),([a0],-120.w)\n")
}
@Test
internal fun memory_indirect_without_outer_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234,a1]),([-12,a0])\n")
}
@Test
internal fun memory_indirect_minimal(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([a1]),([a0])\n")
}
@Test
internal fun memory_indirect_post_indexed_with_all_params(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234.w,a1],a0.w*4,124),([-12,a0],d0.l*8,-120.w)\n")
}
@Test
internal fun memory_indirect_post_indexed_without_base_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([a1],a0,124.l),([a0],d0.l*8,-120)\n")
}
@Test
internal fun memory_indirect_post_indexed_without_outer_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234.l,a1],a0),([-12,a0],d0.l*8)\n")
}
@Test
internal fun memory_indirect_post_indexed_without_address_register(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234.l],a0),([-12],d0.l*8)\n")
}
@Test
internal fun memory_indirect_post_indexed_minimal(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([a1],a0),([a0],d0)\n")
}
@Test
internal fun memory_indirect_pre_indexed_with_all_params(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234,a1,a0.w*4],124),([-12,a0,d0.l*8],-120)\n")
}
@Test
internal fun memory_indirect_pre_indexed_without_base_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([a1,a0],124),([a0,d0.l*8],-120.w)\n")
}
@Test
internal fun memory_indirect_pre_indexed_without_outer_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234.l,a1,a0]),([-12,a0,d0.l*8])\n")
}
@Test
internal fun memory_indirect_pre_indexed_without_address_register(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234.l,a0*4]),([-12,d0.l*8])\n")
}
@Test
internal fun memory_indirect_pre_indexed_only_with_index(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([a0*4]),([d0.l*8])\n")
}
@Test
internal fun memory_indirect_pre_indexed_minimal(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([a1,a0]),([a0,d0])\n")
}
@Test
internal fun pc_memory_indirect_with_all_params(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234.w,pc],124),d0\n")
}
@Test
internal fun pc_memory_indirect_without_base_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([pc],124.l),d0\n")
}
@Test
internal fun pc_memory_indirect_without_outer_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234,pc]),d0\n")
}
@Test
internal fun pc_memory_indirect_minimal(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([pc]),d0\n")
}
@Test
internal fun pc_memory_indirect_post_indexed_with_all_params(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234.l,pc],a0.w*4,124.w),d0\n")
}
@Test
internal fun pc_memory_indirect_post_indexed_without_base_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([pc],a0.l*4,124),d0\n")
}
@Test
internal fun pc_memory_indirect_post_indexed_without_outer_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234,pc],a0),d0\n")
}
@Test
internal fun pc_memory_indirect_post_indexed_minimal(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([pc],a0*4),d0\n")
}
@Test
internal fun pc_memory_indirect_pre_indexed_with_all_params(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234.w,pc,a0.w*4],124),d0\n")
}
@Test
internal fun pc_memory_indirect_pre_indexed_without_base_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([pc,a0*4],124.l),d0\n")
}
@Test
internal fun pc_memory_indirect_pre_indexed_without_outer_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([1234,pc,a0]),d0\n")
}
@Test
internal fun pc_memory_indirect_pre_indexed_minimal(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l ([pc,a0.l*4]),d0\n")
}
@Test
internal fun register_indirect_with_index_base_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l (100.w,a0,a0.l*4),d0\n")
}
@Test
internal fun register_indirect_with_index_base_displacement_without_areg(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l (100.w,a0.l*4),d0\n")
}
@Test
internal fun register_indirect_with_index_base_displacement_without_index(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l (100.l,a0),d0\n")
}
@Test
internal fun register_indirect_with_index_base_displacement_with_dreg_index(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l (d0),(d0.w*4)\n")
}
@Test
internal fun register_indirect_with_index_base_displacement_only(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l (100.l),d0\n")
}
@Test
internal fun register_indirect_with_index_base_displacement_zero(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l (),d0\n")
}
@Test
internal fun pc_indirect_with_index_base_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l (100.w,pc,a0.l*4),d0\n")
}
@Test
internal fun pc_indirect_with_index_base_displacement_without_index(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l (100.l,pc),d0\n")
}
@Test
internal fun absolute_address(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " move.l 4.w,a6\n")

View File

@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.parser
import de.platon42.intellij.jupiter.MyTestCase
import de.platon42.intellij.jupiter.ParsingTestExtension
import de.platon42.intellij.jupiter.TestDataSubPath
import de.platon42.intellij.plugins.m68k.settings.M68kProjectSettings
import org.junit.jupiter.api.Test
@TestDataSubPath("comments")
@ -50,37 +51,51 @@ internal class CommentsTest : AbstractParsingTest() {
@Test
internal fun comment_after_instruction_with_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = true
setSpacesSetting(testCase, true)
testGoodSyntax(testCase, " add.w d0,d0 hey comment\n")
}
@Test
internal fun comment_after_assignment_with_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = true
setSpacesSetting(testCase, true)
testGoodSyntax(testCase, "FOO = 123+23 hey comment\n")
}
@Test
internal fun comment_after_data_directive_with_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
setSpacesSetting(testCase, true)
testGoodSyntax(testCase, " dc.w $1234,$2345 hey comment\n")
}
@Test
internal fun comment_after_macro_call_with_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = true
setSpacesSetting(testCase, true)
testGoodSyntax(testCase, " PUSHM d0,d0 hey comment\n")
}
@Test
internal fun space_does_not_start_comment_within_instruction_without_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = false
setSpacesSetting(testCase, false)
testGoodSyntax(testCase, " add.w # 234, d0 ; hey comment\n")
}
@Test
internal fun space_does_not_start_comment_within_assignment_without_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = false
setSpacesSetting(testCase, false)
testGoodSyntax(testCase, "FOO = 123 + 23 ; hey comment\n")
}
@Test
internal fun space_does_not_start_comment_within_macro_call_without_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = false
setSpacesSetting(testCase, false)
testGoodSyntax(testCase, " PUSHM d0, d0 ; hey comment\n")
}
private fun setSpacesSetting(testCase: ParsingTestExtension.IParsingTestCase, spacesOption: Boolean) {
val settings = M68kProjectSettings()
settings.settings.spaceIntroducesComment = spacesOption
testCase.project.registerService(M68kProjectSettings::class.java, settings)
}
}

View File

@ -27,6 +27,6 @@ noppy MACRO
"""
)
myFixture.completeBasic()
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder("nop", "not", "noppy")
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder("nop", "not", "noppy", "cnop")
}
}

View File

@ -103,7 +103,7 @@ internal class M68kReferenceContributorTest : AbstractM68kTest() {
assertThat(otherfile.text).isEqualTo("; oh no!")
myFixture.renameElementAtCaret("foobar.asm")
val files = FilenameIndex.getFilesByName(myFixture.project, "foobar.asm", GlobalSearchScope.allScope(myFixture.project))
val files = FilenameIndex.getVirtualFilesByName("foobar.asm", GlobalSearchScope.allScope(myFixture.project))
assertThat(files).hasSize(1)
assertThat(file.text).isEqualToIgnoringWhitespace("include \"foobar.asm\"")
@ -123,7 +123,7 @@ internal class M68kReferenceContributorTest : AbstractM68kTest() {
assertThat(otherfile.text).isEqualTo("; oh no!")
myFixture.renameElementAtCaret("foobar.asm")
val files = FilenameIndex.getFilesByName(myFixture.project, "foobar.asm", GlobalSearchScope.allScope(myFixture.project))
val files = FilenameIndex.getVirtualFilesByName("foobar.asm", GlobalSearchScope.allScope(myFixture.project))
assertThat(files).hasSize(1)
assertThat(file.text).isEqualToIgnoringWhitespace("include \"foobar/foobar.asm\"")

Some files were not shown because too many files have changed in this diff Show More