Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
SO, CLRSO, SETSO directives
Browse files Browse the repository at this point in the history
  • Loading branch information
YannCebron committed Oct 20, 2021
1 parent 2174160 commit 6803935
Show file tree
Hide file tree
Showing 34 changed files with 2,231 additions and 1,707 deletions.
2 changes: 2 additions & 0 deletions .idea/dictionaries/yann.xml

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

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- support DX directive
- support IF1/IF2/IFP1 directives
- support FO, CLRFO, SETFO directives
- support SO, CLRSO, SETSO directives
- add inspection: Conditional assembly directives problems
- 68010 support: add reference documentation for BKPT, MOVEC, MOVES instructions
- "M68k Browser": new tool window to browse instructions and (reference) docs
Expand Down
1 change: 0 additions & 1 deletion docs/known_issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ Unsupported directives, these will display false positive
- `public`
- `rorg`
- `showoffset` (PhxAss)
- `so.*`, `clrso`/`setso`
- `struct`/`estruct`
- `symdebug`
- `weak`
Expand Down
64 changes: 63 additions & 1 deletion gen/com/yanncebron/m68kplugin/lang/M68kDirectivesParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ public static boolean clrfo_directive(PsiBuilder b, int l) {
return r;
}

/* ********************************************************** */
// CLRSO
public static boolean clrso_directive(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "clrso_directive")) return false;
if (!nextTokenIs(b, "<directive>", CLRSO)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, CLRSO_DIRECTIVE, "<directive>");
r = consumeToken(b, CLRSO);
exit_section_(b, l, m, r, false, null);
return r;
}

/* ********************************************************** */
// CNOP expression COMMA expression
public static boolean cnop_directive(PsiBuilder b, int l) {
Expand Down Expand Up @@ -424,7 +436,10 @@ private static boolean dcb_directive_3_0(PsiBuilder b, int l) {
// machine_directive |
// fo_directive |
// clrfo_directive |
// setfo_directive
// setfo_directive |
// so_directive |
// clrso_directive |
// setso_directive
static boolean directives(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "directives")) return false;
boolean r;
Expand Down Expand Up @@ -512,6 +527,9 @@ static boolean directives(PsiBuilder b, int l) {
if (!r) r = fo_directive(b, l + 1);
if (!r) r = clrfo_directive(b, l + 1);
if (!r) r = setfo_directive(b, l + 1);
if (!r) r = so_directive(b, l + 1);
if (!r) r = clrso_directive(b, l + 1);
if (!r) r = setso_directive(b, l + 1);
return r;
}

Expand Down Expand Up @@ -1715,6 +1733,50 @@ public static boolean setfo_directive(PsiBuilder b, int l) {
return r || p;
}

/* ********************************************************** */
// SETSO expression
public static boolean setso_directive(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "setso_directive")) return false;
if (!nextTokenIs(b, "<directive>", SETSO)) return false;
boolean r, p;
Marker m = enter_section_(b, l, _NONE_, SETSO_DIRECTIVE, "<directive>");
r = consumeToken(b, SETSO);
p = r; // pin = 1
r = r && M68kExpressionParser.expression(b, l + 1, -1);
exit_section_(b, l, m, r, p, null);
return r || p;
}

/* ********************************************************** */
// label SO data_size_all? expression?
public static boolean so_directive(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "so_directive")) return false;
if (!nextTokenIs(b, "<directive>", ID)) return false;
boolean r, p;
Marker m = enter_section_(b, l, _NONE_, SO_DIRECTIVE, "<directive>");
r = label(b, l + 1);
r = r && consumeToken(b, SO);
p = r; // pin = 2
r = r && report_error_(b, so_directive_2(b, l + 1));
r = p && so_directive_3(b, l + 1) && r;
exit_section_(b, l, m, r, p, null);
return r || p;
}

// data_size_all?
private static boolean so_directive_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "so_directive_2")) return false;
data_size_all(b, l + 1);
return true;
}

// expression?
private static boolean so_directive_3(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "so_directive_3")) return false;
M68kExpressionParser.expression(b, l + 1, -1);
return true;
}

