Added support for single = as comparison in expressions.

This commit is contained in:
Chris Hodges 2021-07-16 12:01:39 +02:00
parent 99ba1014e1
commit 84104c86cd
4 changed files with 106 additions and 90 deletions

View File

@ -194,20 +194,20 @@ public class _M68kLexer implements FlexLexer {
"\1\2\1\7\1\10\1\1\1\11\2\12\1\7\1\10" + "\1\2\1\7\1\10\1\1\1\11\2\12\1\7\1\10" +
"\1\13\1\14\1\1\1\15\1\16\5\15\6\1\1\17" + "\1\13\1\14\1\1\1\15\1\16\5\15\6\1\1\17" +
"\1\20\1\21\1\22\1\23\1\24\1\25\1\26\1\27" + "\1\20\1\21\1\22\1\23\1\24\1\25\1\26\1\27" +
"\1\30\2\15\1\31\1\1\1\31\1\32\1\33\1\34" + "\1\30\2\15\1\31\1\32\1\31\1\33\1\34\1\35" +
"\1\35\1\36\1\37\1\40\1\41\1\42\1\43\1\44" + "\1\36\1\37\1\40\1\41\1\42\1\43\1\44\1\45" +
"\1\45\1\46\1\41\1\47\2\1\1\50\1\51\1\52" + "\1\46\1\47\1\42\1\50\2\1\1\51\1\52\1\53" +
"\6\1\1\53\1\54\1\1\1\55\1\56\1\57\1\60" + "\6\1\1\54\1\55\1\56\1\57\1\60\1\61\1\62" +
"\1\61\1\62\1\63\1\64\1\65\1\66\1\67\1\70" + "\1\63\1\64\1\65\1\66\1\67\1\70\1\71\1\72" +
"\1\63\1\71\1\72\1\12\4\72\1\0\1\73\1\4" + "\1\65\1\73\1\74\1\12\4\74\1\0\1\75\1\4" +
"\2\74\3\0\1\75\1\76\1\77\1\100\1\101\1\102" + "\2\76\3\0\1\77\1\100\1\101\1\102\1\103\1\104" +
"\1\103\1\15\1\104\1\105\1\106\1\0\1\107\5\0" + "\1\105\1\15\1\106\1\107\1\110\1\0\1\111\5\0" +
"\2\15\1\110\1\75\1\76\1\77\1\111\1\112\1\113" + "\2\15\1\32\1\77\1\100\1\101\1\112\1\113\1\114" +
"\1\114\1\115\1\116\1\117\2\0\1\120\1\121\1\122" + "\1\115\1\116\1\117\1\120\2\0\1\121\1\122\1\123" +
"\1\0\1\123\5\0\1\124\1\125\1\126\1\127\1\130" + "\1\0\1\124\5\0\1\56\1\125\1\126\1\127\1\130" +
"\1\131\1\132\1\133\1\0\1\72\1\0\1\72\1\0" + "\1\131\1\132\1\133\1\0\1\74\1\0\1\74\1\0" +
"\1\72\1\0\1\72\2\0\1\4\1\74\1\7\1\134" + "\1\74\1\0\1\74\2\0\1\4\1\76\1\7\1\134" +
"\1\135\1\136\1\137\1\72\7\0"; "\1\135\1\136\1\137\1\74\7\0";
private static int[] zzUnpackAction() { private static int[] zzUnpackAction() {
int[] result = new int[193]; int[] result = new int[193];
@ -936,409 +936,409 @@ public class _M68kLexer implements FlexLexer {
break; break;
case 26: { case 26: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_AR_MOD; return OP_CMP_EQ;
} }
// fall through // fall through
case 121: case 121:
break; break;
case 27: { case 27: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_CMP_LT; return OP_AR_MOD;
} }
// fall through // fall through
case 122: case 122:
break; break;
case 28: { case 28: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_CMP_GT; return OP_CMP_LT;
} }
// fall through // fall through
case 123: case 123:
break; break;
case 29: { case 29: {
yybegin(ASMOPS); yybegin(ASMOPS);
return SEPARATOR; return OP_CMP_GT;
} }
// fall through // fall through
case 124: case 124:
break; break;
case 30: { case 30: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_BITWISE_XOR; return SEPARATOR;
} }
// fall through // fall through
case 125: case 125:
break; break;
case 31: { case 31: {
yybegin(ASMOPS); yybegin(ASMOPS);
return ROUND_L; return OP_BITWISE_XOR;
} }
// fall through // fall through
case 126: case 126:
break; break;
case 32: { case 32: {
return ROUND_R; yybegin(ASMOPS);
return ROUND_L;
} }
// fall through // fall through
case 127: case 127:
break; break;
case 33: { case 33: {
yybegin(ASMOPS); return ROUND_R;
return OP_BITWISE_OR;
} }
// fall through // fall through
case 128: case 128:
break; break;
case 34: { case 34: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_UNARY_COMPL; return OP_BITWISE_OR;
} }
// fall through // fall through
case 129: case 129:
break; break;
case 35: { case 35: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_PLUS; return OP_UNARY_COMPL;
} }
// fall through // fall through
case 130: case 130:
break; break;
case 36: { case 36: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_MINUS; return OP_PLUS;
} }
// fall through // fall through
case 131: case 131:
break; break;
case 37: { case 37: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_AR_MUL; return OP_MINUS;
} }
// fall through // fall through
case 132: case 132:
break; break;
case 38: { case 38: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_BITWISE_AND; return OP_AR_MUL;
} }
// fall through // fall through
case 133: case 133:
break; break;
case 39: { case 39: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_AR_DIV; return OP_BITWISE_AND;
} }
// fall through // fall through
case 134: case 134:
break; break;
case 40: { case 40: {
yybegin(EXPR); yybegin(ASMOPS);
return OP_ASSIGN; return OP_AR_DIV;
} }
// fall through // fall through
case 135: case 135:
break; break;
case 41: { case 41: {
yybegin(EXPR_OP); yybegin(EXPR);
return SYMBOL; return OP_ASSIGN;
} }
// fall through // fall through
case 136: case 136:
break; break;
case 42: { case 42: {
yybegin(EXPR_OP); yybegin(EXPR_OP);
return DECIMAL; return SYMBOL;
} }
// fall through // fall through
case 137: case 137:
break; break;
case 43: { case 43: {
yybegin(EXPR_OP); yybegin(EXPR_OP);
return ROUND_R; return DECIMAL;
} }
// fall through // fall through
case 138: case 138:
break; break;
case 44: { case 44: {
yybegin(EXPR_OP); yybegin(EXPR_OP);
return CURRENT_PC_SYMBOL; return ROUND_R;
} }
// fall through // fall through
case 139: case 139:
break; break;
case 45: { case 45: {
yybegin(EXPR); yybegin(EXPR_OP);
return OP_AR_MOD; return CURRENT_PC_SYMBOL;
} }
// fall through // fall through
case 140: case 140:
break; break;
case 46: { case 46: {
yybegin(EXPR); yybegin(EXPR);
return OP_CMP_LT; return OP_CMP_EQ;
} }
// fall through // fall through
case 141: case 141:
break; break;
case 47: { case 47: {
yybegin(EXPR); yybegin(EXPR);
return OP_CMP_GT; return OP_AR_MOD;
} }
// fall through // fall through
case 142: case 142:
break; break;
case 48: { case 48: {
yybegin(EXPR); yybegin(EXPR);
return SEPARATOR; return OP_CMP_LT;
} }
// fall through // fall through
case 143: case 143:
break; break;
case 49: { case 49: {
yybegin(EXPR); yybegin(EXPR);
return OP_BITWISE_XOR; return OP_CMP_GT;
} }
// fall through // fall through
case 144: case 144:
break; break;
case 50: { case 50: {
yybegin(EXPR); yybegin(EXPR);
return ROUND_L; return SEPARATOR;
} }
// fall through // fall through
case 145: case 145:
break; break;
case 51: { case 51: {
yybegin(EXPR); yybegin(EXPR);
return OP_BITWISE_OR; return OP_BITWISE_XOR;
} }
// fall through // fall through
case 146: case 146:
break; break;
case 52: { case 52: {
yybegin(EXPR); yybegin(EXPR);
return OP_UNARY_COMPL; return ROUND_L;
} }
// fall through // fall through
case 147: case 147:
break; break;
case 53: { case 53: {
yybegin(EXPR); yybegin(EXPR);
return OP_PLUS; return OP_BITWISE_OR;
} }
// fall through // fall through
case 148: case 148:
break; break;
case 54: { case 54: {
yybegin(EXPR); yybegin(EXPR);
return OP_MINUS; return OP_UNARY_COMPL;
} }
// fall through // fall through
case 149: case 149:
break; break;
case 55: { case 55: {
yybegin(EXPR); yybegin(EXPR);
return OP_AR_MUL; return OP_PLUS;
} }
// fall through // fall through
case 150: case 150:
break; break;
case 56: { case 56: {
yybegin(EXPR); yybegin(EXPR);
return OP_BITWISE_AND; return OP_MINUS;
} }
// fall through // fall through
case 151: case 151:
break; break;
case 57: { case 57: {
yybegin(EXPR); yybegin(EXPR);
return OP_AR_DIV; return OP_AR_MUL;
} }
// fall through // fall through
case 152: case 152:
break; break;
case 58: { case 58: {
return STRINGLIT; yybegin(EXPR);
return OP_BITWISE_AND;
} }
// fall through // fall through
case 153: case 153:
break; break;
case 59: { case 59: {
yybegin(ASSIGNMENT); yybegin(EXPR);
yypushback(pushbackAssignment(yytext())); return OP_AR_DIV;
return SYMBOLDEF;
} }
// fall through // fall through
case 154: case 154:
break; break;
case 60: { case 60: {
yybegin(INSTRPART); return STRINGLIT;
return LOCAL_LABEL_DEF;
} }
// fall through // fall through
case 155: case 155:
break; break;
case 61: { case 61: {
return OPSIZE_BS; yybegin(ASSIGNMENT);
yypushback(pushbackAssignment(yytext()));
return SYMBOLDEF;
} }
// fall through // fall through
case 156: case 156:
break; break;
case 62: { case 62: {
return OPSIZE_W; yybegin(INSTRPART);
return LOCAL_LABEL_DEF;
} }
// fall through // fall through
case 157: case 157:
break; break;
case 63: { case 63: {
return OPSIZE_L; return OPSIZE_BS;
} }
// fall through // fall through
case 158: case 158:
break; break;
case 64: { case 64: {
yybegin(ASMOPS_OP); return OPSIZE_W;
return AREG;
} }
// fall through // fall through
case 159: case 159:
break; break;
case 65: { case 65: {
yybegin(ASMOPS_OP); return OPSIZE_L;
return REG_SR;
} }
// fall through // fall through
case 160: case 160:
break; break;
case 66: { case 66: {
yybegin(ASMOPS_OP); yybegin(ASMOPS_OP);
return PC; return AREG;
} }
// fall through // fall through
case 161: case 161:
break; break;
case 67: { case 67: {
yybegin(ASMOPS_OP); yybegin(ASMOPS_OP);
return DREG; return REG_SR;
} }
// fall through // fall through
case 162: case 162:
break; break;
case 68: { case 68: {
yybegin(ASMOPS_OP); yybegin(ASMOPS_OP);
return HEXADECIMAL; return PC;
} }
// fall through // fall through
case 163: case 163:
break; break;
case 69: { case 69: {
yybegin(ASMOPS_OP); yybegin(ASMOPS_OP);
return BINARY; return DREG;
} }
// fall through // fall through
case 164: case 164:
break; break;
case 70: { case 70: {
yybegin(ASMOPS_OP); yybegin(ASMOPS_OP);
return OCTAL; return HEXADECIMAL;
} }
// fall through // fall through
case 165: case 165:
break; break;
case 71: { case 71: {
yybegin(ASMOPS_OP); yybegin(ASMOPS_OP);
return STRINGLIT; return BINARY;
} }
// fall through // fall through
case 166: case 166:
break; break;
case 72: { case 72: {
yybegin(ASMOPS); yybegin(ASMOPS_OP);
return OP_CMP_EQ; return OCTAL;
} }
// fall through // fall through
case 167: case 167:
break; break;
case 73: { case 73: {
yybegin(ASMOPS); yybegin(ASMOPS_OP);
return OP_CMP_LT_EQ; return STRINGLIT;
} }
// fall through // fall through
case 168: case 168:
break; break;
case 74: { case 74: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_AR_SHIFT_L; return OP_CMP_LT_EQ;
} }
// fall through // fall through
case 169: case 169:
break; break;
case 75: { case 75: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_CMP_NOT_EQ; return OP_AR_SHIFT_L;
} }
// fall through // fall through
case 170: case 170:
break; break;
case 76: { case 76: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_CMP_GT_EQ; return OP_CMP_NOT_EQ;
} }
// fall through // fall through
case 171: case 171:
break; break;
case 77: { case 77: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_AR_SHIFT_R; return OP_CMP_GT_EQ;
} }
// fall through // fall through
case 172: case 172:
break; break;
case 78: { case 78: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_LOGICAL_AND; return OP_AR_SHIFT_R;
} }
// fall through // fall through
case 173: case 173:
break; break;
case 79: { case 79: {
yybegin(ASMOPS); yybegin(ASMOPS);
return OP_LOGICAL_OR; return OP_LOGICAL_AND;
} }
// fall through // fall through
case 174: case 174:
break; break;
case 80: { case 80: {
yybegin(EXPR_OP); yybegin(ASMOPS);
return HEXADECIMAL; return OP_LOGICAL_OR;
} }
// fall through // fall through
case 175: case 175:
break; break;
case 81: { case 81: {
yybegin(EXPR_OP); yybegin(EXPR_OP);
return BINARY; return HEXADECIMAL;
} }
// fall through // fall through
case 176: case 176:
break; break;
case 82: { case 82: {
yybegin(EXPR_OP); yybegin(EXPR_OP);
return OCTAL; return BINARY;
} }
// fall through // fall through
case 177: case 177:
break; break;
case 83: { case 83: {
yybegin(EXPR_OP); yybegin(EXPR_OP);
return STRINGLIT; return OCTAL;
} }
// fall through // fall through
case 178: case 178:
break; break;
case 84: { case 84: {
yybegin(EXPR); yybegin(EXPR_OP);
return OP_CMP_EQ; return STRINGLIT;
} }
// fall through // fall through
case 179: case 179:

