Nosfe also likes to place assignments with colons. Fixed assignment symbol detection (again :-/).
This commit is contained in:
parent
213150e51f
commit
d53a1fbac8
File diff suppressed because it is too large
Load Diff
@ -411,7 +411,7 @@ public class M68kParser implements PsiParser, LightPsiParser {
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// SYMBOLDEF (OP_ASSIGN|EQU) expr
|
||||
// SYMBOLDEF COLON? (OP_ASSIGN|EQU) expr
|
||||
public static boolean Assignment(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "Assignment")) return false;
|
||||
if (!nextTokenIs(b, SYMBOLDEF)) return false;
|
||||
@ -419,14 +419,22 @@ public class M68kParser implements PsiParser, LightPsiParser {
|
||||
Marker m = enter_section_(b);
|
||||
r = consumeToken(b, SYMBOLDEF);
|
||||
r = r && Assignment_1(b, l + 1);
|
||||
r = r && Assignment_2(b, l + 1);
|
||||
r = r && expr(b, l + 1, -1);
|
||||
exit_section_(b, m, ASSIGNMENT, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// OP_ASSIGN|EQU
|
||||
// COLON?
|
||||
private static boolean Assignment_1(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "Assignment_1")) return false;
|
||||
consumeToken(b, COLON);
|
||||
return true;
|
||||
}
|
||||
|
||||
// OP_ASSIGN|EQU
|
||||
private static boolean Assignment_2(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "Assignment_2")) return false;
|
||||
boolean r;
|
||||
r = consumeToken(b, OP_ASSIGN);
|
||||
if (!r) r = consumeToken(b, EQU);
|
||||
|
@ -71,6 +71,7 @@ public interface M68kTypes {
|
||||
|
||||
IElementType AREG = new M68kTokenType("AREG");
|
||||
IElementType BINARY = new M68kTokenType("BINARY");
|
||||
IElementType COLON = new M68kTokenType("COLON");
|
||||
IElementType COMMENT = new M68kTokenType("COMMENT");
|
||||
IElementType CURRENT_PC_SYMBOL = new M68kTokenType("CURRENT_PC_SYMBOL");
|
||||
IElementType DATA_DIRECTIVE = new M68kTokenType("DATA_DIRECTIVE");
|
||||
|
@ -5,7 +5,7 @@ import de.platon42.intellij.plugins.m68k.asm.M68kIsa.mnemonics
|
||||
|
||||
object LexerUtil {
|
||||
|
||||
private val ASSIGNMENT_SEPARATORS = charArrayOf(' ', '\t')
|
||||
private val ASSIGNMENT_SEPARATORS = charArrayOf(' ', '\t', '=', ':')
|
||||
|
||||
@JvmStatic
|
||||
fun isAsmMnemonic(text: CharSequence) = mnemonics.contains(text.toString().lowercase())
|
||||
@ -23,10 +23,6 @@ object LexerUtil {
|
||||
|
||||
@JvmStatic
|
||||
fun pushbackAssignment(text: CharSequence): Int {
|
||||
val spacePos = text.indexOfAny(ASSIGNMENT_SEPARATORS)
|
||||
if (spacePos > -1) {
|
||||
return text.length - spacePos
|
||||
}
|
||||
return text.length - text.indexOf('=')
|
||||
return text.length - text.indexOfAny(ASSIGNMENT_SEPARATORS)
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ EOL=\R
|
||||
WHITE_SPACE=\p{Blank}+
|
||||
AREG=((a[0-7])|sp)
|
||||
DREG=(d[0-7])
|
||||
ASSIGNMENT=(([:letter:]|_)(([:letter:]|[:digit:])|_)*((\p{Blank}+equ\p{Blank}+)|(\p{Blank}+set\p{Blank}+)|\p{Blank}*=\p{Blank}*))
|
||||
ASSIGNMENT=(([:letter:]|_)(([:letter:]|[:digit:])|_)*:?((\p{Blank}+equ\p{Blank}+)|(\p{Blank}+set\p{Blank}+)|\p{Blank}*=\p{Blank}*))
|
||||
LOCAL_LABEL=(\.([:letter:]|_)(([:letter:]|[:digit:])|_)*:?)|(([:letter:]|_)(([:letter:]|[:digit:])|_)*\$:?)
|
||||
LOCAL_LABEL_WC=(\.([:letter:]|_)(([:letter:]|[:digit:])|_)*:)|(([:letter:]|_)(([:letter:]|[:digit:])|_)*\$:)
|
||||
GLOBAL_LABEL=(([:letter:]|_)(([:letter:]|[:digit:])|_)*:?:?)
|
||||
@ -125,6 +125,7 @@ HASH_COMMENT=([#;*].*+)
|
||||
|
||||
"equ"|"set" { yybegin(EXPR); return EQU; }
|
||||
|
||||
":" { return COLON; }
|
||||
"=" { yybegin(EXPR); return OP_ASSIGN; }
|
||||
|
||||
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
|
||||
|
@ -126,7 +126,7 @@ statement ::= (Assignment
|
||||
|
||||
private statement_recover ::= !(EOL)
|
||||
|
||||
Assignment ::= SYMBOLDEF (OP_ASSIGN|EQU) expr
|
||||
Assignment ::= SYMBOLDEF COLON? (OP_ASSIGN|EQU) expr
|
||||
|
||||
private LabelInsts ::= LabelWithInstruction | LabelOnly | InstructionOnly
|
||||
|
||||
|
@ -20,7 +20,17 @@ internal class AssignmentTest : AbstractParsingTest() {
|
||||
|
||||
@Test
|
||||
internal fun assignment_with_local_label(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
testGoodSyntax(testCase, "FOO=.local-.bar\n")
|
||||
testGoodSyntax(testCase, "FOO= .local-.bar\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun assignment_with_colon(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
testGoodSyntax(testCase, "FOO: = 123\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun assignment_with_colon_and_set(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
testGoodSyntax(testCase, "FOO: set 123\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -0,0 +1,11 @@
|
||||
Assembly File: a.asm
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAssignmentImpl(ASSIGNMENT)
|
||||
PsiElement(M68kTokenType.SYMBOLDEF)('FOO')
|
||||
PsiElement(M68kTokenType.COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.OP_ASSIGN)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('123')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
@ -0,0 +1,11 @@
|
||||
Assembly File: a.asm
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAssignmentImpl(ASSIGNMENT)
|
||||
PsiElement(M68kTokenType.SYMBOLDEF)('FOO')
|
||||
PsiElement(M68kTokenType.COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.EQU)('set')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('123')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
@ -3,6 +3,7 @@ Assembly File: a.asm
|
||||
M68kAssignmentImpl(ASSIGNMENT)
|
||||
PsiElement(M68kTokenType.SYMBOLDEF)('FOO')
|
||||
PsiElement(M68kTokenType.OP_ASSIGN)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kBinarySubExprImpl(BINARY_SUB_EXPR)
|
||||
M68kRefExprImpl(REF_EXPR)
|
||||
PsiElement(M68kTokenType.SYMBOL)('.local')
|
||||
|
Loading…
Reference in New Issue
Block a user