| 1 |
// Scintilla source code edit control |
| 2 |
/** @file LexerSimple.cxx |
| 3 |
** A simple lexer with no state. |
| 4 |
**/ |
| 5 |
// Copyright 1998-2010 by Neil Hodgson <[email protected]> |
| 6 |
// The License.txt file describes the conditions under which this software may be distributed. |
| 7 |
|
| 8 |
#include <cstdlib> |
| 9 |
#include <cassert> |
| 10 |
|
| 11 |
#include <string> |
| 12 |
#include <string_view> |
| 13 |
|
| 14 |
#include "ILexer.h" |
| 15 |
#include "Scintilla.h" |
| 16 |
#include "SciLexer.h" |
| 17 |
|
| 18 |
#include "PropSetSimple.h" |
| 19 |
#include "WordList.h" |
| 20 |
#include "LexAccessor.h" |
| 21 |
#include "Accessor.h" |
| 22 |
#include "LexerModule.h" |
| 23 |
#include "LexerBase.h" |
| 24 |
#include "LexerSimple.h" |
| 25 |
|
| 26 |
using namespace Lexilla; |
| 27 |
|
| 28 |
LexerSimple::LexerSimple(const LexerModule *module_) : |
| 29 |
LexerBase(module_->LexClasses(), module_->NamedStyles()), |
| 30 |
lexerModule(module_) { |
| 31 |
for (int wl = 0; wl < lexerModule->GetNumWordLists(); wl++) { |
| 32 |
if (!wordLists.empty()) |
| 33 |
wordLists += "\n"; |
| 34 |
wordLists += lexerModule->GetWordListDescription(wl); |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
const char * SCI_METHOD LexerSimple::DescribeWordListSets() { |
| 39 |
return wordLists.c_str(); |
| 40 |
} |
| 41 |
|
| 42 |
void SCI_METHOD LexerSimple::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Scintilla::IDocument *pAccess) { |
| 43 |
Accessor astyler(pAccess, &props); |
| 44 |
lexerModule->Lex(startPos, lengthDoc, initStyle, keyWordLists, astyler); |
| 45 |
astyler.Flush(); |
| 46 |
} |
| 47 |
|
| 48 |
void SCI_METHOD LexerSimple::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Scintilla::IDocument *pAccess) { |
| 49 |
if (props.GetInt("fold")) { |
| 50 |
Accessor astyler(pAccess, &props); |
| 51 |
lexerModule->Fold(startPos, lengthDoc, initStyle, keyWordLists, astyler); |
| 52 |
astyler.Flush(); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
const char * SCI_METHOD LexerSimple::GetName() { |
| 57 |
return lexerModule->languageName; |
| 58 |
} |
| 59 |
|
| 60 |
int SCI_METHOD LexerSimple::GetIdentifier() { |
| 61 |
return lexerModule->GetLanguage(); |
| 62 |
} |