Added missing test for comparing expressions. Deleted unused generated file for Label-Implementation, noticed problem in inheritance hierarchy and removed base interface M68kLabel, too.
This commit is contained in:
parent
72db8ad8b2
commit
ad3b207362
@ -37,7 +37,6 @@ public class M68kParser implements PsiParser, LightPsiParser {
|
||||
}
|
||||
|
||||
public static final TokenSet[] EXTENDS_SETS_ = new TokenSet[]{
|
||||
create_token_set_(GLOBAL_LABEL, LABEL, LOCAL_LABEL),
|
||||
create_token_set_(ADDRESS_REGISTER, DATA_REGISTER, REGISTER, SPECIAL_REGISTER),
|
||||
create_token_set_(ABSOLUTE_ADDRESS_ADDRESSING_MODE, ADDRESSING_MODE, ADDRESS_REGISTER_DIRECT_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_ADDRESSING_MODE,
|
||||
ADDRESS_REGISTER_INDIRECT_POST_INC_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_PRE_DEC_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE,
|
||||
@ -567,14 +566,12 @@ public class M68kParser implements PsiParser, LightPsiParser {
|
||||
|
||||
/* ********************************************************** */
|
||||
// LocalLabel | GlobalLabel
|
||||
public static boolean Label(PsiBuilder b, int l) {
|
||||
static boolean Label(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "Label")) return false;
|
||||
if (!nextTokenIs(b, "<label>", GLOBAL_LABEL_DEF, LOCAL_LABEL_DEF)) return false;
|
||||
if (!nextTokenIs(b, "", GLOBAL_LABEL_DEF, LOCAL_LABEL_DEF)) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _COLLAPSE_, LABEL, "<label>");
|
||||
r = LocalLabel(b, l + 1);
|
||||
if (!r) r = GlobalLabel(b, l + 1);
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import de.platon42.intellij.plugins.m68k.stubs.M68kGlobalLabelStub;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface M68kGlobalLabel extends M68kLabel, M68kNamedElement, StubBasedPsiElement<M68kGlobalLabelStub> {
|
||||
public interface M68kGlobalLabel extends M68kNamedElement, StubBasedPsiElement<M68kGlobalLabelStub> {
|
||||
|
||||
@Nullable
|
||||
String getName();
|
||||
|
@ -1,6 +0,0 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package de.platon42.intellij.plugins.m68k.psi;
|
||||
|
||||
public interface M68kLabel extends M68kPsiElement {
|
||||
|
||||
}
|
@ -5,7 +5,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface M68kLocalLabel extends M68kLabel, M68kNamedElement {
|
||||
public interface M68kLocalLabel extends M68kNamedElement {
|
||||
|
||||
@Nullable
|
||||
String getName();
|
||||
|
@ -9,7 +9,10 @@ import java.util.List;
|
||||
public interface M68kPreprocessorDirective extends M68kPsiElement {
|
||||
|
||||
@Nullable
|
||||
M68kLabel getLabel();
|
||||
M68kGlobalLabel getGlobalLabel();
|
||||
|
||||
@Nullable
|
||||
M68kLocalLabel getLocalLabel();
|
||||
|
||||
@NotNull
|
||||
List<M68kExpr> getExprList();
|
||||
|
@ -12,7 +12,10 @@ public interface M68kStatement extends M68kPsiElement {
|
||||
M68kAssignment getAssignment();
|
||||
|
||||
@Nullable
|
||||
M68kLabel getLabel();
|
||||
M68kGlobalLabel getGlobalLabel();
|
||||
|
||||
@Nullable
|
||||
M68kLocalLabel getLocalLabel();
|
||||
|
||||
@Nullable
|
||||
M68kMacroCall getMacroCall();
|
||||
|
@ -48,7 +48,6 @@ public interface M68kTypes {
|
||||
IElementType EXPR = new M68kElementType("EXPR");
|
||||
IElementType GLOBAL_LABEL = M68kStubElementTypeFactory.stubFactory("GLOBAL_LABEL");
|
||||
IElementType IMMEDIATE_DATA = new M68kElementType("IMMEDIATE_DATA");
|
||||
IElementType LABEL = new M68kElementType("LABEL");
|
||||
IElementType LITERAL_EXPR = new M68kElementType("LITERAL_EXPR");
|
||||
IElementType LOCAL_LABEL = new M68kElementType("LOCAL_LABEL");
|
||||
IElementType MACRO_CALL = new M68kElementType("MACRO_CALL");
|
||||
|
@ -79,21 +79,15 @@ public class M68kVisitor extends PsiElementVisitor {
|
||||
}
|
||||
|
||||
public void visitGlobalLabel(@NotNull M68kGlobalLabel o) {
|
||||
visitLabel(o);
|
||||
// visitNamedElement(o);
|
||||
visitNamedElement(o);
|
||||
}
|
||||
|
||||
public void visitImmediateData(@NotNull M68kImmediateData o) {
|
||||
visitAddressingMode(o);
|
||||
}
|
||||
|
||||
public void visitLabel(@NotNull M68kLabel o) {
|
||||
visitPsiElement(o);
|
||||
}
|
||||
|
||||
public void visitLocalLabel(@NotNull M68kLocalLabel o) {
|
||||
visitLabel(o);
|
||||
// visitNamedElement(o);
|
||||
visitNamedElement(o);
|
||||
}
|
||||
|
||||
public void visitMacroCall(@NotNull M68kMacroCall o) {
|
||||
|
@ -1,27 +0,0 @@
|
||||
// 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 de.platon42.intellij.plugins.m68k.psi.M68kLabel;
|
||||
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class M68kLabelImpl extends ASTWrapperPsiElement implements M68kLabel {
|
||||
|
||||
public M68kLabelImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
public void accept(@NotNull M68kVisitor visitor) {
|
||||
visitor.visitLabel(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
|
||||
else super.accept(visitor);
|
||||
}
|
||||
|
||||
}
|
@ -5,10 +5,7 @@ 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.M68kLabel;
|
||||
import de.platon42.intellij.plugins.m68k.psi.M68kPreprocessorDirective;
|
||||
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
|
||||
import de.platon42.intellij.plugins.m68k.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -32,8 +29,14 @@ public class M68kPreprocessorDirectiveImpl extends ASTWrapperPsiElement implemen
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public M68kLabel getLabel() {
|
||||
return PsiTreeUtil.getChildOfType(this, M68kLabel.class);
|
||||
public M68kGlobalLabel getGlobalLabel() {
|
||||
return PsiTreeUtil.getChildOfType(this, M68kGlobalLabel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public M68kLocalLabel getLocalLabel() {
|
||||
return PsiTreeUtil.getChildOfType(this, M68kLocalLabel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,8 +39,14 @@ public class M68kStatementImpl extends ASTWrapperPsiElement implements M68kState
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public M68kLabel getLabel() {
|
||||
return PsiTreeUtil.getChildOfType(this, M68kLabel.class);
|
||||
public M68kGlobalLabel getGlobalLabel() {
|
||||
return PsiTreeUtil.getChildOfType(this, M68kGlobalLabel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public M68kLocalLabel getLocalLabel() {
|
||||
return PsiTreeUtil.getChildOfType(this, M68kLocalLabel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -145,7 +145,6 @@ private InstructionOnly ::= Instruction
|
||||
|
||||
LocalLabel ::= LOCAL_LABEL_DEF COLON? {
|
||||
name = "local label"
|
||||
extends = Label
|
||||
implements = "de.platon42.intellij.plugins.m68k.psi.M68kNamedElement"
|
||||
mixin = "de.platon42.intellij.plugins.m68k.psi.M68kLocalLabelMixin"
|
||||
methods = [getName setName getNameIdentifier]
|
||||
@ -153,7 +152,6 @@ LocalLabel ::= LOCAL_LABEL_DEF COLON? {
|
||||
|
||||
GlobalLabel ::= GLOBAL_LABEL_DEF COLON* {
|
||||
name = "global label"
|
||||
extends = Label
|
||||
implements = "de.platon42.intellij.plugins.m68k.psi.M68kNamedElement"
|
||||
mixin = "de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabelMixin"
|
||||
elementTypeFactory = "de.platon42.intellij.plugins.m68k.stubs.M68kStubElementTypeFactory.stubFactory"
|
||||
@ -161,7 +159,7 @@ GlobalLabel ::= GLOBAL_LABEL_DEF COLON* {
|
||||
methods = [getName setName getNameIdentifier]
|
||||
}
|
||||
|
||||
Label ::= LocalLabel | GlobalLabel
|
||||
private Label ::= LocalLabel | GlobalLabel
|
||||
|
||||
OperandSize ::= (OPSIZE_BS|OPSIZE_W|OPSIZE_L) { name = ".s|.b|.w|.l" }
|
||||
AddressSize ::= (OPSIZE_W|OPSIZE_L) { name = ".w|.l" }
|
||||
|
@ -38,6 +38,11 @@ internal class ExpressionsTest : AbstractParsingTest() {
|
||||
testGoodSyntax(testCase, "FOO = -(~(!!(+(1//~WIDTH^@123+%100101*4/2+(NARF%10|32!21))<<2)>>1)&$1f)\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun comparing_expressions(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
testGoodSyntax(testCase, "FOO = ((WIDTH<20)&&(HEIGHT<=10))||((WIDTH>=40)&&(HEIGHT>=128))&&(WIDTH!=0)&&(HEIGHT<>0)=1\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun current_pc_symbol_relative_expression(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
testGoodSyntax(testCase, " dc.w *-.label\n")
|
||||
|
@ -0,0 +1,89 @@
|
||||
Assembly File: a.asm
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAssignmentImpl(ASSIGNMENT)
|
||||
M68kSymbolDefinitionImpl(SYMBOL_DEFINITION)
|
||||
PsiElement(M68kTokenType.SYMBOLDEF)('FOO')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.OP_ASSIGN)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kBinaryLogicalOrExprImpl(BINARY_LOGICAL_OR_EXPR)
|
||||
M68kParenExprImpl(PAREN_EXPR)
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kBinaryLogicalAndExprImpl(BINARY_LOGICAL_AND_EXPR)
|
||||
M68kParenExprImpl(PAREN_EXPR)
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kBinaryCmpLtExprImpl(BINARY_CMP_LT_EXPR)
|
||||
M68kRefExprImpl(REF_EXPR)
|
||||
M68kSymbolReferenceImpl(SYMBOL_REFERENCE)
|
||||
PsiElement(M68kTokenType.SYMBOL)('WIDTH')
|
||||
PsiElement(M68kTokenType.OP_CMP_LT)('<')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('20')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.OP_LOGICAL_AND)('&&')
|
||||
M68kParenExprImpl(PAREN_EXPR)
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kBinaryCmpLeExprImpl(BINARY_CMP_LE_EXPR)
|
||||
M68kRefExprImpl(REF_EXPR)
|
||||
M68kSymbolReferenceImpl(SYMBOL_REFERENCE)
|
||||
PsiElement(M68kTokenType.SYMBOL)('HEIGHT')
|
||||
PsiElement(M68kTokenType.OP_CMP_LT_EQ)('<=')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('10')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.OP_LOGICAL_OR)('||')
|
||||
M68kBinaryLogicalAndExprImpl(BINARY_LOGICAL_AND_EXPR)
|
||||
M68kBinaryLogicalAndExprImpl(BINARY_LOGICAL_AND_EXPR)
|
||||
M68kParenExprImpl(PAREN_EXPR)
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kBinaryLogicalAndExprImpl(BINARY_LOGICAL_AND_EXPR)
|
||||
M68kParenExprImpl(PAREN_EXPR)
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kBinaryCmpGeExprImpl(BINARY_CMP_GE_EXPR)
|
||||
M68kRefExprImpl(REF_EXPR)
|
||||
M68kSymbolReferenceImpl(SYMBOL_REFERENCE)
|
||||
PsiElement(M68kTokenType.SYMBOL)('WIDTH')
|
||||
PsiElement(M68kTokenType.OP_CMP_GT_EQ)('>=')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('40')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.OP_LOGICAL_AND)('&&')
|
||||
M68kParenExprImpl(PAREN_EXPR)
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kBinaryCmpGeExprImpl(BINARY_CMP_GE_EXPR)
|
||||
M68kRefExprImpl(REF_EXPR)
|
||||
M68kSymbolReferenceImpl(SYMBOL_REFERENCE)
|
||||
PsiElement(M68kTokenType.SYMBOL)('HEIGHT')
|
||||
PsiElement(M68kTokenType.OP_CMP_GT_EQ)('>=')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('128')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.OP_LOGICAL_AND)('&&')
|
||||
M68kParenExprImpl(PAREN_EXPR)
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kBinaryCmpNeExprImpl(BINARY_CMP_NE_EXPR)
|
||||
M68kRefExprImpl(REF_EXPR)
|
||||
M68kSymbolReferenceImpl(SYMBOL_REFERENCE)
|
||||
PsiElement(M68kTokenType.SYMBOL)('WIDTH')
|
||||
PsiElement(M68kTokenType.OP_CMP_NOT_EQ)('!=')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('0')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.OP_LOGICAL_AND)('&&')
|
||||
M68kBinaryCmpEqExprImpl(BINARY_CMP_EQ_EXPR)
|
||||
M68kParenExprImpl(PAREN_EXPR)
|
||||
PsiElement(M68kTokenType.ROUND_L)('(')
|
||||
M68kBinaryCmpNeExprImpl(BINARY_CMP_NE_EXPR)
|
||||
M68kRefExprImpl(REF_EXPR)
|
||||
M68kSymbolReferenceImpl(SYMBOL_REFERENCE)
|
||||
PsiElement(M68kTokenType.SYMBOL)('HEIGHT')
|
||||
PsiElement(M68kTokenType.OP_CMP_NOT_EQ)('<>')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('0')
|
||||
PsiElement(M68kTokenType.ROUND_R)(')')
|
||||
PsiElement(M68kTokenType.OP_CMP_EQ)('=')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('1')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
Loading…
Reference in New Issue
Block a user