Added M68kLexerPrefs (preliminary). Added support for optional space-introducing comments.
This commit is contained in:
parent
618a4eee01
commit
349372f6b3
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,7 @@
|
||||
package de.platon42.intellij.plugins.m68k.lexer
|
||||
|
||||
import com.intellij.psi.TokenType
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import de.platon42.intellij.plugins.m68k.asm.AssemblerDirectives
|
||||
import de.platon42.intellij.plugins.m68k.asm.M68kIsa.mnemonics
|
||||
|
||||
@ -30,4 +32,13 @@ object LexerUtil {
|
||||
fun pushbackLabelColons(text: CharSequence): Int {
|
||||
return text.count { it == ':' }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun handleEolCommentWhitespace(lexer: _M68kLexer): IElementType {
|
||||
if (!lexer.eatOneWhitespace && lexer.lexerPrefs.spaceIntroducesComment) {
|
||||
lexer.yybegin(_M68kLexer.WAITEOL)
|
||||
}
|
||||
lexer.eatOneWhitespace = false;
|
||||
return TokenType.WHITE_SPACE
|
||||
}
|
||||
}
|
@ -2,4 +2,4 @@ package de.platon42.intellij.plugins.m68k.lexer
|
||||
|
||||
import com.intellij.lexer.FlexAdapter
|
||||
|
||||
class M68kLexer : FlexAdapter(_M68kLexer())
|
||||
class M68kLexer(lexerPrefs: M68kLexerPrefs) : FlexAdapter(_M68kLexer(lexerPrefs))
|
@ -0,0 +1,8 @@
|
||||
package de.platon42.intellij.plugins.m68k.lexer
|
||||
|
||||
data class M68kLexerPrefs(
|
||||
var spaceIntroducesComment: Boolean = false,
|
||||
var maxLinesPerMacro: Int = 50,
|
||||
var macroSectionUnparsed: Boolean = false,
|
||||
var macroParametersUnparsed: Boolean = true
|
||||
)
|
@ -11,8 +11,17 @@ import static de.platon42.intellij.plugins.m68k.lexer.LexerUtil.*;
|
||||
%%
|
||||
|
||||
%{
|
||||
public _M68kLexer() {
|
||||
this((java.io.Reader)null);
|
||||
private M68kLexerPrefs lexerPrefs;
|
||||
boolean eatOneWhitespace = false;
|
||||
|
||||
public M68kLexerPrefs getLexerPrefs()
|
||||
{
|
||||
return lexerPrefs;
|
||||
}
|
||||
|
||||
public _M68kLexer(M68kLexerPrefs lexerPrefs) {
|
||||
this((java.io.Reader)null);
|
||||
this.lexerPrefs = lexerPrefs;
|
||||
}
|
||||
%}
|
||||
|
||||
@ -49,16 +58,17 @@ STRINGLIT=(`([^`\\\r\n]|\\.)*`|'([^'\\\r\n]|\\.)*'|\"([^\"\\\r\n]|\\.)*\")
|
||||
PLAINPARAM=(`([^`\\\r\n]|\\.)*`|'([^'\\\r\n]|\\.)*'|\"([^\"\\\r\n]|\\.)*\")|<([^>\\\r\n]|\\.)*>|([^,;\p{Blank}\r\n])+ // why does \R not work, I have no idea
|
||||
COMMENT=([;].*+)
|
||||
HASH_COMMENT=([#;*].*+)
|
||||
SKIP_TO_EOL=[^\r\n]+
|
||||
|
||||
%state NOSOL,INSTRPART,ASMINSTR,ASMOPS,ASMOPS_OP,ASSIGNMENT,EXPR,EXPR_OP,MACROCALL,WAITEOL
|
||||
|
||||
%%
|
||||
<YYINITIAL> {
|
||||
{WHITE_SPACE} { yybegin(NOSOL); return WHITE_SPACE; }
|
||||
{WHITE_SPACE} { yybegin(NOSOL); eatOneWhitespace = false; return WHITE_SPACE; }
|
||||
{EOL} { return WHITE_SPACE; }
|
||||
{ASSIGNMENT} { yybegin(ASSIGNMENT); yypushback(pushbackAssignment(yytext())); return SYMBOLDEF; }
|
||||
{LOCAL_LABEL} { yybegin(INSTRPART); yypushback(pushbackLabelColons(yytext())); return LOCAL_LABEL_DEF; }
|
||||
{GLOBAL_LABEL} { yybegin(INSTRPART); yypushback(pushbackLabelColons(yytext())); return GLOBAL_LABEL_DEF; }
|
||||
{ASSIGNMENT} { yybegin(ASSIGNMENT); eatOneWhitespace = true; yypushback(pushbackAssignment(yytext())); return SYMBOLDEF; }
|
||||
{LOCAL_LABEL} { yybegin(INSTRPART); eatOneWhitespace = false; yypushback(pushbackLabelColons(yytext())); return LOCAL_LABEL_DEF; }
|
||||
{GLOBAL_LABEL} { yybegin(INSTRPART); eatOneWhitespace = false; yypushback(pushbackLabelColons(yytext())); return GLOBAL_LABEL_DEF; }
|
||||
|
||||
{HASH_COMMENT} { return COMMENT; }
|
||||
}
|
||||
@ -73,10 +83,10 @@ HASH_COMMENT=([#;*].*+)
|
||||
if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; }
|
||||
if(isDataDirective(yytext())) { yybegin(EXPR); return DATA_DIRECTIVE; }
|
||||
if(isOtherDirective(yytext())) { yybegin(EXPR); return OTHER_DIRECTIVE; }
|
||||
yybegin(MACROCALL); return MACRO_INVOKATION;
|
||||
yybegin(MACROCALL); eatOneWhitespace = true; return MACRO_INVOKATION;
|
||||
}
|
||||
// {MNEMONIC} { if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; } else { yybegin(INSTRPART); return SYMBOL; } }
|
||||
{MACRONAME} { yybegin(MACROCALL); return MACRO_INVOKATION; }
|
||||
{MACRONAME} { yybegin(MACROCALL); eatOneWhitespace = true; return MACRO_INVOKATION; }
|
||||
{HASH_COMMENT} { yybegin(YYINITIAL); return COMMENT; }
|
||||
}
|
||||
|
||||
@ -91,10 +101,10 @@ HASH_COMMENT=([#;*].*+)
|
||||
if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; }
|
||||
if(isDataDirective(yytext())) { yybegin(EXPR); return DATA_DIRECTIVE; }
|
||||
if(isOtherDirective(yytext())) { yybegin(EXPR); return OTHER_DIRECTIVE; }
|
||||
yybegin(MACROCALL); return MACRO_INVOKATION;
|
||||
yybegin(MACROCALL); eatOneWhitespace = true; return MACRO_INVOKATION;
|
||||
}
|
||||
// {MNEMONIC} { if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; } else { return SYMBOL; } }
|
||||
{MACRONAME} { yybegin(MACROCALL); return MACRO_INVOKATION; }
|
||||
{MACRONAME} { yybegin(MACROCALL); eatOneWhitespace = true; return MACRO_INVOKATION; }
|
||||
|
||||
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
|
||||
}
|
||||
@ -111,7 +121,7 @@ HASH_COMMENT=([#;*].*+)
|
||||
}
|
||||
|
||||
<MACROCALL> {
|
||||
{WHITE_SPACE} { return WHITE_SPACE; } // FIXME space optionally introduces comment
|
||||
{WHITE_SPACE} { return handleEolCommentWhitespace(this); }
|
||||
{EOL} { yybegin(YYINITIAL); return EOL; }
|
||||
|
||||
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
|
||||
@ -134,7 +144,7 @@ HASH_COMMENT=([#;*].*+)
|
||||
}
|
||||
|
||||
<EXPR> {
|
||||
{WHITE_SPACE} { return WHITE_SPACE; } // FIXME space optionally introduces comment
|
||||
{WHITE_SPACE} { return handleEolCommentWhitespace(this); }
|
||||
{EOL} { yybegin(YYINITIAL); return EOL; }
|
||||
|
||||
{BINARY} { yybegin(EXPR_OP); return BINARY; }
|
||||
@ -159,7 +169,7 @@ HASH_COMMENT=([#;*].*+)
|
||||
}
|
||||
|
||||
<EXPR_OP> {
|
||||
{WHITE_SPACE} { return WHITE_SPACE; } // FIXME space optionally introduces comment
|
||||
{WHITE_SPACE} { return handleEolCommentWhitespace(this); }
|
||||
{EOL} { yybegin(YYINITIAL); return EOL; }
|
||||
|
||||
"<<" { yybegin(EXPR); return OP_AR_SHIFT_L; }
|
||||
@ -195,7 +205,7 @@ HASH_COMMENT=([#;*].*+)
|
||||
}
|
||||
|
||||
<ASMOPS> {
|
||||
{WHITE_SPACE} { return WHITE_SPACE; } // FIXME space optionally introduces comment
|
||||
{WHITE_SPACE} { return handleEolCommentWhitespace(this); }
|
||||
{EOL} { yybegin(YYINITIAL); return EOL; }
|
||||
|
||||
{BINARY} { yybegin(ASMOPS_OP); return BINARY; }
|
||||
@ -230,7 +240,7 @@ HASH_COMMENT=([#;*].*+)
|
||||
}
|
||||
|
||||
<ASMOPS_OP> {
|
||||
{WHITE_SPACE} { return WHITE_SPACE; } // FIXME space optionally introduces comment
|
||||
{WHITE_SPACE} { return handleEolCommentWhitespace(this); }
|
||||
{EOL} { yybegin(YYINITIAL); return EOL; }
|
||||
|
||||
{OPSIZE_BS} { return OPSIZE_BS; }
|
||||
@ -274,6 +284,7 @@ HASH_COMMENT=([#;*].*+)
|
||||
<WAITEOL>
|
||||
{
|
||||
{EOL} { yybegin(YYINITIAL); return EOL; }
|
||||
{SKIP_TO_EOL} { return COMMENT; }
|
||||
}
|
||||
|
||||
[^] { return BAD_CHARACTER; }
|
||||
|
@ -12,6 +12,7 @@ import com.intellij.psi.tree.IFileElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import de.platon42.intellij.plugins.m68k.M68kFileElementType;
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
@ -20,12 +21,19 @@ public class M68kParserDefinition implements ParserDefinition {
|
||||
public static final TokenSet STRING_LITERALS = TokenSet.create(M68kTypes.STRINGLIT);
|
||||
public static final TokenSet COMMENTS = TokenSet.create(M68kTypes.COMMENT);
|
||||
|
||||
private M68kLexerPrefs lexerPrefs = new M68kLexerPrefs(); // TODO make this configurable
|
||||
|
||||
public M68kParserDefinition() {
|
||||
}
|
||||
|
||||
public M68kLexerPrefs getLexerPrefs() {
|
||||
return lexerPrefs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Lexer createLexer(Project project) {
|
||||
return new M68kLexer();
|
||||
// TODO take prefs from project somehow
|
||||
return new M68kLexer(lexerPrefs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import com.intellij.openapi.util.NlsContexts.ConfigurableName
|
||||
import de.platon42.intellij.plugins.m68k.M68kIcons.FILE
|
||||
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
|
||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.COMMENT
|
||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.DATA_PREPROCESSOR
|
||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.DATA_WIDTH_BS
|
||||
@ -36,7 +37,7 @@ class M68kColorSettingsPage : ColorSettingsPage {
|
||||
}
|
||||
|
||||
override fun getHighlighter(): SyntaxHighlighter {
|
||||
return M68kSyntaxHighlighter()
|
||||
return M68kSyntaxHighlighter(null)
|
||||
}
|
||||
|
||||
@NonNls
|
||||
@ -85,24 +86,26 @@ hello: dc.b 'Hello World!',10,0
|
||||
|
||||
companion object {
|
||||
private val DESCRIPTORS = arrayOf(
|
||||
AttributesDescriptor("Global labels", GLOBAL_LABEL),
|
||||
AttributesDescriptor("Local labels", LOCAL_LABEL),
|
||||
AttributesDescriptor("Comma (separator)", SEPARATOR),
|
||||
AttributesDescriptor("Symbol definition", SYMBOLDEF),
|
||||
AttributesDescriptor("Symbol reference", SYMBOL),
|
||||
AttributesDescriptor("Assembly mnemonic", MNEMONIC),
|
||||
AttributesDescriptor("Macro invocation", MACRO_CALL),
|
||||
AttributesDescriptor("Byte/short data width", DATA_WIDTH_BS),
|
||||
AttributesDescriptor("Word data width", DATA_WIDTH_W),
|
||||
AttributesDescriptor("Long data width", DATA_WIDTH_L),
|
||||
AttributesDescriptor("Data preprocessor directives", DATA_PREPROCESSOR),
|
||||
AttributesDescriptor("Other preprocessor directives", OTHER_PREPROCESSOR),
|
||||
AttributesDescriptor("Strings", STRING),
|
||||
AttributesDescriptor("Numbers", NUMBER),
|
||||
AttributesDescriptor("Address registers", AREG),
|
||||
AttributesDescriptor("Data registers", DREG),
|
||||
AttributesDescriptor("Special registers", SPECIAL_REG),
|
||||
AttributesDescriptor("Comments", COMMENT),
|
||||
AttributesDescriptor("Bad characters", BAD_CHARACTER))
|
||||
AttributesDescriptor("Global labels", GLOBAL_LABEL),
|
||||
AttributesDescriptor("Local labels", LOCAL_LABEL),
|
||||
AttributesDescriptor("Comma (separator)", SEPARATOR),
|
||||
AttributesDescriptor("Colon", COLON),
|
||||
AttributesDescriptor("Symbol definition", SYMBOLDEF),
|
||||
AttributesDescriptor("Symbol reference", SYMBOL),
|
||||
AttributesDescriptor("Assembly mnemonic", MNEMONIC),
|
||||
AttributesDescriptor("Macro invocation", MACRO_CALL),
|
||||
AttributesDescriptor("Byte/short data width", DATA_WIDTH_BS),
|
||||
AttributesDescriptor("Word data width", DATA_WIDTH_W),
|
||||
AttributesDescriptor("Long data width", DATA_WIDTH_L),
|
||||
AttributesDescriptor("Data preprocessor directives", DATA_PREPROCESSOR),
|
||||
AttributesDescriptor("Other preprocessor directives", OTHER_PREPROCESSOR),
|
||||
AttributesDescriptor("Strings", STRING),
|
||||
AttributesDescriptor("Numbers", NUMBER),
|
||||
AttributesDescriptor("Address registers", AREG),
|
||||
AttributesDescriptor("Data registers", DREG),
|
||||
AttributesDescriptor("Special registers", SPECIAL_REG),
|
||||
AttributesDescriptor("Comments", COMMENT),
|
||||
AttributesDescriptor("Bad characters", BAD_CHARACTER)
|
||||
)
|
||||
}
|
||||
}
|
@ -5,19 +5,27 @@ import com.intellij.openapi.editor.DefaultLanguageHighlighterColors
|
||||
import com.intellij.openapi.editor.HighlighterColors
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.TokenType
|
||||
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
|
||||
|
||||
class M68kSyntaxHighlighter : SyntaxHighlighterBase() {
|
||||
class M68kSyntaxHighlighter(val project: Project?) : SyntaxHighlighterBase() {
|
||||
override fun getHighlightingLexer(): Lexer {
|
||||
return M68kLexer()
|
||||
if (project == null) {
|
||||
return M68kLexer(M68kLexerPrefs()) // Use some defaults
|
||||
} else {
|
||||
// FIXME Where do we get the prefs from?
|
||||
return M68kLexer(M68kLexerPrefs())
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTokenHighlights(tokenType: IElementType): Array<TextAttributesKey> {
|
||||
return when (tokenType) {
|
||||
M68kTypes.SEPARATOR -> arrayOf(SEPARATOR)
|
||||
M68kTypes.COLON -> arrayOf(COLON)
|
||||
M68kTypes.GLOBAL_LABEL_DEF, M68kTypes.GLOBAL_LABEL -> arrayOf(GLOBAL_LABEL)
|
||||
M68kTypes.LOCAL_LABEL_DEF, M68kTypes.LOCAL_LABEL -> arrayOf(LOCAL_LABEL)
|
||||
M68kTypes.SYMBOLDEF -> arrayOf(SYMBOLDEF)
|
||||
@ -44,6 +52,7 @@ class M68kSyntaxHighlighter : SyntaxHighlighterBase() {
|
||||
val GLOBAL_LABEL = TextAttributesKey.createTextAttributesKey("M68K_LOCAL_LABEL", DefaultLanguageHighlighterColors.LOCAL_VARIABLE)
|
||||
val LOCAL_LABEL = TextAttributesKey.createTextAttributesKey("M68K_GLOBAL_LABEL", DefaultLanguageHighlighterColors.GLOBAL_VARIABLE)
|
||||
val SEPARATOR = TextAttributesKey.createTextAttributesKey("M68K_SEPARATOR", DefaultLanguageHighlighterColors.COMMA)
|
||||
val COLON = TextAttributesKey.createTextAttributesKey("M68K_COLON", DefaultLanguageHighlighterColors.DOT)
|
||||
val SYMBOLDEF = TextAttributesKey.createTextAttributesKey("M68K_SYMBOLDEF", DefaultLanguageHighlighterColors.STATIC_FIELD)
|
||||
val SYMBOL = TextAttributesKey.createTextAttributesKey("M68K_SYMBOL", DefaultLanguageHighlighterColors.IDENTIFIER)
|
||||
val MNEMONIC = TextAttributesKey.createTextAttributesKey("M68K_MNEMONIC", DefaultLanguageHighlighterColors.FUNCTION_CALL)
|
||||
|
@ -5,5 +5,5 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
|
||||
class M68kSyntaxHighlighterFactory : SyntaxHighlighterFactory() {
|
||||
override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?) = M68kSyntaxHighlighter()
|
||||
override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?) = M68kSyntaxHighlighter(project)
|
||||
}
|
@ -112,6 +112,9 @@ public class ParsingTestExtension implements ParameterResolver, AfterTestExecuti
|
||||
}
|
||||
|
||||
public interface IParsingTestCase {
|
||||
|
||||
ParserDefinition getParserDefinition();
|
||||
|
||||
void ensureNoErrorElements();
|
||||
|
||||
void doTest(boolean checkResult);
|
||||
@ -129,11 +132,14 @@ public class ParsingTestExtension implements ParameterResolver, AfterTestExecuti
|
||||
|
||||
private static class ParsingTestCaseWrapper extends ParsingTestCase implements IParsingTestCase {
|
||||
private ExtensionContext extensionContext;
|
||||
|
||||
private ParserDefinition parserDefinition;
|
||||
private static ExtensionContext extensionContextHack;
|
||||
|
||||
private ParsingTestCaseWrapper(ExtensionContext extensionContext, String extension, ParserDefinition parserDefinition) {
|
||||
super(passthroughInitHack(extensionContext), extension, parserDefinition);
|
||||
this.extensionContext = extensionContext;
|
||||
this.parserDefinition = parserDefinition;
|
||||
}
|
||||
|
||||
private static String passthroughInitHack(ExtensionContext extensionContext) {
|
||||
@ -159,6 +165,11 @@ public class ParsingTestExtension implements ParameterResolver, AfterTestExecuti
|
||||
super.tearDown(); // Clears fields!
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParserDefinition getParserDefinition() {
|
||||
return parserDefinition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
String testname = extensionContext.getDisplayName().replace(" ", "_");
|
||||
|
@ -47,4 +47,40 @@ internal class CommentsTest : AbstractParsingTest() {
|
||||
internal fun end_of_line_comments(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
testGoodSyntax(testCase, "foo = 1234; hi\n\n\nlabel; foo\n\n\n add.w d0,d0;narf \n\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun comment_after_instruction_with_space_introduces_comment_option(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
|
||||
(testCase.parserDefinition as M68kParserDefinition).lexerPrefs.spaceIntroducesComment = 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
|
||||
testGoodSyntax(testCase, "FOO = 123+23 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
|
||||
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
|
||||
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
|
||||
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
|
||||
testGoodSyntax(testCase, " PUSHM d0, d0 ; hey comment\n")
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
Assembly File: a.asm
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAssignmentImpl(ASSIGNMENT)
|
||||
PsiElement(M68kTokenType.SYMBOLDEF)('FOO')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.OP_ASSIGN)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kBinaryAddExprImpl(BINARY_ADD_EXPR)
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('123')
|
||||
PsiElement(M68kTokenType.OP_PLUS)('+')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('23')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(M68kTokenType.COMMENT)('hey comment')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
@ -0,0 +1,19 @@
|
||||
Assembly File: a.asm
|
||||
PsiWhiteSpace(' ')
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAsmInstructionImpl(ASM_INSTRUCTION)
|
||||
M68kAsmOpImpl(ASM_OP)
|
||||
PsiElement(M68kTokenType.MNEMONIC)('add')
|
||||
M68kOperandSizeImpl(OPERAND_SIZE)
|
||||
PsiElement(M68kTokenType.OPSIZE_W)('.w')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE)
|
||||
M68kDataRegisterImpl(DATA_REGISTER)
|
||||
PsiElement(M68kTokenType.DREG)('d0')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE)
|
||||
M68kDataRegisterImpl(DATA_REGISTER)
|
||||
PsiElement(M68kTokenType.DREG)('d0')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(M68kTokenType.COMMENT)('hey comment')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
@ -0,0 +1,12 @@
|
||||
Assembly File: a.asm
|
||||
PsiWhiteSpace(' ')
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kMacroCallImpl(MACRO_CALL)
|
||||
PsiElement(M68kTokenType.MACRO_INVOKATION)('PUSHM')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.STRINGLIT)('d0')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
PsiElement(M68kTokenType.STRINGLIT)('d0')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(M68kTokenType.COMMENT)('hey comment')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
@ -0,0 +1,18 @@
|
||||
Assembly File: a.asm
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAssignmentImpl(ASSIGNMENT)
|
||||
PsiElement(M68kTokenType.SYMBOLDEF)('FOO')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.OP_ASSIGN)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kBinaryAddExprImpl(BINARY_ADD_EXPR)
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('123')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.OP_PLUS)('+')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('23')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(M68kTokenType.COMMENT)('; hey comment')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
@ -0,0 +1,22 @@
|
||||
Assembly File: a.asm
|
||||
PsiWhiteSpace(' ')
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kAsmInstructionImpl(ASM_INSTRUCTION)
|
||||
M68kAsmOpImpl(ASM_OP)
|
||||
PsiElement(M68kTokenType.MNEMONIC)('add')
|
||||
M68kOperandSizeImpl(OPERAND_SIZE)
|
||||
PsiElement(M68kTokenType.OPSIZE_W)('.w')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kImmediateDataImpl(IMMEDIATE_DATA)
|
||||
PsiElement(M68kTokenType.HASH)('#')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kLiteralExprImpl(LITERAL_EXPR)
|
||||
PsiElement(M68kTokenType.DECIMAL)('234')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE)
|
||||
M68kDataRegisterImpl(DATA_REGISTER)
|
||||
PsiElement(M68kTokenType.DREG)('d0')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(M68kTokenType.COMMENT)('; hey comment')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
@ -0,0 +1,13 @@
|
||||
Assembly File: a.asm
|
||||
PsiWhiteSpace(' ')
|
||||
M68kStatementImpl(STATEMENT)
|
||||
M68kMacroCallImpl(MACRO_CALL)
|
||||
PsiElement(M68kTokenType.MACRO_INVOKATION)('PUSHM')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.STRINGLIT)('d0')
|
||||
PsiElement(M68kTokenType.SEPARATOR)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(M68kTokenType.STRINGLIT)('d0')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(M68kTokenType.COMMENT)('; hey comment')
|
||||
PsiElement(M68kTokenType.EOL)('\n')
|
Loading…
Reference in New Issue
Block a user