aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexlib
diff options
context:
space:
mode:
Diffstat (limited to 'lexlib')
-rw-r--r--lexlib/Accessor.cxx73
-rw-r--r--lexlib/Accessor.h31
-rw-r--r--lexlib/CatalogueModules.h70
-rw-r--r--lexlib/DefaultLexer.cxx139
-rw-r--r--lexlib/DefaultLexer.h57
-rw-r--r--lexlib/LexAccessor.h195
-rw-r--r--lexlib/LexerBase.cxx155
-rw-r--r--lexlib/LexerBase.h57
-rw-r--r--lexlib/LexerModule.cxx123
-rw-r--r--lexlib/LexerModule.h92
-rw-r--r--lexlib/LexerNoExceptions.cxx62
-rw-r--r--lexlib/LexerNoExceptions.h28
-rw-r--r--lexlib/LexerSimple.cxx61
-rw-r--r--lexlib/LexerSimple.h29
-rw-r--r--lexlib/OptionSet.h149
-rw-r--r--lexlib/PropSetSimple.cxx157
-rw-r--r--lexlib/PropSetSimple.h28
-rw-r--r--lexlib/SparseState.h106
-rw-r--r--lexlib/StringCopy.h32
-rw-r--r--lexlib/StyleContext.cxx68
-rw-r--r--lexlib/StyleContext.h212
-rw-r--r--lexlib/SubStyles.h208
-rw-r--r--lexlib/WordList.cxx315
-rw-r--r--lexlib/WordList.h38
24 files changed, 0 insertions, 2485 deletions
diff --git a/lexlib/Accessor.cxx b/lexlib/Accessor.cxx
deleted file mode 100644
index 7cce9a554..000000000
--- a/lexlib/Accessor.cxx
+++ /dev/null
@@ -1,73 +0,0 @@
-// Scintilla source code edit control
-/** @file Accessor.cxx
- ** Interfaces between Scintilla and lexers.
- **/
-// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#include <cstdlib>
-#include <cassert>
-
-#include "ILexer.h"
-#include "Scintilla.h"
-#include "SciLexer.h"
-
-#include "PropSetSimple.h"
-#include "WordList.h"
-#include "LexAccessor.h"
-#include "Accessor.h"
-
-using namespace Scintilla;
-
-Accessor::Accessor(IDocument *pAccess_, PropSetSimple *pprops_) : LexAccessor(pAccess_), pprops(pprops_) {
-}
-
-int Accessor::GetPropertyInt(const char *key, int defaultValue) const {
- return pprops->GetInt(key, defaultValue);
-}
-
-int Accessor::IndentAmount(Sci_Position line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
- const Sci_Position end = Length();
- int spaceFlags = 0;
-
- // Determines the indentation level of the current line and also checks for consistent
- // indentation compared to the previous line.
- // Indentation is judged consistent when the indentation whitespace of each line lines
- // the same or the indentation of one line is a prefix of the other.
-
- Sci_Position pos = LineStart(line);
- char ch = (*this)[pos];
- int indent = 0;
- bool inPrevPrefix = line > 0;
- Sci_Position posPrev = inPrevPrefix ? LineStart(line-1) : 0;
- while ((ch == ' ' || ch == '\t') && (pos < end)) {
- if (inPrevPrefix) {
- const char chPrev = (*this)[posPrev++];
- if (chPrev == ' ' || chPrev == '\t') {
- if (chPrev != ch)
- spaceFlags |= wsInconsistent;
- } else {
- inPrevPrefix = false;
- }
- }
- if (ch == ' ') {
- spaceFlags |= wsSpace;
- indent++;
- } else { // Tab
- spaceFlags |= wsTab;
- if (spaceFlags & wsSpace)
- spaceFlags |= wsSpaceTab;
- indent = (indent / 8 + 1) * 8;
- }
- ch = (*this)[++pos];
- }
-
- *flags = spaceFlags;
- indent += SC_FOLDLEVELBASE;
- // if completely empty line or the start of a comment...
- if ((LineStart(line) == Length()) || (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') ||
- (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)))
- return indent | SC_FOLDLEVELWHITEFLAG;
- else
- return indent;
-}
diff --git a/lexlib/Accessor.h b/lexlib/Accessor.h
deleted file mode 100644
index 8fc3f641a..000000000
--- a/lexlib/Accessor.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Scintilla source code edit control
-/** @file Accessor.h
- ** Interfaces between Scintilla and lexers.
- **/
-// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef ACCESSOR_H
-#define ACCESSOR_H
-
-namespace Scintilla {
-
-enum { wsSpace=1, wsTab=2, wsSpaceTab=4, wsInconsistent=8 };
-
-class Accessor;
-class WordList;
-class PropSetSimple;
-
-typedef bool (*PFNIsCommentLeader)(Accessor &styler, Sci_Position pos, Sci_Position len);
-
-class Accessor : public LexAccessor {
-public:
- PropSetSimple *pprops;
- Accessor(IDocument *pAccess_, PropSetSimple *pprops_);
- int GetPropertyInt(const char *, int defaultValue=0) const;
- int IndentAmount(Sci_Position line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
-};
-
-}
-
-#endif
diff --git a/lexlib/CatalogueModules.h b/lexlib/CatalogueModules.h
deleted file mode 100644
index 267a7b82b..000000000
--- a/lexlib/CatalogueModules.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// Scintilla source code edit control
-/** @file CatalogueModules.h
- ** Lexer infrastructure.
- ** Contains a list of LexerModules which can be searched to find a module appropriate for a
- ** particular language.
- **/
-// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef CATALOGUEMODULES_H
-#define CATALOGUEMODULES_H
-
-namespace Scintilla {
-
-class CatalogueModules {
- std::vector<LexerModule *> lexerCatalogue;
-public:
- const LexerModule *Find(int language) const {
- for (const LexerModule *lm : lexerCatalogue) {
- if (lm->GetLanguage() == language) {
- return lm;
- }
- }
- return nullptr;
- }
-
- const LexerModule *Find(const char *languageName) const noexcept {
- if (languageName) {
- for (const LexerModule *lm : lexerCatalogue) {
- if (lm->languageName && (0 == strcmp(lm->languageName, languageName))) {
- return lm;
- }
- }
- }
- return nullptr;
- }
-
- void AddLexerModule(LexerModule *plm) {
- lexerCatalogue.push_back(plm);
- }
-
- unsigned int Count() const noexcept {
- return static_cast<unsigned int>(lexerCatalogue.size());
- }
-
- const char *Name(unsigned int index) const noexcept {
- if (index < static_cast<unsigned int>(lexerCatalogue.size())) {
- return lexerCatalogue[index]->languageName;
- } else {
- return "";
- }
- }
-
- LexerFactoryFunction Factory(unsigned int index) const noexcept {
- // Works for object lexers but not for function lexers
- return lexerCatalogue[index]->fnFactory;
- }
-
- ILexer5 *Create(unsigned int index) const {
- const LexerModule *plm = lexerCatalogue[index];
- if (!plm) {
- return nullptr;
- }
- return plm->Create();
- }
-};
-
-}
-
-#endif
diff --git a/lexlib/DefaultLexer.cxx b/lexlib/DefaultLexer.cxx
deleted file mode 100644
index 89671aa30..000000000
--- a/lexlib/DefaultLexer.cxx
+++ /dev/null
@@ -1,139 +0,0 @@
-// Scintilla source code edit control
-/** @file DefaultLexer.cxx
- ** A lexer base class that provides reasonable default behaviour.
- **/
-// Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#include <cstdlib>
-#include <cassert>
-#include <cstring>
-
-#include "ILexer.h"
-#include "Scintilla.h"
-#include "SciLexer.h"
-
-#include "PropSetSimple.h"
-#include "WordList.h"
-#include "LexAccessor.h"
-#include "Accessor.h"
-#include "LexerModule.h"
-#include "DefaultLexer.h"
-
-using namespace Scintilla;
-
-static const char styleSubable[] = { 0 };
-
-DefaultLexer::DefaultLexer(const char *languageName_, int language_,
- const LexicalClass *lexClasses_, size_t nClasses_) :
- languageName(languageName_),
- language(language_),
- lexClasses(lexClasses_),
- nClasses(nClasses_) {
-}
-
-DefaultLexer::~DefaultLexer() {
-}
-
-void SCI_METHOD DefaultLexer::Release() {
- delete this;
-}
-
-int SCI_METHOD DefaultLexer::Version() const {
- return lvRelease5;
-}
-
-const char * SCI_METHOD DefaultLexer::PropertyNames() {
- return "";
-}
-
-int SCI_METHOD DefaultLexer::PropertyType(const char *) {
- return SC_TYPE_BOOLEAN;
-}
-
-const char * SCI_METHOD DefaultLexer::DescribeProperty(const char *) {
- return "";
-}
-
-Sci_Position SCI_METHOD DefaultLexer::PropertySet(const char *, const char *) {
- return -1;
-}
-
-const char * SCI_METHOD DefaultLexer::DescribeWordListSets() {
- return "";
-}
-
-Sci_Position SCI_METHOD DefaultLexer::WordListSet(int, const char *) {
- return -1;
-}
-
-void SCI_METHOD DefaultLexer::Fold(Sci_PositionU, Sci_Position, int, IDocument *) {
-}
-
-void * SCI_METHOD DefaultLexer::PrivateCall(int, void *) {
- return nullptr;
-}
-
-int SCI_METHOD DefaultLexer::LineEndTypesSupported() {
- return SC_LINE_END_TYPE_DEFAULT;
-}
-
-int SCI_METHOD DefaultLexer::AllocateSubStyles(int, int) {
- return -1;
-}
-
-int SCI_METHOD DefaultLexer::SubStylesStart(int) {
- return -1;
-}
-
-int SCI_METHOD DefaultLexer::SubStylesLength(int) {
- return 0;
-}
-
-int SCI_METHOD DefaultLexer::StyleFromSubStyle(int subStyle) {
- return subStyle;
-}
-
-int SCI_METHOD DefaultLexer::PrimaryStyleFromStyle(int style) {
- return style;
-}
-
-void SCI_METHOD DefaultLexer::FreeSubStyles() {
-}
-
-void SCI_METHOD DefaultLexer::SetIdentifiers(int, const char *) {
-}
-
-int SCI_METHOD DefaultLexer::DistanceToSecondaryStyles() {
- return 0;
-}
-
-const char * SCI_METHOD DefaultLexer::GetSubStyleBases() {
- return styleSubable;
-}
-
-int SCI_METHOD DefaultLexer::NamedStyles() {
- return static_cast<int>(nClasses);
-}
-
-const char * SCI_METHOD DefaultLexer::NameOfStyle(int style) {
- return (style < NamedStyles()) ? lexClasses[style].name : "";
-}
-
-const char * SCI_METHOD DefaultLexer::TagsOfStyle(int style) {
- return (style < NamedStyles()) ? lexClasses[style].tags : "";
-}
-
-const char * SCI_METHOD DefaultLexer::DescriptionOfStyle(int style) {
- return (style < NamedStyles()) ? lexClasses[style].description : "";
-}
-
-// ILexer5 methods
-const char * SCI_METHOD DefaultLexer::GetName() {
- return languageName;
-}
-
-int SCI_METHOD DefaultLexer::GetIdentifier() {
- return language;
-}
-
diff --git a/lexlib/DefaultLexer.h b/lexlib/DefaultLexer.h
deleted file mode 100644
index 9139c4595..000000000
--- a/lexlib/DefaultLexer.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// Scintilla source code edit control
-/** @file DefaultLexer.h
- ** A lexer base class with default empty implementations of methods.
- ** For lexers that do not support all features so do not need real implementations.
- ** Does have real implementation for style metadata.
- **/
-// Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef DEFAULTLEXER_H
-#define DEFAULTLEXER_H
-
-namespace Scintilla {
-
-// A simple lexer with no state
-class DefaultLexer : public ILexer5 {
- const char *languageName;
- int language;
- const LexicalClass *lexClasses;
- size_t nClasses;
-public:
- DefaultLexer(const char *languageName_, int language_,
- const LexicalClass *lexClasses_ = nullptr, size_t nClasses_ = 0);
- virtual ~DefaultLexer();
- void SCI_METHOD Release() override;
- int SCI_METHOD Version() const override;
- const char * SCI_METHOD PropertyNames() override;
- int SCI_METHOD PropertyType(const char *name) override;
- const char * SCI_METHOD DescribeProperty(const char *name) override;
- Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
- const char * SCI_METHOD DescribeWordListSets() override;
- Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
- void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override = 0;
- void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override;
- void * SCI_METHOD PrivateCall(int operation, void *pointer) override;
- int SCI_METHOD LineEndTypesSupported() override;
- int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) override;
- int SCI_METHOD SubStylesStart(int styleBase) override;
- int SCI_METHOD SubStylesLength(int styleBase) override;
- int SCI_METHOD StyleFromSubStyle(int subStyle) override;
- int SCI_METHOD PrimaryStyleFromStyle(int style) override;
- void SCI_METHOD FreeSubStyles() override;
- void SCI_METHOD SetIdentifiers(int style, const char *identifiers) override;
- int SCI_METHOD DistanceToSecondaryStyles() override;
- const char * SCI_METHOD GetSubStyleBases() override;
- int SCI_METHOD NamedStyles() override;
- const char * SCI_METHOD NameOfStyle(int style) override;
- const char * SCI_METHOD TagsOfStyle(int style) override;
- const char * SCI_METHOD DescriptionOfStyle(int style) override;
- // ILexer5 methods
- const char * SCI_METHOD GetName() override;
- int SCI_METHOD GetIdentifier() override;
-};
-
-}
-
-#endif
diff --git a/lexlib/LexAccessor.h b/lexlib/LexAccessor.h
deleted file mode 100644
index 658eb6e6d..000000000
--- a/lexlib/LexAccessor.h
+++ /dev/null
@@ -1,195 +0,0 @@
-// Scintilla source code edit control
-/** @file LexAccessor.h
- ** Interfaces between Scintilla and lexers.
- **/
-// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef LEXACCESSOR_H
-#define LEXACCESSOR_H
-
-namespace Scintilla {
-
-enum class EncodingType { eightBit, unicode, dbcs };
-
-class LexAccessor {
-private:
- IDocument *pAccess;
- enum {extremePosition=0x7FFFFFFF};
- /** @a bufferSize is a trade off between time taken to copy the characters
- * and retrieval overhead.
- * @a slopSize positions the buffer before the desired position
- * in case there is some backtracking. */
- enum {bufferSize=4000, slopSize=bufferSize/8};
- char buf[bufferSize+1];
- Sci_Position startPos;
- Sci_Position endPos;
- int codePage;
- enum EncodingType encodingType;
- Sci_Position lenDoc;
- char styleBuf[bufferSize];
- Sci_Position validLen;
- Sci_PositionU startSeg;
- Sci_Position startPosStyling;
- int documentVersion;
-
- void Fill(Sci_Position position) {
- startPos = position - slopSize;
- if (startPos + bufferSize > lenDoc)
- startPos = lenDoc - bufferSize;
- if (startPos < 0)
- startPos = 0;
- endPos = startPos + bufferSize;
- if (endPos > lenDoc)
- endPos = lenDoc;
-
- pAccess->GetCharRange(buf, startPos, endPos-startPos);
- buf[endPos-startPos] = '\0';
- }
-
-public:
- explicit LexAccessor(IDocument *pAccess_) :
- pAccess(pAccess_), startPos(extremePosition), endPos(0),
- codePage(pAccess->CodePage()),
- encodingType(EncodingType::eightBit),
- lenDoc(pAccess->Length()),
- validLen(0),
- startSeg(0), startPosStyling(0),
- documentVersion(pAccess->Version()) {
- // Prevent warnings by static analyzers about uninitialized buf and styleBuf.
- buf[0] = 0;
- styleBuf[0] = 0;
- switch (codePage) {
- case 65001:
- encodingType = EncodingType::unicode;
- break;
- case 932:
- case 936:
- case 949:
- case 950:
- case 1361:
- encodingType = EncodingType::dbcs;
- }
- }
- char operator[](Sci_Position position) {
- if (position < startPos || position >= endPos) {
- Fill(position);
- }
- return buf[position - startPos];
- }
- IDocument *MultiByteAccess() const noexcept {
- return pAccess;
- }
- /** Safe version of operator[], returning a defined value for invalid position. */
- char SafeGetCharAt(Sci_Position position, char chDefault=' ') {
- if (position < startPos || position >= endPos) {
- Fill(position);
- if (position < startPos || position >= endPos) {
- // Position is outside range of document
- return chDefault;
- }
- }
- return buf[position - startPos];
- }
- bool IsLeadByte(char ch) const {
- return pAccess->IsDBCSLeadByte(ch);
- }
- EncodingType Encoding() const noexcept {
- return encodingType;
- }
- bool Match(Sci_Position pos, const char *s) {
- for (int i=0; *s; i++) {
- if (*s != SafeGetCharAt(pos+i))
- return false;
- s++;
- }
- return true;
- }
- char StyleAt(Sci_Position position) const {
- return pAccess->StyleAt(position);
- }
- Sci_Position GetLine(Sci_Position position) const {
- return pAccess->LineFromPosition(position);
- }
- Sci_Position LineStart(Sci_Position line) const {
- return pAccess->LineStart(line);
- }
- Sci_Position LineEnd(Sci_Position line) const {
- return pAccess->LineEnd(line);
- }
- int LevelAt(Sci_Position line) const {
- return pAccess->GetLevel(line);
- }
- Sci_Position Length() const {
- return lenDoc;
- }
- void Flush() {
- if (validLen > 0) {
- pAccess->SetStyles(validLen, styleBuf);
- startPosStyling += validLen;
- validLen = 0;
- }
- }
- int GetLineState(Sci_Position line) const {
- return pAccess->GetLineState(line);
- }
- int SetLineState(Sci_Position line, int state) {
- return pAccess->SetLineState(line, state);
- }
- // Style setting
- void StartAt(Sci_PositionU start) {
- pAccess->StartStyling(start);
- startPosStyling = start;
- }
- Sci_PositionU GetStartSegment() const {
- return startSeg;
- }
- void StartSegment(Sci_PositionU pos) {
- startSeg = pos;
- }
- void ColourTo(Sci_PositionU pos, int chAttr) {
- // Only perform styling if non empty range
- if (pos != startSeg - 1) {
- assert(pos >= startSeg);
- if (pos < startSeg) {
- return;
- }
-
- if (validLen + (pos - startSeg + 1) >= bufferSize)
- Flush();
- const char attr = static_cast<char>(chAttr);
- if (validLen + (pos - startSeg + 1) >= bufferSize) {
- // Too big for buffer so send directly
- pAccess->SetStyleFor(pos - startSeg + 1, attr);
- } else {
- for (Sci_PositionU i = startSeg; i <= pos; i++) {
- assert((startPosStyling + validLen) < Length());
- styleBuf[validLen++] = attr;
- }
- }
- }
- startSeg = pos+1;
- }
- void SetLevel(Sci_Position line, int level) {
- pAccess->SetLevel(line, level);
- }
- void IndicatorFill(Sci_Position start, Sci_Position end, int indicator, int value) {
- pAccess->DecorationSetCurrentIndicator(indicator);
- pAccess->DecorationFillRange(start, value, end - start);
- }
-
- void ChangeLexerState(Sci_Position start, Sci_Position end) {
- pAccess->ChangeLexerState(start, end);
- }
-};
-
-struct LexicalClass {
- int value;
- const char *name;
- const char *tags;
- const char *description;
-};
-
-}
-
-#endif
diff --git a/lexlib/LexerBase.cxx b/lexlib/LexerBase.cxx
deleted file mode 100644
index bf195d824..000000000
--- a/lexlib/LexerBase.cxx
+++ /dev/null
@@ -1,155 +0,0 @@
-// Scintilla source code edit control
-/** @file LexerBase.cxx
- ** A simple lexer with no state.
- **/
-// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#include <cstdlib>
-#include <cassert>
-#include <cstring>
-
-#include "ILexer.h"
-#include "Scintilla.h"
-#include "SciLexer.h"
-
-#include "PropSetSimple.h"
-#include "WordList.h"
-#include "LexAccessor.h"
-#include "Accessor.h"
-#include "LexerModule.h"
-#include "LexerBase.h"
-
-using namespace Scintilla;
-
-static const char styleSubable[] = { 0 };
-
-LexerBase::LexerBase(const LexicalClass *lexClasses_, size_t nClasses_) :
- lexClasses(lexClasses_), nClasses(nClasses_) {
- for (int wl = 0; wl < numWordLists; wl++)
- keyWordLists[wl] = new WordList;
- keyWordLists[numWordLists] = 0;
-}
-
-LexerBase::~LexerBase() {
- for (int wl = 0; wl < numWordLists; wl++) {
- delete keyWordLists[wl];
- keyWordLists[wl] = 0;
- }
- keyWordLists[numWordLists] = 0;
-}
-
-void SCI_METHOD LexerBase::Release() {
- delete this;
-}
-
-int SCI_METHOD LexerBase::Version() const {
- return lvRelease5;
-}
-
-const char * SCI_METHOD LexerBase::PropertyNames() {
- return "";
-}
-
-int SCI_METHOD LexerBase::PropertyType(const char *) {
- return SC_TYPE_BOOLEAN;
-}
-
-const char * SCI_METHOD LexerBase::DescribeProperty(const char *) {
- return "";
-}
-
-Sci_Position SCI_METHOD LexerBase::PropertySet(const char *key, const char *val) {
- const char *valOld = props.Get(key);
- if (strcmp(val, valOld) != 0) {
- props.Set(key, val, strlen(key), strlen(val));
- return 0;
- } else {
- return -1;
- }
-}
-
-const char *SCI_METHOD LexerBase::PropertyGet(const char *key) {
- return props.Get(key);
-}
-
-const char * SCI_METHOD LexerBase::DescribeWordListSets() {
- return "";
-}
-
-Sci_Position SCI_METHOD LexerBase::WordListSet(int n, const char *wl) {
- if (n < numWordLists) {
- if (keyWordLists[n]->Set(wl)) {
- return 0;
- }
- }
- return -1;
-}
-
-void * SCI_METHOD LexerBase::PrivateCall(int, void *) {
- return nullptr;
-}
-
-int SCI_METHOD LexerBase::LineEndTypesSupported() {
- return SC_LINE_END_TYPE_DEFAULT;
-}
-
-int SCI_METHOD LexerBase::AllocateSubStyles(int, int) {
- return -1;
-}
-
-int SCI_METHOD LexerBase::SubStylesStart(int) {
- return -1;
-}
-
-int SCI_METHOD LexerBase::SubStylesLength(int) {
- return 0;
-}
-
-int SCI_METHOD LexerBase::StyleFromSubStyle(int subStyle) {
- return subStyle;
-}
-
-int SCI_METHOD LexerBase::PrimaryStyleFromStyle(int style) {
- return style;
-}
-
-void SCI_METHOD LexerBase::FreeSubStyles() {
-}
-
-void SCI_METHOD LexerBase::SetIdentifiers(int, const char *) {
-}
-
-int SCI_METHOD LexerBase::DistanceToSecondaryStyles() {
- return 0;
-}
-
-const char * SCI_METHOD LexerBase::GetSubStyleBases() {
- return styleSubable;
-}
-
-int SCI_METHOD LexerBase::NamedStyles() {
- return static_cast<int>(nClasses);
-}
-
-const char * SCI_METHOD LexerBase::NameOfStyle(int style) {
- return (style < NamedStyles()) ? lexClasses[style].name : "";
-}
-
-const char * SCI_METHOD LexerBase::TagsOfStyle(int style) {
- return (style < NamedStyles()) ? lexClasses[style].tags : "";
-}
-
-const char * SCI_METHOD LexerBase::DescriptionOfStyle(int style) {
- return (style < NamedStyles()) ? lexClasses[style].description : "";
-}
-
-// ILexer5 methods
-
-const char *SCI_METHOD LexerBase::GetName() {
- return "";
-}
-
-int SCI_METHOD LexerBase::GetIdentifier() {
- return SCLEX_AUTOMATIC;
-}
diff --git a/lexlib/LexerBase.h b/lexlib/LexerBase.h
deleted file mode 100644
index 22d17fea1..000000000
--- a/lexlib/LexerBase.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// Scintilla source code edit control
-/** @file LexerBase.h
- ** A simple lexer with no state.
- **/
-// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef LEXERBASE_H
-#define LEXERBASE_H
-
-namespace Scintilla {
-
-// A simple lexer with no state
-class LexerBase : public ILexer5 {
-protected:
- const LexicalClass *lexClasses;
- size_t nClasses;
- PropSetSimple props;
- enum {numWordLists=KEYWORDSET_MAX+1};
- WordList *keyWordLists[numWordLists+1];
-public:
- LexerBase(const LexicalClass *lexClasses_=nullptr, size_t nClasses_=0);
- virtual ~LexerBase();
- void SCI_METHOD Release() override;
- int SCI_METHOD Version() const override;
- const char * SCI_METHOD PropertyNames() override;
- int SCI_METHOD PropertyType(const char *name) override;
- const char * SCI_METHOD DescribeProperty(const char *name) override;
- Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
- const char * SCI_METHOD DescribeWordListSets() override;
- Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
- void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override = 0;
- void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override = 0;
- void * SCI_METHOD PrivateCall(int operation, void *pointer) override;
- int SCI_METHOD LineEndTypesSupported() override;
- int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) override;
- int SCI_METHOD SubStylesStart(int styleBase) override;
- int SCI_METHOD SubStylesLength(int styleBase) override;
- int SCI_METHOD StyleFromSubStyle(int subStyle) override;
- int SCI_METHOD PrimaryStyleFromStyle(int style) override;
- void SCI_METHOD FreeSubStyles() override;
- void SCI_METHOD SetIdentifiers(int style, const char *identifiers) override;
- int SCI_METHOD DistanceToSecondaryStyles() override;
- const char * SCI_METHOD GetSubStyleBases() override;
- int SCI_METHOD NamedStyles() override;
- const char * SCI_METHOD NameOfStyle(int style) override;
- const char * SCI_METHOD TagsOfStyle(int style) override;
- const char * SCI_METHOD DescriptionOfStyle(int style) override;
- // ILexer5 methods
- const char * SCI_METHOD GetName() override;
- int SCI_METHOD GetIdentifier() override;
- const char *SCI_METHOD PropertyGet(const char *key) override;
-};
-
-}
-
-#endif
diff --git a/lexlib/LexerModule.cxx b/lexlib/LexerModule.cxx
deleted file mode 100644
index 0f1498bf2..000000000
--- a/lexlib/LexerModule.cxx
+++ /dev/null
@@ -1,123 +0,0 @@
-// Scintilla source code edit control
-/** @file LexerModule.cxx
- ** Colourise for particular languages.
- **/
-// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#include <cstdlib>
-#include <cassert>
-
-#include <string>
-
-#include "ILexer.h"
-#include "Scintilla.h"
-#include "SciLexer.h"
-
-#include "PropSetSimple.h"
-#include "WordList.h"
-#include "LexAccessor.h"
-#include "Accessor.h"
-#include "LexerModule.h"
-#include "LexerBase.h"
-#include "LexerSimple.h"
-
-using namespace Scintilla;
-
-LexerModule::LexerModule(int language_,
- LexerFunction fnLexer_,
- const char *languageName_,
- LexerFunction fnFolder_,
- const char *const wordListDescriptions_[],
- const LexicalClass *lexClasses_,
- size_t nClasses_) noexcept :
- language(language_),
- fnLexer(fnLexer_),
- fnFolder(fnFolder_),
- fnFactory(nullptr),
- wordListDescriptions(wordListDescriptions_),
- lexClasses(lexClasses_),
- nClasses(nClasses_),
- languageName(languageName_) {
-}
-
-LexerModule::LexerModule(int language_,
- LexerFactoryFunction fnFactory_,
- const char *languageName_,
- const char * const wordListDescriptions_[]) noexcept :
- language(language_),
- fnLexer(nullptr),
- fnFolder(nullptr),
- fnFactory(fnFactory_),
- wordListDescriptions(wordListDescriptions_),
- lexClasses(nullptr),
- nClasses(0),
- languageName(languageName_) {
-}
-
-int LexerModule::GetLanguage() const noexcept {
- return language;
-}
-
-int LexerModule::GetNumWordLists() const noexcept {
- if (!wordListDescriptions) {
- return -1;
- } else {
- int numWordLists = 0;
-
- while (wordListDescriptions[numWordLists]) {
- ++numWordLists;
- }
-
- return numWordLists;
- }
-}
-
-const char *LexerModule::GetWordListDescription(int index) const noexcept {
- assert(index < GetNumWordLists());
- if (!wordListDescriptions || (index >= GetNumWordLists())) {
- return "";
- } else {
- return wordListDescriptions[index];
- }
-}
-
-const LexicalClass *LexerModule::LexClasses() const noexcept {
- return lexClasses;
-}
-
-size_t LexerModule::NamedStyles() const noexcept {
- return nClasses;
-}
-
-ILexer5 *LexerModule::Create() const {
- if (fnFactory)
- return fnFactory();
- else
- return new LexerSimple(this);
-}
-
-void LexerModule::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler) const {
- if (fnLexer)
- fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler);
-}
-
-void LexerModule::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler) const {
- if (fnFolder) {
- Sci_Position lineCurrent = styler.GetLine(startPos);
- // Move back one line in case deletion wrecked current line fold state
- if (lineCurrent > 0) {
- lineCurrent--;
- const Sci_Position newStartPos = styler.LineStart(lineCurrent);
- lengthDoc += startPos - newStartPos;
- startPos = newStartPos;
- initStyle = 0;
- if (startPos > 0) {
- initStyle = styler.StyleAt(startPos - 1);
- }
- }
- fnFolder(startPos, lengthDoc, initStyle, keywordlists, styler);
- }
-}
diff --git a/lexlib/LexerModule.h b/lexlib/LexerModule.h
deleted file mode 100644
index 83bdf237d..000000000
--- a/lexlib/LexerModule.h
+++ /dev/null
@@ -1,92 +0,0 @@
-// Scintilla source code edit control
-/** @file LexerModule.h
- ** Colourise for particular languages.
- **/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef LEXERMODULE_H
-#define LEXERMODULE_H
-
-namespace Scintilla {
-
-class Accessor;
-class WordList;
-struct LexicalClass;
-
-typedef void (*LexerFunction)(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler);
-typedef ILexer5 *(*LexerFactoryFunction)();
-
-/**
- * A LexerModule is responsible for lexing and folding a particular language.
- * The Catalogue class maintains a list of LexerModules which can be searched to find a
- * module appropriate to a particular language.
- * The ExternalLexerModule subclass holds lexers loaded from DLLs or shared libraries.
- */
-class LexerModule {
-protected:
- int language;
- LexerFunction fnLexer;
- LexerFunction fnFolder;
- LexerFactoryFunction fnFactory;
- const char * const * wordListDescriptions;
- const LexicalClass *lexClasses;
- size_t nClasses;
-
-public:
- const char *languageName;
- LexerModule(
- int language_,
- LexerFunction fnLexer_,
- const char *languageName_=nullptr,
- LexerFunction fnFolder_= nullptr,
- const char * const wordListDescriptions_[]=nullptr,
- const LexicalClass *lexClasses_=nullptr,
- size_t nClasses_=0) noexcept;
- LexerModule(
- int language_,
- LexerFactoryFunction fnFactory_,
- const char *languageName_,
- const char * const wordListDescriptions_[]=nullptr) noexcept;
- int GetLanguage() const noexcept;
-
- // -1 is returned if no WordList information is available
- int GetNumWordLists() const noexcept;
- const char *GetWordListDescription(int index) const noexcept;
- const LexicalClass *LexClasses() const noexcept;
- size_t NamedStyles() const noexcept;
-
- ILexer5 *Create() const;
-
- void Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler) const;
- void Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler) const;
-
- friend class CatalogueModules;
-};
-
-inline int Maximum(int a, int b) noexcept {
- return (a > b) ? a : b;
-}
-
-// Shut up annoying Visual C++ warnings:
-#ifdef _MSC_VER
-#pragma warning(disable: 4244 4456 4457)
-#endif
-
-// Turn off shadow warnings for lexers as may be maintained by others
-#if defined(__GNUC__)
-#pragma GCC diagnostic ignored "-Wshadow"
-#endif
-
-// Clang doesn't like omitting braces in array initialization but they just add
-// noise to LexicalClass arrays in lexers
-#if defined(__clang__)
-#pragma clang diagnostic ignored "-Wmissing-braces"
-#endif
-
-}
-
-#endif
diff --git a/lexlib/LexerNoExceptions.cxx b/lexlib/LexerNoExceptions.cxx
deleted file mode 100644
index 3627e188a..000000000
--- a/lexlib/LexerNoExceptions.cxx
+++ /dev/null
@@ -1,62 +0,0 @@
-// Scintilla source code edit control
-/** @file LexerNoExceptions.cxx
- ** A simple lexer with no state which does not throw exceptions so can be used in an external lexer.
- **/
-// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#include <cstdlib>
-#include <cassert>
-
-#include "ILexer.h"
-#include "Scintilla.h"
-#include "SciLexer.h"
-
-#include "PropSetSimple.h"
-#include "WordList.h"
-#include "LexAccessor.h"
-#include "Accessor.h"
-#include "LexerModule.h"
-#include "LexerBase.h"
-#include "LexerNoExceptions.h"
-
-using namespace Scintilla;
-
-Sci_Position SCI_METHOD LexerNoExceptions::PropertySet(const char *key, const char *val) {
- try {
- return LexerBase::PropertySet(key, val);
- } catch (...) {
- // Should not throw into caller as may be compiled with different compiler or options
- }
- return -1;
-}
-
-Sci_Position SCI_METHOD LexerNoExceptions::WordListSet(int n, const char *wl) {
- try {
- return LexerBase::WordListSet(n, wl);
- } catch (...) {
- // Should not throw into caller as may be compiled with different compiler or options
- }
- return -1;
-}
-
-void SCI_METHOD LexerNoExceptions::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) {
- try {
- Accessor astyler(pAccess, &props);
- Lexer(startPos, lengthDoc, initStyle, pAccess, astyler);
- astyler.Flush();
- } catch (...) {
- // Should not throw into caller as may be compiled with different compiler or options
- pAccess->SetErrorStatus(SC_STATUS_FAILURE);
- }
-}
-void SCI_METHOD LexerNoExceptions::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) {
- try {
- Accessor astyler(pAccess, &props);
- Folder(startPos, lengthDoc, initStyle, pAccess, astyler);
- astyler.Flush();
- } catch (...) {
- // Should not throw into caller as may be compiled with different compiler or options
- pAccess->SetErrorStatus(SC_STATUS_FAILURE);
- }
-}
diff --git a/lexlib/LexerNoExceptions.h b/lexlib/LexerNoExceptions.h
deleted file mode 100644
index 5bcb090f0..000000000
--- a/lexlib/LexerNoExceptions.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Scintilla source code edit control
-/** @file LexerNoExceptions.h
- ** A simple lexer with no state.
- **/
-// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef LEXERNOEXCEPTIONS_H
-#define LEXERNOEXCEPTIONS_H
-
-namespace Scintilla {
-
-// A simple lexer with no state
-class LexerNoExceptions : public LexerBase {
-public:
- // TODO Also need to prevent exceptions in constructor and destructor
- Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
- Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
- void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override;
- void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *) override;
-
- virtual void Lexer(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess, Accessor &styler) = 0;
- virtual void Folder(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess, Accessor &styler) = 0;
-};
-
-}
-
-#endif
diff --git a/lexlib/LexerSimple.cxx b/lexlib/LexerSimple.cxx
deleted file mode 100644
index e69c44ad6..000000000
--- a/lexlib/LexerSimple.cxx
+++ /dev/null
@@ -1,61 +0,0 @@
-// Scintilla source code edit control
-/** @file LexerSimple.cxx
- ** A simple lexer with no state.
- **/
-// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#include <cstdlib>
-#include <cassert>
-
-#include <string>
-
-#include "ILexer.h"
-#include "Scintilla.h"
-#include "SciLexer.h"
-
-#include "PropSetSimple.h"
-#include "WordList.h"
-#include "LexAccessor.h"
-#include "Accessor.h"
-#include "LexerModule.h"
-#include "LexerBase.h"
-#include "LexerSimple.h"
-
-using namespace Scintilla;
-
-LexerSimple::LexerSimple(const LexerModule *module_) :
- LexerBase(module_->LexClasses(), module_->NamedStyles()),
- module(module_) {
- for (int wl = 0; wl < module->GetNumWordLists(); wl++) {
- if (!wordLists.empty())
- wordLists += "\n";
- wordLists += module->GetWordListDescription(wl);
- }
-}
-
-const char * SCI_METHOD LexerSimple::DescribeWordListSets() {
- return wordLists.c_str();
-}
-
-void SCI_METHOD LexerSimple::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) {
- Accessor astyler(pAccess, &props);
- module->Lex(startPos, lengthDoc, initStyle, keyWordLists, astyler);
- astyler.Flush();
-}
-
-void SCI_METHOD LexerSimple::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) {
- if (props.GetInt("fold")) {
- Accessor astyler(pAccess, &props);
- module->Fold(startPos, lengthDoc, initStyle, keyWordLists, astyler);
- astyler.Flush();
- }
-}
-
-const char * SCI_METHOD LexerSimple::GetName() {
- return module->languageName;
-}
-
-int SCI_METHOD LexerSimple::GetIdentifier() {
- return module->GetLanguage();
-}
diff --git a/lexlib/LexerSimple.h b/lexlib/LexerSimple.h
deleted file mode 100644
index ae4177769..000000000
--- a/lexlib/LexerSimple.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Scintilla source code edit control
-/** @file LexerSimple.h
- ** A simple lexer with no state.
- **/
-// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef LEXERSIMPLE_H
-#define LEXERSIMPLE_H
-
-namespace Scintilla {
-
-// A simple lexer with no state
-class LexerSimple : public LexerBase {
- const LexerModule *module;
- std::string wordLists;
-public:
- explicit LexerSimple(const LexerModule *module_);
- const char * SCI_METHOD DescribeWordListSets() override;
- void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override;
- void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override;
- // ILexer5 methods
- const char * SCI_METHOD GetName() override;
- int SCI_METHOD GetIdentifier() override;
-};
-
-}
-
-#endif
diff --git a/lexlib/OptionSet.h b/lexlib/OptionSet.h
deleted file mode 100644
index 3c282e49b..000000000
--- a/lexlib/OptionSet.h
+++ /dev/null
@@ -1,149 +0,0 @@
-// Scintilla source code edit control
-/** @file OptionSet.h
- ** Manage descriptive information about an options struct for a lexer.
- ** Hold the names, positions, and descriptions of boolean, integer and string options and
- ** allow setting options and retrieving metadata about the options.
- **/
-// Copyright 2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef OPTIONSET_H
-#define OPTIONSET_H
-
-namespace Scintilla {
-
-template <typename T>
-class OptionSet {
- typedef T Target;
- typedef bool T::*plcob;
- typedef int T::*plcoi;
- typedef std::string T::*plcos;
- struct Option {
- int opType;
- union {
- plcob pb;
- plcoi pi;
- plcos ps;
- };
- std::string value;
- std::string description;
- Option() :
- opType(SC_TYPE_BOOLEAN), pb(0), description("") {
- }
- Option(plcob pb_, std::string description_="") :
- opType(SC_TYPE_BOOLEAN), pb(pb_), description(description_) {
- }
- Option(plcoi pi_, std::string description_) :
- opType(SC_TYPE_INTEGER), pi(pi_), description(description_) {
- }
- Option(plcos ps_, std::string description_) :
- opType(SC_TYPE_STRING), ps(ps_), description(description_) {
- }
- bool Set(T *base, const char *val) {
- value = val;
- switch (opType) {
- case SC_TYPE_BOOLEAN: {
- bool option = atoi(val) != 0;
- if ((*base).*pb != option) {
- (*base).*pb = option;
- return true;
- }
- break;
- }
- case SC_TYPE_INTEGER: {
- int option = atoi(val);
- if ((*base).*pi != option) {
- (*base).*pi = option;
- return true;
- }
- break;
- }
- case SC_TYPE_STRING: {
- if ((*base).*ps != val) {
- (*base).*ps = val;
- return true;
- }
- break;
- }
- }
- return false;
- }
- const char *Get() const noexcept {
- return value.c_str();
- }
- };
- typedef std::map<std::string, Option> OptionMap;
- OptionMap nameToDef;
- std::string names;
- std::string wordLists;
-
- void AppendName(const char *name) {
- if (!names.empty())
- names += "\n";
- names += name;
- }
-public:
- void DefineProperty(const char *name, plcob pb, std::string description="") {
- nameToDef[name] = Option(pb, description);
- AppendName(name);
- }
- void DefineProperty(const char *name, plcoi pi, std::string description="") {
- nameToDef[name] = Option(pi, description);
- AppendName(name);
- }
- void DefineProperty(const char *name, plcos ps, std::string description="") {
- nameToDef[name] = Option(ps, description);
- AppendName(name);
- }
- const char *PropertyNames() const noexcept {
- return names.c_str();
- }
- int PropertyType(const char *name) {
- typename OptionMap::iterator it = nameToDef.find(name);
- if (it != nameToDef.end()) {
- return it->second.opType;
- }
- return SC_TYPE_BOOLEAN;
- }
- const char *DescribeProperty(const char *name) {
- typename OptionMap::iterator it = nameToDef.find(name);
- if (it != nameToDef.end()) {
- return it->second.description.c_str();
- }
- return "";
- }
-
- bool PropertySet(T *base, const char *name, const char *val) {
- typename OptionMap::iterator it = nameToDef.find(name);
- if (it != nameToDef.end()) {
- return it->second.Set(base, val);
- }
- return false;
- }
-
- const char *PropertyGet(const char *name) {
- typename OptionMap::iterator it = nameToDef.find(name);
- if (it != nameToDef.end()) {
- return it->second.Get();
- }
- return nullptr;
- }
-
- void DefineWordListSets(const char * const wordListDescriptions[]) {
- if (wordListDescriptions) {
- for (size_t wl = 0; wordListDescriptions[wl]; wl++) {
- if (!wordLists.empty())
- wordLists += "\n";
- wordLists += wordListDescriptions[wl];
- }
- }
- }
-
- const char *DescribeWordListSets() const noexcept {
- return wordLists.c_str();
- }
-};
-
-}
-
-#endif
diff --git a/lexlib/PropSetSimple.cxx b/lexlib/PropSetSimple.cxx
deleted file mode 100644
index 6ee57d667..000000000
--- a/lexlib/PropSetSimple.cxx
+++ /dev/null
@@ -1,157 +0,0 @@
-// Scintilla source code edit control
-/** @file PropSetSimple.cxx
- ** A basic string to string map.
- **/
-// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-// Maintain a dictionary of properties
-
-#include <cstdlib>
-#include <cstring>
-
-#include <string>
-#include <map>
-
-#include "PropSetSimple.h"
-
-using namespace Scintilla;
-
-namespace {
-
-typedef std::map<std::string, std::string> mapss;
-
-mapss *PropsFromPointer(void *impl) noexcept {
- return static_cast<mapss *>(impl);
-}
-
-constexpr bool IsASpaceCharacter(int ch) noexcept {
- return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
-}
-
-}
-
-PropSetSimple::PropSetSimple() {
- mapss *props = new mapss;
- impl = static_cast<void *>(props);
-}
-
-PropSetSimple::~PropSetSimple() {
- mapss *props = PropsFromPointer(impl);
- delete props;
- impl = nullptr;
-}
-
-void PropSetSimple::Set(const char *key, const char *val, size_t lenKey, size_t lenVal) {
- mapss *props = PropsFromPointer(impl);
- if (!*key) // Empty keys are not supported
- return;
- (*props)[std::string(key, lenKey)] = std::string(val, lenVal);
-}
-
-void PropSetSimple::Set(const char *keyVal) {
- while (IsASpaceCharacter(*keyVal))
- keyVal++;
- const char *endVal = keyVal;
- while (*endVal && (*endVal != '\n'))
- endVal++;
- const char *eqAt = strchr(keyVal, '=');
- if (eqAt) {
- Set(keyVal, eqAt + 1, eqAt-keyVal,
- endVal - eqAt - 1);
- } else if (*keyVal) { // No '=' so assume '=1'
- Set(keyVal, "1", endVal-keyVal, 1);
- }
-}
-
-void PropSetSimple::SetMultiple(const char *s) {
- const char *eol = strchr(s, '\n');
- while (eol) {
- Set(s);
- s = eol + 1;
- eol = strchr(s, '\n');
- }
- Set(s);
-}
-
-const char *PropSetSimple::Get(const char *key) const {
- mapss *props = PropsFromPointer(impl);
- mapss::const_iterator keyPos = props->find(std::string(key));
- if (keyPos != props->end()) {
- return keyPos->second.c_str();
- } else {
- return "";
- }
-}
-
-// There is some inconsistency between GetExpanded("foo") and Expand("$(foo)").
-// A solution is to keep a stack of variables that have been expanded, so that
-// recursive expansions can be skipped. For now I'll just use the C++ stack
-// for that, through a recursive function and a simple chain of pointers.
-
-struct VarChain {
- VarChain(const char *var_=nullptr, const VarChain *link_= nullptr) noexcept : var(var_), link(link_) {}
-
- bool contains(const char *testVar) const {
- return (var && (0 == strcmp(var, testVar)))
- || (link && link->contains(testVar));
- }
-
- const char *var;
- const VarChain *link;
-};
-
-static int ExpandAllInPlace(const PropSetSimple &props, std::string &withVars, int maxExpands, const VarChain &blankVars) {
- size_t varStart = withVars.find("$(");
- while ((varStart != std::string::npos) && (maxExpands > 0)) {
- const size_t varEnd = withVars.find(')', varStart+2);
- if (varEnd == std::string::npos) {
- break;
- }
-
- // For consistency, when we see '$(ab$(cde))', expand the inner variable first,
- // regardless whether there is actually a degenerate variable named 'ab$(cde'.
- size_t innerVarStart = withVars.find("$(", varStart+2);
- while ((innerVarStart != std::string::npos) && (innerVarStart > varStart) && (innerVarStart < varEnd)) {
- varStart = innerVarStart;
- innerVarStart = withVars.find("$(", varStart+2);
- }
-
- std::string var(withVars, varStart + 2, varEnd - varStart - 2);
- std::string val = props.Get(var.c_str());
-
- if (blankVars.contains(var.c_str())) {
- val = ""; // treat blankVar as an empty string (e.g. to block self-reference)
- }
-
- if (--maxExpands >= 0) {
- maxExpands = ExpandAllInPlace(props, val, maxExpands, VarChain(var.c_str(), &blankVars));
- }
-
- withVars.erase(varStart, varEnd-varStart+1);
- withVars.insert(varStart, val.c_str(), val.length());
-
- varStart = withVars.find("$(");
- }
-
- return maxExpands;
-}
-
-size_t PropSetSimple::GetExpanded(const char *key, char *result) const {
- std::string val = Get(key);
- ExpandAllInPlace(*this, val, 100, VarChain(key));
- const size_t n = val.size();
- if (result) {
- memcpy(result, val.c_str(), n+1);
- }
- return n; // Not including NUL
-}
-
-int PropSetSimple::GetInt(const char *key, int defaultValue) const {
- std::string val = Get(key);
- ExpandAllInPlace(*this, val, 100, VarChain(key));
- if (!val.empty()) {
- return atoi(val.c_str());
- }
- return defaultValue;
-}
diff --git a/lexlib/PropSetSimple.h b/lexlib/PropSetSimple.h
deleted file mode 100644
index d4a5b2243..000000000
--- a/lexlib/PropSetSimple.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Scintilla source code edit control
-/** @file PropSetSimple.h
- ** A basic string to string map.
- **/
-// Copyright 1998-2009 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef PROPSETSIMPLE_H
-#define PROPSETSIMPLE_H
-
-namespace Scintilla {
-
-class PropSetSimple {
- void *impl;
- void Set(const char *keyVal);
-public:
- PropSetSimple();
- virtual ~PropSetSimple();
- void Set(const char *key, const char *val, size_t lenKey, size_t lenVal);
- void SetMultiple(const char *);
- const char *Get(const char *key) const;
- size_t GetExpanded(const char *key, char *result) const;
- int GetInt(const char *key, int defaultValue=0) const;
-};
-
-}
-
-#endif
diff --git a/lexlib/SparseState.h b/lexlib/SparseState.h
deleted file mode 100644
index 6286c76af..000000000
--- a/lexlib/SparseState.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// Scintilla source code edit control
-/** @file SparseState.h
- ** Hold lexer state that may change rarely.
- ** This is often per-line state such as whether a particular type of section has been entered.
- ** A state continues until it is changed.
- **/
-// Copyright 2011 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef SPARSESTATE_H
-#define SPARSESTATE_H
-
-namespace Scintilla {
-
-template <typename T>
-class SparseState {
- struct State {
- Sci_Position position;
- T value;
- constexpr State(Sci_Position position_, T value_) noexcept : position(position_), value(value_) {
- }
- inline bool operator<(const State &other) const noexcept {
- return position < other.position;
- }
- inline bool operator==(const State &other) const noexcept {
- return (position == other.position) && (value == other.value);
- }
- };
- Sci_Position positionFirst;
- typedef std::vector<State> stateVector;
- stateVector states;
-
- typename stateVector::iterator Find(Sci_Position position) {
- const State searchValue(position, T());
- return std::lower_bound(states.begin(), states.end(), searchValue);
- }
-
-public:
- explicit SparseState(Sci_Position positionFirst_=-1) {
- positionFirst = positionFirst_;
- }
- void Set(Sci_Position position, T value) {
- Delete(position);
- if (states.empty() || (value != states[states.size()-1].value)) {
- states.push_back(State(position, value));
- }
- }
- T ValueAt(Sci_Position position) {
- if (states.empty())
- return T();
- if (position < states[0].position)
- return T();
- typename stateVector::iterator low = Find(position);
- if (low == states.end()) {
- return states[states.size()-1].value;
- } else {
- if (low->position > position) {
- --low;
- }
- return low->value;
- }
- }
- bool Delete(Sci_Position position) {
- typename stateVector::iterator low = Find(position);
- if (low != states.end()) {
- states.erase(low, states.end());
- return true;
- }
- return false;
- }
- size_t size() const {
- return states.size();
- }
-
- // Returns true if Merge caused a significant change
- bool Merge(const SparseState<T> &other, Sci_Position ignoreAfter) {
- // Changes caused beyond ignoreAfter are not significant
- Delete(ignoreAfter+1);
-
- bool different = true;
- bool changed = false;
- typename stateVector::iterator low = Find(other.positionFirst);
- if (static_cast<size_t>(states.end() - low) == other.states.size()) {
- // Same number in other as after positionFirst in this
- different = !std::equal(low, states.end(), other.states.begin());
- }
- if (different) {
- if (low != states.end()) {
- states.erase(low, states.end());
- changed = true;
- }
- typename stateVector::const_iterator startOther = other.states.begin();
- if (!states.empty() && !other.states.empty() && states.back().value == startOther->value)
- ++startOther;
- if (startOther != other.states.end()) {
- states.insert(states.end(), startOther, other.states.end());
- changed = true;
- }
- }
- return changed;
- }
-};
-
-}
-
-#endif
diff --git a/lexlib/StringCopy.h b/lexlib/StringCopy.h
deleted file mode 100644
index 1c5442e65..000000000
--- a/lexlib/StringCopy.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Scintilla source code edit control
-/** @file StringCopy.h
- ** Safe string copy function which always NUL terminates.
- ** ELEMENTS macro for determining array sizes.
- **/
-// Copyright 2013 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef STRINGCOPY_H
-#define STRINGCOPY_H
-
-namespace Scintilla {
-
-// Safer version of string copy functions like strcpy, wcsncpy, etc.
-// Instantiate over fixed length strings of both char and wchar_t.
-// May truncate if source doesn't fit into dest with room for NUL.
-
-template <typename T, size_t count>
-void StringCopy(T (&dest)[count], const T* source) {
- for (size_t i=0; i<count; i++) {
- dest[i] = source[i];
- if (!source[i])
- break;
- }
- dest[count-1] = 0;
-}
-
-#define ELEMENTS(a) (sizeof(a) / sizeof(a[0]))
-
-}
-
-#endif
diff --git a/lexlib/StyleContext.cxx b/lexlib/StyleContext.cxx
deleted file mode 100644
index fe56e53d7..000000000
--- a/lexlib/StyleContext.cxx
+++ /dev/null
@@ -1,68 +0,0 @@
-// Scintilla source code edit control
-/** @file StyleContext.cxx
- ** Lexer infrastructure.
- **/
-// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
-// This file is in the public domain.
-
-#include <cstdlib>
-#include <cassert>
-
-#include "ILexer.h"
-
-#include "LexAccessor.h"
-#include "Accessor.h"
-#include "StyleContext.h"
-#include "CharacterSet.h"
-
-using namespace Scintilla;
-
-bool StyleContext::MatchIgnoreCase(const char *s) {
- if (MakeLowerCase(ch) != static_cast<unsigned char>(*s))
- return false;
- s++;
- if (MakeLowerCase(chNext) != static_cast<unsigned char>(*s))
- return false;
- s++;
- for (int n = 2; *s; n++) {
- if (*s !=
- MakeLowerCase(styler.SafeGetCharAt(currentPos + n, 0)))
- return false;
- s++;
- }
- return true;
-}
-
-static void getRange(Sci_PositionU start,
- Sci_PositionU end,
- LexAccessor &styler,
- char *s,
- Sci_PositionU len) {
- Sci_PositionU i = 0;
- while ((i < end - start + 1) && (i < len-1)) {
- s[i] = styler[start + i];
- i++;
- }
- s[i] = '\0';
-}
-
-void StyleContext::GetCurrent(char *s, Sci_PositionU len) {
- getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len);
-}
-
-static void getRangeLowered(Sci_PositionU start,
- Sci_PositionU end,
- LexAccessor &styler,
- char *s,
- Sci_PositionU len) {
- Sci_PositionU i = 0;
- while ((i < end - start + 1) && (i < len-1)) {
- s[i] = MakeLowerCase(styler[start + i]);
- i++;
- }
- s[i] = '\0';
-}
-
-void StyleContext::GetCurrentLowered(char *s, Sci_PositionU len) {
- getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len);
-}
diff --git a/lexlib/StyleContext.h b/lexlib/StyleContext.h
deleted file mode 100644
index c9ff4efbb..000000000
--- a/lexlib/StyleContext.h
+++ /dev/null
@@ -1,212 +0,0 @@
-// Scintilla source code edit control
-/** @file StyleContext.h
- ** Lexer infrastructure.
- **/
-// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
-// This file is in the public domain.
-
-#ifndef STYLECONTEXT_H
-#define STYLECONTEXT_H
-
-namespace Scintilla {
-
-// All languages handled so far can treat all characters >= 0x80 as one class
-// which just continues the current token or starts an identifier if in default.
-// DBCS treated specially as the second character can be < 0x80 and hence
-// syntactically significant. UTF-8 avoids this as all trail bytes are >= 0x80
-class StyleContext {
- LexAccessor &styler;
- IDocument *multiByteAccess;
- Sci_PositionU endPos;
- Sci_PositionU lengthDocument;
-
- // Used for optimizing GetRelativeCharacter
- Sci_PositionU posRelative;
- Sci_PositionU currentPosLastRelative;
- Sci_Position offsetRelative;
-
- void GetNextChar() {
- if (multiByteAccess) {
- chNext = multiByteAccess->GetCharacterAndWidth(currentPos+width, &widthNext);
- } else {
- chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+width, 0));
- widthNext = 1;
- }
- // End of line determined from line end position, allowing CR, LF,
- // CRLF and Unicode line ends as set by document.
- if (currentLine < lineDocEnd)
- atLineEnd = static_cast<Sci_Position>(currentPos) >= (lineStartNext-1);
- else // Last line
- atLineEnd = static_cast<Sci_Position>(currentPos) >= lineStartNext;
- }
-
-public:
- Sci_PositionU currentPos;
- Sci_Position currentLine;
- Sci_Position lineDocEnd;
- Sci_Position lineStartNext;
- bool atLineStart;
- bool atLineEnd;
- int state;
- int chPrev;
- int ch;
- Sci_Position width;
- int chNext;
- Sci_Position widthNext;
-
- StyleContext(Sci_PositionU startPos, Sci_PositionU length,
- int initStyle, LexAccessor &styler_, char chMask='\377') :
- styler(styler_),
- multiByteAccess(nullptr),
- endPos(startPos + length),
- posRelative(0),
- currentPosLastRelative(0x7FFFFFFF),
- offsetRelative(0),
- currentPos(startPos),
- currentLine(-1),
- lineStartNext(-1),
- atLineEnd(false),
- state(initStyle & chMask), // Mask off all bits which aren't in the chMask.
- chPrev(0),
- ch(0),
- width(0),
- chNext(0),
- widthNext(1) {
- if (styler.Encoding() != EncodingType::eightBit) {
- multiByteAccess = styler.MultiByteAccess();
- }
- styler.StartAt(startPos /*, chMask*/);
- styler.StartSegment(startPos);
- currentLine = styler.GetLine(startPos);
- lineStartNext = styler.LineStart(currentLine+1);
- lengthDocument = static_cast<Sci_PositionU>(styler.Length());
- if (endPos == lengthDocument)
- endPos++;
- lineDocEnd = styler.GetLine(lengthDocument);
- atLineStart = static_cast<Sci_PositionU>(styler.LineStart(currentLine)) == startPos;
-
- // Variable width is now 0 so GetNextChar gets the char at currentPos into chNext/widthNext
- width = 0;
- GetNextChar();
- ch = chNext;
- width = widthNext;
-
- GetNextChar();
- }
- // Deleted so StyleContext objects can not be copied.
- StyleContext(const StyleContext &) = delete;
- StyleContext &operator=(const StyleContext &) = delete;
- void Complete() {
- styler.ColourTo(currentPos - ((currentPos > lengthDocument) ? 2 : 1), state);
- styler.Flush();
- }
- bool More() const noexcept {
- return currentPos < endPos;
- }
- void Forward() {
- if (currentPos < endPos) {
- atLineStart = atLineEnd;
- if (atLineStart) {
- currentLine++;
- lineStartNext = styler.LineStart(currentLine+1);
- }
- chPrev = ch;
- currentPos += width;
- ch = chNext;
- width = widthNext;
- GetNextChar();
- } else {
- atLineStart = false;
- chPrev = ' ';
- ch = ' ';
- chNext = ' ';
- atLineEnd = true;
- }
- }
- void Forward(Sci_Position nb) {
- for (Sci_Position i = 0; i < nb; i++) {
- Forward();
- }
- }
- void ForwardBytes(Sci_Position nb) {
- const Sci_PositionU forwardPos = currentPos + nb;
- while (forwardPos > currentPos) {
- const Sci_PositionU currentPosStart = currentPos;
- Forward();
- if (currentPos == currentPosStart) {
- // Reached end
- return;
- }
- }
- }
- void ChangeState(int state_) noexcept {
- state = state_;
- }
- void SetState(int state_) {
- styler.ColourTo(currentPos - ((currentPos > lengthDocument) ? 2 : 1), state);
- state = state_;
- }
- void ForwardSetState(int state_) {
- Forward();
- styler.ColourTo(currentPos - ((currentPos > lengthDocument) ? 2 : 1), state);
- state = state_;
- }
- Sci_Position LengthCurrent() const {
- return currentPos - styler.GetStartSegment();
- }
- int GetRelative(Sci_Position n, char chDefault='\0') {
- return static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+n, chDefault));
- }
- int GetRelativeCharacter(Sci_Position n) {
- if (n == 0)
- return ch;
- if (multiByteAccess) {
- if ((currentPosLastRelative != currentPos) ||
- ((n > 0) && ((offsetRelative < 0) || (n < offsetRelative))) ||
- ((n < 0) && ((offsetRelative > 0) || (n > offsetRelative)))) {
- posRelative = currentPos;
- offsetRelative = 0;
- }
- const Sci_Position diffRelative = n - offsetRelative;
- const Sci_Position posNew = multiByteAccess->GetRelativePosition(posRelative, diffRelative);
- const int chReturn = multiByteAccess->GetCharacterAndWidth(posNew, nullptr);
- posRelative = posNew;
- currentPosLastRelative = currentPos;
- offsetRelative = n;
- return chReturn;
- } else {
- // fast version for single byte encodings
- return static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + n, 0));
- }
- }
- bool Match(char ch0) const {
- return ch == static_cast<unsigned char>(ch0);
- }
- bool Match(char ch0, char ch1) const {
- return (ch == static_cast<unsigned char>(ch0)) && (chNext == static_cast<unsigned char>(ch1));
- }
- bool Match(const char *s) {
- if (ch != static_cast<unsigned char>(*s))
- return false;
- s++;
- if (!*s)
- return true;
- if (chNext != static_cast<unsigned char>(*s))
- return false;
- s++;
- for (int n=2; *s; n++) {
- if (*s != styler.SafeGetCharAt(currentPos+n, 0))
- return false;
- s++;
- }
- return true;
- }
- // Non-inline
- bool MatchIgnoreCase(const char *s);
- void GetCurrent(char *s, Sci_PositionU len);
- void GetCurrentLowered(char *s, Sci_PositionU len);
-};
-
-}
-
-#endif
diff --git a/lexlib/SubStyles.h b/lexlib/SubStyles.h
deleted file mode 100644
index 4bfe7ebfc..000000000
--- a/lexlib/SubStyles.h
+++ /dev/null
@@ -1,208 +0,0 @@
-// Scintilla source code edit control
-/** @file SubStyles.h
- ** Manage substyles for a lexer.
- **/
-// Copyright 2012 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef SUBSTYLES_H
-#define SUBSTYLES_H
-
-namespace Scintilla {
-
-class WordClassifier {
- int baseStyle;
- int firstStyle;
- int lenStyles;
- std::map<std::string, int> wordToStyle;
-
-public:
-
- explicit WordClassifier(int baseStyle_) : baseStyle(baseStyle_), firstStyle(0), lenStyles(0) {
- }
-
- void Allocate(int firstStyle_, int lenStyles_) {
- firstStyle = firstStyle_;
- lenStyles = lenStyles_;
- wordToStyle.clear();
- }
-
- int Base() const noexcept {
- return baseStyle;
- }
-
- int Start() const noexcept {
- return firstStyle;
- }
-
- int Last() const noexcept {
- return firstStyle + lenStyles - 1;
- }
-
- int Length() const noexcept {
- return lenStyles;
- }
-
- void Clear() noexcept {
- firstStyle = 0;
- lenStyles = 0;
- wordToStyle.clear();
- }
-
- int ValueFor(const std::string &s) const {
- std::map<std::string, int>::const_iterator it = wordToStyle.find(s);
- if (it != wordToStyle.end())
- return it->second;
- else
- return -1;
- }
-
- bool IncludesStyle(int style) const noexcept {
- return (style >= firstStyle) && (style < (firstStyle + lenStyles));
- }
-
- void RemoveStyle(int style) {
- std::map<std::string, int>::iterator it = wordToStyle.begin();
- while (it != wordToStyle.end()) {
- if (it->second == style) {
- it = wordToStyle.erase(it);
- } else {
- ++it;
- }
- }
- }
-
- void SetIdentifiers(int style, const char *identifiers) {
- RemoveStyle(style);
- while (*identifiers) {
- const char *cpSpace = identifiers;
- while (*cpSpace && !(*cpSpace == ' ' || *cpSpace == '\t' || *cpSpace == '\r' || *cpSpace == '\n'))
- cpSpace++;
- if (cpSpace > identifiers) {
- std::string word(identifiers, cpSpace - identifiers);
- wordToStyle[word] = style;
- }
- identifiers = cpSpace;
- if (*identifiers)
- identifiers++;
- }
- }
-};
-
-class SubStyles {
- int classifications;
- const char *baseStyles;
- int styleFirst;
- int stylesAvailable;
- int secondaryDistance;
- int allocated;
- std::vector<WordClassifier> classifiers;
-
- int BlockFromBaseStyle(int baseStyle) const noexcept {
- for (int b=0; b < classifications; b++) {
- if (baseStyle == baseStyles[b])
- return b;
- }
- return -1;
- }
-
- int BlockFromStyle(int style) const {
- int b = 0;
- for (std::vector<WordClassifier>::const_iterator it=classifiers.begin(); it != classifiers.end(); ++it) {
- if (it->IncludesStyle(style))
- return b;
- b++;
- }
- return -1;
- }
-
-public:
-
- SubStyles(const char *baseStyles_, int styleFirst_, int stylesAvailable_, int secondaryDistance_) :
- classifications(0),
- baseStyles(baseStyles_),
- styleFirst(styleFirst_),
- stylesAvailable(stylesAvailable_),
- secondaryDistance(secondaryDistance_),
- allocated(0) {
- while (baseStyles[classifications]) {
- classifiers.push_back(WordClassifier(baseStyles[classifications]));
- classifications++;
- }
- }
-
- int Allocate(int styleBase, int numberStyles) {
- const int block = BlockFromBaseStyle(styleBase);
- if (block >= 0) {
- if ((allocated + numberStyles) > stylesAvailable)
- return -1;
- const int startBlock = styleFirst + allocated;
- allocated += numberStyles;
- classifiers[block].Allocate(startBlock, numberStyles);
- return startBlock;
- } else {
- return -1;
- }
- }
-
- int Start(int styleBase) noexcept {
- const int block = BlockFromBaseStyle(styleBase);
- return (block >= 0) ? classifiers[block].Start() : -1;
- }
-
- int Length(int styleBase) noexcept {
- const int block = BlockFromBaseStyle(styleBase);
- return (block >= 0) ? classifiers[block].Length() : 0;
- }
-
- int BaseStyle(int subStyle) const {
- const int block = BlockFromStyle(subStyle);
- if (block >= 0)
- return classifiers[block].Base();
- else
- return subStyle;
- }
-
- int DistanceToSecondaryStyles() const noexcept {
- return secondaryDistance;
- }
-
- int FirstAllocated() const {
- int start = 257;
- for (std::vector<WordClassifier>::const_iterator it = classifiers.begin(); it != classifiers.end(); ++it) {
- if (start > it->Start())
- start = it->Start();
- }
- return (start < 256) ? start : -1;
- }
-
- int LastAllocated() const {
- int last = -1;
- for (std::vector<WordClassifier>::const_iterator it = classifiers.begin(); it != classifiers.end(); ++it) {
- if (last < it->Last())
- last = it->Last();
- }
- return last;
- }
-
- void SetIdentifiers(int style, const char *identifiers) {
- const int block = BlockFromStyle(style);
- if (block >= 0)
- classifiers[block].SetIdentifiers(style, identifiers);
- }
-
- void Free() {
- allocated = 0;
- for (std::vector<WordClassifier>::iterator it=classifiers.begin(); it != classifiers.end(); ++it)
- it->Clear();
- }
-
- const WordClassifier &Classifier(int baseStyle) const noexcept {
- const int block = BlockFromBaseStyle(baseStyle);
- return classifiers[block >= 0 ? block : 0];
- }
-};
-
-}
-
-#endif
diff --git a/lexlib/WordList.cxx b/lexlib/WordList.cxx
deleted file mode 100644
index 460995daa..000000000
--- a/lexlib/WordList.cxx
+++ /dev/null
@@ -1,315 +0,0 @@
-// Scintilla source code edit control
-/** @file WordList.cxx
- ** Hold a list of words.
- **/
-// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#include <cstdlib>
-#include <cassert>
-#include <cstring>
-
-#include <algorithm>
-#include <iterator>
-
-#include "WordList.h"
-
-using namespace Scintilla;
-
-/**
- * Creates an array that points into each word in the string and puts \0 terminators
- * after each word.
- */
-static char **ArrayFromWordList(char *wordlist, size_t slen, int *len, bool onlyLineEnds = false) {
- int prev = '\n';
- int words = 0;
- // For rapid determination of whether a character is a separator, build
- // a look up table.
- bool wordSeparator[256] = {}; // Initialise all to false.
- wordSeparator[static_cast<unsigned int>('\r')] = true;
- wordSeparator[static_cast<unsigned int>('\n')] = true;
- if (!onlyLineEnds) {
- wordSeparator[static_cast<unsigned int>(' ')] = true;
- wordSeparator[static_cast<unsigned int>('\t')] = true;
- }
- for (int j = 0; wordlist[j]; j++) {
- const int curr = static_cast<unsigned char>(wordlist[j]);
- if (!wordSeparator[curr] && wordSeparator[prev])
- words++;
- prev = curr;
- }
- char **keywords = new char *[words + 1];
- int wordsStore = 0;
- if (words) {
- prev = '\0';
- for (size_t k = 0; k < slen; k++) {
- if (!wordSeparator[static_cast<unsigned char>(wordlist[k])]) {
- if (!prev) {
- keywords[wordsStore] = &wordlist[k];
- wordsStore++;
- }
- } else {
- wordlist[k] = '\0';
- }
- prev = wordlist[k];
- }
- }
- assert(wordsStore < (words + 1));
- keywords[wordsStore] = &wordlist[slen];
- *len = wordsStore;
- return keywords;
-}
-
-WordList::WordList(bool onlyLineEnds_) :
- words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_) {
- // Prevent warnings by static analyzers about uninitialized starts.
- starts[0] = -1;
-}
-
-WordList::~WordList() {
- Clear();
-}
-
-WordList::operator bool() const noexcept {
- return len ? true : false;
-}
-
-bool WordList::operator!=(const WordList &other) const noexcept {
- if (len != other.len)
- return true;
- for (int i=0; i<len; i++) {
- if (strcmp(words[i], other.words[i]) != 0)
- return true;
- }
- return false;
-}
-
-int WordList::Length() const noexcept {
- return len;
-}
-
-void WordList::Clear() noexcept {
- if (words) {
- delete []list;
- delete []words;
- }
- words = nullptr;
- list = nullptr;
- len = 0;
-}
-
-#ifdef _MSC_VER
-
-static bool cmpWords(const char *a, const char *b) {
- return strcmp(a, b) < 0;
-}
-
-#else
-
-static int cmpWords(const void *a, const void *b) {
- return strcmp(*static_cast<const char * const *>(a), *static_cast<const char * const *>(b));
-}
-
-static void SortWordList(char **words, unsigned int len) {
- qsort(words, len, sizeof(*words), cmpWords);
-}
-
-#endif
-
-bool WordList::Set(const char *s) {
- const size_t lenS = strlen(s) + 1;
- char *listTemp = new char[lenS];
- memcpy(listTemp, s, lenS);
- int lenTemp = 0;
- char **wordsTemp = ArrayFromWordList(listTemp, lenS - 1, &lenTemp, onlyLineEnds);
-#ifdef _MSC_VER
- std::sort(wordsTemp, wordsTemp + lenTemp, cmpWords);
-#else
- SortWordList(wordsTemp, lenTemp);
-#endif
-
- if (lenTemp == len) {
- bool changed = false;
- for (int i = 0; i < lenTemp; i++) {
- if (strcmp(words[i], wordsTemp[i]) != 0) {
- changed = true;
- break;
- }
- }
- if (!changed) {
- delete []listTemp;
- delete []wordsTemp;
- return false;
- }
- }
-
- Clear();
- words = wordsTemp;
- list = listTemp;
- len = lenTemp;
- std::fill(starts, std::end(starts), -1);
- for (int l = len - 1; l >= 0; l--) {
- unsigned char indexChar = words[l][0];
- starts[indexChar] = l;
- }
- return true;
-}
-
-/** Check whether a string is in the list.
- * List elements are either exact matches or prefixes.
- * Prefix elements start with '^' and match all strings that start with the rest of the element
- * so '^GTK_' matches 'GTK_X', 'GTK_MAJOR_VERSION', and 'GTK_'.
- */
-bool WordList::InList(const char *s) const noexcept {
- if (0 == words)
- return false;
- const unsigned char firstChar = s[0];
- int j = starts[firstChar];
- if (j >= 0) {
- while (words[j][0] == firstChar) {
- if (s[1] == words[j][1]) {
- const char *a = words[j] + 1;
- const char *b = s + 1;
- while (*a && *a == *b) {
- a++;
- b++;
- }
- if (!*a && !*b)
- return true;
- }
- j++;
- }
- }
- j = starts[static_cast<unsigned int>('^')];
- if (j >= 0) {
- while (words[j][0] == '^') {
- const char *a = words[j] + 1;
- const char *b = s;
- while (*a && *a == *b) {
- a++;
- b++;
- }
- if (!*a)
- return true;
- j++;
- }
- }
- return false;
-}
-
-/** similar to InList, but word s can be a substring of keyword.
- * eg. the keyword define is defined as def~ine. This means the word must start
- * with def to be a keyword, but also defi, defin and define are valid.
- * The marker is ~ in this case.
- */
-bool WordList::InListAbbreviated(const char *s, const char marker) const noexcept {
- if (0 == words)
- return false;
- const unsigned char firstChar = s[0];
- int j = starts[firstChar];
- if (j >= 0) {
- while (words[j][0] == firstChar) {
- bool isSubword = false;
- int start = 1;
- if (words[j][1] == marker) {
- isSubword = true;
- start++;
- }
- if (s[1] == words[j][start]) {
- const char *a = words[j] + start;
- const char *b = s + 1;
- while (*a && *a == *b) {
- a++;
- if (*a == marker) {
- isSubword = true;
- a++;
- }
- b++;
- }
- if ((!*a || isSubword) && !*b)
- return true;
- }
- j++;
- }
- }
- j = starts[static_cast<unsigned int>('^')];
- if (j >= 0) {
- while (words[j][0] == '^') {
- const char *a = words[j] + 1;
- const char *b = s;
- while (*a && *a == *b) {
- a++;
- b++;
- }
- if (!*a)
- return true;
- j++;
- }
- }
- return false;
-}
-
-/** similar to InListAbbreviated, but word s can be a abridged version of a keyword.
-* eg. the keyword is defined as "after.~:". This means the word must have a prefix (begins with) of
-* "after." and suffix (ends with) of ":" to be a keyword, Hence "after.field:" , "after.form.item:" are valid.
-* Similarly "~.is.valid" keyword is suffix only... hence "field.is.valid" , "form.is.valid" are valid.
-* The marker is ~ in this case.
-* No multiple markers check is done and wont work.
-*/
-bool WordList::InListAbridged(const char *s, const char marker) const noexcept {
- if (0 == words)
- return false;
- const unsigned char firstChar = s[0];
- int j = starts[firstChar];
- if (j >= 0) {
- while (words[j][0] == firstChar) {
- const char *a = words[j];
- const char *b = s;
- while (*a && *a == *b) {
- a++;
- if (*a == marker) {
- a++;
- const size_t suffixLengthA = strlen(a);
- const size_t suffixLengthB = strlen(b);
- if (suffixLengthA >= suffixLengthB)
- break;
- b = b + suffixLengthB - suffixLengthA - 1;
- }
- b++;
- }
- if (!*a && !*b)
- return true;
- j++;
- }
- }
-
- j = starts[static_cast<unsigned int>(marker)];
- if (j >= 0) {
- while (words[j][0] == marker) {
- const char *a = words[j] + 1;
- const char *b = s;
- const size_t suffixLengthA = strlen(a);
- const size_t suffixLengthB = strlen(b);
- if (suffixLengthA > suffixLengthB) {
- j++;
- continue;
- }
- b = b + suffixLengthB - suffixLengthA;
-
- while (*a && *a == *b) {
- a++;
- b++;
- }
- if (!*a && !*b)
- return true;
- j++;
- }
- }
-
- return false;
-}
-
-const char *WordList::WordAt(int n) const noexcept {
- return words[n];
-}
-
diff --git a/lexlib/WordList.h b/lexlib/WordList.h
deleted file mode 100644
index 127f00e68..000000000
--- a/lexlib/WordList.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Scintilla source code edit control
-/** @file WordList.h
- ** Hold a list of words.
- **/
-// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef WORDLIST_H
-#define WORDLIST_H
-
-namespace Scintilla {
-
-/**
- */
-class WordList {
- // Each word contains at least one character - a empty word acts as sentinel at the end.
- char **words;
- char *list;
- int len;
- bool onlyLineEnds; ///< Delimited by any white space or only line ends
- int starts[256];
-public:
- explicit WordList(bool onlyLineEnds_ = false);
- ~WordList();
- operator bool() const noexcept;
- bool operator!=(const WordList &other) const noexcept;
- int Length() const noexcept;
- void Clear() noexcept;
- bool Set(const char *s);
- bool InList(const char *s) const noexcept;
- bool InListAbbreviated(const char *s, const char marker) const noexcept;
- bool InListAbridged(const char *s, const char marker) const noexcept;
- const char *WordAt(int n) const noexcept;
-};
-
-}
-
-#endif