/* ********************************************************** */
// SPC expression
public static boolean spc_directive(PsiBuilder b, int l) {
Expand Down
8 changes: 4 additions & 4 deletions gen/com/yanncebron/m68kplugin/lang/M68kParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ static boolean parse_root_(IElementType t, PsiBuilder b, int l) {
SCS_INSTRUCTION, SEQ_INSTRUCTION, SF_INSTRUCTION, SGE_INSTRUCTION,
SGT_INSTRUCTION, SHI_INSTRUCTION, SHS_INSTRUCTION, SLE_INSTRUCTION,
SLO_INSTRUCTION, SLS_INSTRUCTION, SLT_INSTRUCTION, SMI_INSTRUCTION,
SNE_INSTRUCTION, SPL_INSTRUCTION, ST_INSTRUCTION, SUBA_INSTRUCTION,
SUBI_INSTRUCTION, SUBQ_INSTRUCTION, SUBX_INSTRUCTION, SUB_INSTRUCTION,
SVC_INSTRUCTION, SVS_INSTRUCTION, SWAP_INSTRUCTION, TAS_INSTRUCTION,
TST_INSTRUCTION),
SNE_INSTRUCTION, SO_DIRECTIVE, SPL_INSTRUCTION, ST_INSTRUCTION,
SUBA_INSTRUCTION, SUBI_INSTRUCTION, SUBQ_INSTRUCTION, SUBX_INSTRUCTION,
SUB_INSTRUCTION, SVC_INSTRUCTION, SVS_INSTRUCTION, SWAP_INSTRUCTION,
TAS_INSTRUCTION, TST_INSTRUCTION),
};

