From 5041adf635ce4aa8d7111e11c47c3b20152e4543 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 14 Mar 2014 08:04:34 +1100 Subject: Assembler lexer variant As(SCLEX_AS) for Unix assembly code which uses '#' for comments and ';' to separate statements. From nkmathew. --- doc/ScintillaHistory.html | 5 +++++ include/SciLexer.h | 1 + include/Scintilla.iface | 4 +++- lexers/LexAsm.cxx | 13 ++++++++++--- src/Catalogue.cxx | 1 + 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 372cccfa8..9ec40881f 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -443,6 +443,7 @@ Robert Gieseke Mike M + nkmathew

@@ -473,6 +474,10 @@ DirectWrite on Windows.

  • + Additional assembler lexer variant As(SCLEX_AS) for Unix assembly code which uses '#' for comments and + ';' to separate statements. +
  • +
  • Fix crashes and other bugs in Fortran folder by removing folding of do-label constructs.
  • diff --git a/include/SciLexer.h b/include/SciLexer.h index 1101bf226..cb4079b8c 100644 --- a/include/SciLexer.h +++ b/include/SciLexer.h @@ -125,6 +125,7 @@ #define SCLEX_KVIRC 110 #define SCLEX_RUST 111 #define SCLEX_DMAP 112 +#define SCLEX_AS 113 #define SCLEX_AUTOMATIC 1000 #define SCE_P_DEFAULT 0 #define SCE_P_COMMENTLINE 1 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 8eac156fb..7040b63a9 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2658,6 +2658,7 @@ val SCLEX_STTXT=109 val SCLEX_KVIRC=110 val SCLEX_RUST=111 val SCLEX_DMAP=112 +val SCLEX_AS=113 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a # value assigned in sequence from SCLEX_AUTOMATIC+1. @@ -3247,8 +3248,9 @@ val SCE_SCRIPTOL_IDENTIFIER=12 val SCE_SCRIPTOL_TRIPLE=13 val SCE_SCRIPTOL_CLASSNAME=14 val SCE_SCRIPTOL_PREPROCESSOR=15 -# Lexical states for SCLEX_ASM +# Lexical states for SCLEX_ASM, SCLEX_AS lex Asm=SCLEX_ASM SCE_ASM_ +lex As=SCLEX_AS SCE_ASM_ val SCE_ASM_DEFAULT=0 val SCE_ASM_COMMENT=1 val SCE_ASM_NUMBER=2 diff --git a/lexers/LexAsm.cxx b/lexers/LexAsm.cxx index b327ce5f2..37a4efe35 100644 --- a/lexers/LexAsm.cxx +++ b/lexers/LexAsm.cxx @@ -150,8 +150,10 @@ class LexerAsm : public ILexer { WordList directives4foldend; OptionsAsm options; OptionSetAsm osAsm; + int commentChar; public: - LexerAsm() { + LexerAsm(int commentChar_) { + commentChar = commentChar_; } virtual ~LexerAsm() { } @@ -183,7 +185,11 @@ public: } static ILexer *LexerFactoryAsm() { - return new LexerAsm(); + return new LexerAsm(';'); + } + + static ILexer *LexerFactoryAs() { + return new LexerAsm('#'); } }; @@ -342,7 +348,7 @@ void SCI_METHOD LexerAsm::Lex(unsigned int startPos, int length, int initStyle, // Determine if a new state should be entered. if (sc.state == SCE_ASM_DEFAULT) { - if (sc.ch == ';'){ + if (sc.ch == commentChar){ 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); @@ -457,4 +463,5 @@ void SCI_METHOD LexerAsm::Fold(unsigned int startPos, int length, int initStyle, } LexerModule lmAsm(SCLEX_ASM, LexerAsm::LexerFactoryAsm, "asm", asmWordListDesc); +LexerModule lmAs(SCLEX_AS, LexerAsm::LexerFactoryAs, "as", asmWordListDesc); diff --git a/src/Catalogue.cxx b/src/Catalogue.cxx index b7f816d76..41d5d5489 100644 --- a/src/Catalogue.cxx +++ b/src/Catalogue.cxx @@ -80,6 +80,7 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmAbaqus); LINK_LEXER(lmAda); LINK_LEXER(lmAPDL); + LINK_LEXER(lmAs); LINK_LEXER(lmAsm); LINK_LEXER(lmAsn1); LINK_LEXER(lmASY); -- cgit v1.2.3