View File

@ -162,7 +162,7 @@ HASH_COMMENT=([#;*].*+)
">>" { yybegin(EXPR); return OP_AR_SHIFT_R; } ">>" { yybegin(EXPR); return OP_AR_SHIFT_R; }
"&&" { yybegin(EXPR); return OP_LOGICAL_AND; } "&&" { yybegin(EXPR); return OP_LOGICAL_AND; }
"||" { yybegin(EXPR); return OP_LOGICAL_OR; } "||" { yybegin(EXPR); return OP_LOGICAL_OR; }
"==" { yybegin(EXPR); return OP_CMP_EQ; } "=="|"=" { yybegin(EXPR); return OP_CMP_EQ; }
"<>"|"!=" { yybegin(EXPR); return OP_CMP_NOT_EQ; } "<>"|"!=" { yybegin(EXPR); return OP_CMP_NOT_EQ; }
">=" { yybegin(EXPR); return OP_CMP_GT_EQ; } ">=" { yybegin(EXPR); return OP_CMP_GT_EQ; }
"<=" { yybegin(EXPR); return OP_CMP_LT_EQ; } "<=" { yybegin(EXPR); return OP_CMP_LT_EQ; }
@ -180,7 +180,6 @@ HASH_COMMENT=([#;*].*+)
")" { return ROUND_R; } ")" { return ROUND_R; }
// "." { return DOT; } // "." { return DOT; }
// "$" { return DOLLAR; } // "$" { return DOLLAR; }
// "=" { yybegin(EXPR); return OP_ASSIGN; }
"~" { yybegin(EXPR); return OP_UNARY_COMPL; } "~" { yybegin(EXPR); return OP_UNARY_COMPL; }
"+" { yybegin(EXPR); return OP_PLUS; } "+" { yybegin(EXPR); return OP_PLUS; }
"-" { yybegin(EXPR); return OP_MINUS; } "-" { yybegin(EXPR); return OP_MINUS; }
@ -238,7 +237,7 @@ HASH_COMMENT=([#;*].*+)
">>" { yybegin(ASMOPS); return OP_AR_SHIFT_R; } ">>" { yybegin(ASMOPS); return OP_AR_SHIFT_R; }
"&&" { yybegin(ASMOPS); return OP_LOGICAL_AND; } "&&" { yybegin(ASMOPS); return OP_LOGICAL_AND; }
"||" { yybegin(ASMOPS); return OP_LOGICAL_OR; } "||" { yybegin(ASMOPS); return OP_LOGICAL_OR; }
"==" { yybegin(ASMOPS); return OP_CMP_EQ; } "=="|"=" { yybegin(ASMOPS); return OP_CMP_EQ; }
"<>"|"!=" { yybegin(ASMOPS); return OP_CMP_NOT_EQ; } "<>"|"!=" { yybegin(ASMOPS); return OP_CMP_NOT_EQ; }
">=" { yybegin(ASMOPS); return OP_CMP_GT_EQ; } ">=" { yybegin(ASMOPS); return OP_CMP_GT_EQ; }
"<=" { yybegin(ASMOPS); return OP_CMP_LT_EQ; } "<=" { yybegin(ASMOPS); return OP_CMP_LT_EQ; }
@ -256,7 +255,6 @@ HASH_COMMENT=([#;*].*+)
")" { return ROUND_R; } ")" { return ROUND_R; }
// "." { return DOT; } // "." { return DOT; }
// "$" { return DOLLAR; } // "$" { return DOLLAR; }
// "=" { return OP_ASSIGN; }
"~" { yybegin(ASMOPS); return OP_UNARY_COMPL; } "~" { yybegin(ASMOPS); return OP_UNARY_COMPL; }
"+" { yybegin(ASMOPS); return OP_PLUS; } "+" { yybegin(ASMOPS); return OP_PLUS; }
"-" { yybegin(ASMOPS); return OP_MINUS; } "-" { yybegin(ASMOPS); return OP_MINUS; }

View File

@ -43,4 +43,9 @@ internal class ExpressionsTest : AbstractParsingTest() {
internal fun current_pc_symbol_relative_expression(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { internal fun current_pc_symbol_relative_expression(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " dc.w *-.label\n") testGoodSyntax(testCase, " dc.w *-.label\n")
} }
@Test
internal fun if_with_single_equals_comparison(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, " IF DEBUG=1\n")
}
} }

View File

@ -0,0 +1,13 @@
Assembly File: a.asm
PsiWhiteSpace(' ')
M68kStatementImpl(STATEMENT)
M68kPreprocessorDirectiveImpl(PREPROCESSOR_DIRECTIVE)
PsiElement(M68kTokenType.OTHER_DIRECTIVE)('IF')
PsiWhiteSpace(' ')
M68kBinaryCmpEqExprImpl(BINARY_CMP_EQ_EXPR)
M68kRefExprImpl(REF_EXPR)
PsiElement(M68kTokenType.SYMBOL)('DEBUG')
PsiElement(M68kTokenType.OP_CMP_EQ)('=')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.DECIMAL)('1')
PsiElement(M68kTokenType.EOL)('\n')