/* ********************************************************** */
Expand Down
12 changes: 12 additions & 0 deletions gen/com/yanncebron/m68kplugin/lang/psi/M68kTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public interface M68kTypes {
IElementType BVS_INSTRUCTION = new M68kCompositeElementType("BVS_INSTRUCTION");
IElementType CHK_INSTRUCTION = new M68kCompositeElementType("CHK_INSTRUCTION");
IElementType CLRFO_DIRECTIVE = new M68kCompositeElementType("CLRFO_DIRECTIVE");
IElementType CLRSO_DIRECTIVE = new M68kCompositeElementType("CLRSO_DIRECTIVE");
IElementType CLR_INSTRUCTION = new M68kCompositeElementType("CLR_INSTRUCTION");
IElementType CMPA_INSTRUCTION = new M68kCompositeElementType("CMPA_INSTRUCTION");
IElementType CMPI_INSTRUCTION = new M68kCompositeElementType("CMPI_INSTRUCTION");
Expand Down Expand Up @@ -272,6 +273,7 @@ public interface M68kTypes {
IElementType SECTION_DIRECTIVE = new M68kCompositeElementType("SECTION_DIRECTIVE");
IElementType SEQ_INSTRUCTION = new M68kCompositeElementType("SEQ_INSTRUCTION");
IElementType SETFO_DIRECTIVE = new M68kCompositeElementType("SETFO_DIRECTIVE");
IElementType SETSO_DIRECTIVE = new M68kCompositeElementType("SETSO_DIRECTIVE");
IElementType SET_DIRECTIVE = new M68kCompositeElementType("SET_DIRECTIVE");
IElementType SF_INSTRUCTION = new M68kCompositeElementType("SF_INSTRUCTION");
IElementType SGE_INSTRUCTION = new M68kCompositeElementType("SGE_INSTRUCTION");
Expand All @@ -286,6 +288,7 @@ public interface M68kTypes {
IElementType SLT_INSTRUCTION = new M68kCompositeElementType("SLT_INSTRUCTION");
IElementType SMI_INSTRUCTION = new M68kCompositeElementType("SMI_INSTRUCTION");
IElementType SNE_INSTRUCTION = new M68kCompositeElementType("SNE_INSTRUCTION");
IElementType SO_DIRECTIVE = new M68kCompositeElementType("SO_DIRECTIVE");
IElementType SPC_DIRECTIVE = new M68kCompositeElementType("SPC_DIRECTIVE");
IElementType SPL_INSTRUCTION = new M68kCompositeElementType("SPL_INSTRUCTION");
IElementType STOP_INSTRUCTION = new M68kCompositeElementType("STOP_INSTRUCTION");
Expand Down Expand Up @@ -509,6 +512,9 @@ else if (type == CHK_INSTRUCTION) {
else if (type == CLRFO_DIRECTIVE) {
return new M68kClrfoDirectiveImpl(node);
}
else if (type == CLRSO_DIRECTIVE) {
return new M68kClrsoDirectiveImpl(node);
}
else if (type == CLR_INSTRUCTION) {
return new M68kClrInstructionImpl(node);
}
Expand Down Expand Up @@ -1052,6 +1058,9 @@ else if (type == SEQ_INSTRUCTION) {
else if (type == SETFO_DIRECTIVE) {
return new M68kSetfoDirectiveImpl(node);
}
else if (type == SETSO_DIRECTIVE) {
return new M68kSetsoDirectiveImpl(node);
}
else if (type == SET_DIRECTIVE) {
return new M68kSetDirectiveImpl(node);
}
Expand Down Expand Up @@ -1094,6 +1103,9 @@ else if (type == SMI_INSTRUCTION) {
else if (type == SNE_INSTRUCTION) {
return new M68kSneInstructionImpl(node);
}
else if (type == SO_DIRECTIVE) {
return new M68kSoDirectiveImpl(node);
}
else if (type == SPC_DIRECTIVE) {
return new M68kSpcDirectiveImpl(node);
}
Expand Down
13 changes: 13 additions & 0 deletions gen/com/yanncebron/m68kplugin/lang/psi/M68kVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ public void visitClrfoDirective(@NotNull M68kClrfoDirective o) {
visitDirective(o);
}

public void visitClrsoDirective(@NotNull M68kClrsoDirective o) {
visitDirective(o);
}

public void visitCmpInstruction(@NotNull M68kCmpInstruction o) {
visitCmpInstructionBase(o);
}
Expand Down Expand Up @@ -1105,6 +1109,10 @@ public void visitSetfoDirective(@NotNull M68kSetfoDirective o) {
visitDirective(o);
}

public void visitSetsoDirective(@NotNull M68kSetsoDirective o) {
visitDirective(o);
}

public void visitSfInstruction(@NotNull M68kSfInstruction o) {
visitSccInstructionBase(o);
}
Expand Down Expand Up @@ -1162,6 +1170,11 @@ public void visitSneInstruction(@NotNull M68kSneInstruction o) {
visitSccInstructionBase(o);
}

public void visitSoDirective(@NotNull M68kSoDirective o) {
visitDataSized(o);
// visitDirective(o);
}

public void visitSpcDirective(@NotNull M68kSpcDirective o) {
visitDirective(o);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2021 The Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yanncebron.m68kplugin.lang.psi.directive;

import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;

public interface M68kClrsoDirective extends M68kDirective {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2021 The Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yanncebron.m68kplugin.lang.psi.directive;

import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
import com.yanncebron.m68kplugin.lang.psi.expression.M68kExpression;

public interface M68kSetsoDirective extends M68kDirective {

@Nullable
M68kExpression getExpression();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2021 The Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yanncebron.m68kplugin.lang.psi.directive;

import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
import com.yanncebron.m68kplugin.lang.psi.M68kDataSized;
import com.yanncebron.m68kplugin.lang.psi.M68kLabel;
import com.yanncebron.m68kplugin.lang.psi.expression.M68kExpression;

public interface M68kSoDirective extends M68kDataSized, M68kDirective {

@Nullable
M68kExpression getExpression();

@NotNull
M68kLabel getLabel();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2021 The Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yanncebron.m68kplugin.lang.psi.directive.impl;

import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import static com.yanncebron.m68kplugin.lang.psi.M68kTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.yanncebron.m68kplugin.lang.psi.directive.*;
import com.yanncebron.m68kplugin.lang.psi.M68kVisitor;
import com.yanncebron.m68kplugin.lang.psi.impl.M68kPsiImplUtil;

public class M68kClrsoDirectiveImpl extends ASTWrapperPsiElement implements M68kClrsoDirective {

public M68kClrsoDirectiveImpl(@NotNull ASTNode node) {
super(node);
}

public void accept(@NotNull M68kVisitor visitor) {
visitor.visitClrsoDirective(this);
}

@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor)visitor);
else super.accept(visitor);
}

}
Loading

0 comments on commit 6803935

Please sign in to comment.