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