From 7ba1c94e850603d2a70f1a52e737cc8f83cffbee Mon Sep 17 00:00:00 2001 From: Dejan Budimir Date: Tue, 21 Apr 2020 22:11:01 +1000 Subject: Backport: Feature [feature-requests:1346]. Add lexer.as.comment.character property to change comment character. Backport of changeset 8155:b89853508137. --- lexers/LexAsm.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lexers') diff --git a/lexers/LexAsm.cxx b/lexers/LexAsm.cxx index 9bc775ceb..7f9c7d50b 100644 --- a/lexers/LexAsm.cxx +++ b/lexers/LexAsm.cxx @@ -80,6 +80,7 @@ struct OptionsAsm { std::string foldExplicitEnd; bool foldExplicitAnywhere; bool foldCompact; + std::string commentChar; OptionsAsm() { delimiter = ""; fold = false; @@ -90,6 +91,7 @@ struct OptionsAsm { foldExplicitEnd = ""; foldExplicitAnywhere = false; foldCompact = true; + commentChar = ""; } }; @@ -134,6 +136,9 @@ struct OptionSetAsm : public OptionSet { DefineProperty("fold.compact", &OptionsAsm::foldCompact); + DefineProperty("lexer.as.comment.character", &OptionsAsm::commentChar, + "Overrides the default comment character (which is ';' for asm and '#' for as)."); + DefineWordListSets(asmWordListDesc); } }; @@ -245,6 +250,9 @@ Sci_Position SCI_METHOD LexerAsm::WordListSet(int n, const char *wl) { void SCI_METHOD LexerAsm::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { LexAccessor styler(pAccess); + const char commentCharacter = options.commentChar.empty() ? + commentChar : options.commentChar.front(); + // Do not leak onto next line if (initStyle == SCE_ASM_STRINGEOL) initStyle = SCE_ASM_DEFAULT; @@ -350,7 +358,7 @@ void SCI_METHOD LexerAsm::Lex(Sci_PositionU startPos, Sci_Position length, int i // Determine if a new state should be entered. if (sc.state == SCE_ASM_DEFAULT) { - if (sc.ch == commentChar){ + if (sc.ch == commentCharacter) { sc.SetState(SCE_ASM_COMMENT); } else if (IsASCII(sc.ch) && (isdigit(sc.ch) || (sc.ch == '.' && IsASCII(sc.chNext) && isdigit(sc.chNext)))) { sc.SetState(SCE_ASM_NUMBER); -- cgit v1.2.3