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 <neilh@scintilla.org> |
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 | module(module_) { |
31 | for (int wl = 0; wl < module->GetNumWordLists(); wl++) { |
32 | if (!wordLists.empty()) |
33 | wordLists += "\n" ; |
34 | wordLists += module->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 | module->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 | module->Fold(startPos, lengthDoc, initStyle, keyWordLists, astyler); |
52 | astyler.Flush(); |
53 | } |
54 | } |
55 | |
56 | const char * SCI_METHOD LexerSimple::GetName() { |
57 | return module->languageName; |
58 | } |
59 | |
60 | int SCI_METHOD LexerSimple::GetIdentifier() { |
61 | return module->GetLanguage(); |
62 | } |
63 | |