diff options
author | nyamatongwe <devnull@localhost> | 2010-07-13 21:19:35 +1000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2010-07-13 21:19:35 +1000 |
commit | 6cf0abd5bbf6c54149546d5d19bf67a2a0f93490 (patch) | |
tree | 526d0194ec85f789bf3d71e1159d5fb83f745bf1 /src | |
parent | 65af538e0dc3702a7b29ef82243696e21b7fa03a (diff) | |
download | scintilla-mirror-6cf0abd5bbf6c54149546d5d19bf67a2a0f93490.tar.gz |
Creating lexlib with lexer support files.
Diffstat (limited to 'src')
-rw-r--r-- | src/CharacterSet.h | 59 | ||||
-rw-r--r-- | src/PropSetSimple.h | 33 | ||||
-rw-r--r-- | src/StyleContext.cxx | 55 | ||||
-rw-r--r-- | src/StyleContext.h | 177 |
4 files changed, 0 insertions, 324 deletions
diff --git a/src/CharacterSet.h b/src/CharacterSet.h deleted file mode 100644 index 9b8869635..000000000 --- a/src/CharacterSet.h +++ /dev/null @@ -1,59 +0,0 @@ -// Scintilla source code edit control -/** @file CharacterSet.h - ** Encapsulates a set of characters. Used to test if a character is within a set. - **/ -// Copyright 2007 by Neil Hodgson <neilh@scintilla.org> -// The License.txt file describes the conditions under which this software may be distributed. - -class CharacterSet { - int size; - bool valueAfter; - bool *bset; -public: - enum setBase { - setNone=0, - setLower=1, - setUpper=2, - setDigits=4, - setAlpha=setLower|setUpper, - setAlphaNum=setAlpha|setDigits - }; - CharacterSet(setBase base=setNone, const char *initialSet="", int size_=0x80, bool valueAfter_=false) { - size = size_; - valueAfter = valueAfter_; - bset = new bool[size]; - for (int i=0; i < size; i++) { - bset[i] = false; - } - AddString(initialSet); - if (base & setLower) - AddString("abcdefghijklmnopqrstuvwxyz"); - if (base & setUpper) - AddString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - if (base & setDigits) - AddString("0123456789"); - } - ~CharacterSet() { - delete []bset; - bset = 0; - size = 0; - } - void Add(int val) { - PLATFORM_ASSERT(val >= 0); - PLATFORM_ASSERT(val < size); - bset[val] = true; - } - void AddString(const char *CharacterSet) { - for (const char *cp=CharacterSet; *cp; cp++) { - int val = static_cast<unsigned char>(*cp); - PLATFORM_ASSERT(val >= 0); - PLATFORM_ASSERT(val < size); - bset[val] = true; - } - } - bool Contains(int val) const { - PLATFORM_ASSERT(val >= 0); - if (val < 0) return false; - return (val < size) ? bset[val] : valueAfter; - } -}; diff --git a/src/PropSetSimple.h b/src/PropSetSimple.h deleted file mode 100644 index 1674cfb9e..000000000 --- a/src/PropSetSimple.h +++ /dev/null @@ -1,33 +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 - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -class PropSetSimple : public PropertyGet { - void *impl; - void Set(const char *keyVal); -public: - PropSetSimple(); - virtual ~PropSetSimple(); - void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1); - void SetMultiple(const char *); - const char *Get(const char *key) const; - char *Expanded(const char *key) const; - char *ToString() const; - int GetInt(const char *key, int defaultValue=0) const; -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/src/StyleContext.cxx b/src/StyleContext.cxx deleted file mode 100644 index 4a1f71622..000000000 --- a/src/StyleContext.cxx +++ /dev/null @@ -1,55 +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 <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <stdio.h> - -#include "Platform.h" - -#include "PropSet.h" -#include "Accessor.h" -#include "StyleContext.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -static void getRange(unsigned int start, - unsigned int end, - Accessor &styler, - char *s, - unsigned int len) { - unsigned int i = 0; - while ((i < end - start + 1) && (i < len-1)) { - s[i] = styler[start + i]; - i++; - } - s[i] = '\0'; -} - -void StyleContext::GetCurrent(char *s, unsigned int len) { - getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len); -} - -static void getRangeLowered(unsigned int start, - unsigned int end, - Accessor &styler, - char *s, - unsigned int len) { - unsigned int i = 0; - while ((i < end - start + 1) && (i < len-1)) { - s[i] = static_cast<char>(tolower(styler[start + i])); - i++; - } - s[i] = '\0'; -} - -void StyleContext::GetCurrentLowered(char *s, unsigned int len) { - getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len); -} diff --git a/src/StyleContext.h b/src/StyleContext.h deleted file mode 100644 index 4e175bc29..000000000 --- a/src/StyleContext.h +++ /dev/null @@ -1,177 +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. - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -// 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 { - Accessor &styler; - unsigned int endPos; - StyleContext &operator=(const StyleContext &); - void GetNextChar(unsigned int pos) { - chNext = static_cast<unsigned char>(styler.SafeGetCharAt(pos+1)); - if (styler.IsLeadByte(static_cast<char>(chNext))) { - chNext = chNext << 8; - chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(pos+2)); - } - // End of line? - // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) - // or on LF alone (Unix). Avoid triggering two times on Dos/Win. - atLineEnd = (ch == '\r' && chNext != '\n') || - (ch == '\n') || - (currentPos >= endPos); - } - -public: - unsigned int currentPos; - bool atLineStart; - bool atLineEnd; - int state; - int chPrev; - int ch; - int chNext; - - StyleContext(unsigned int startPos, unsigned int length, - int initStyle, Accessor &styler_, char chMask=31) : - styler(styler_), - endPos(startPos + length), - currentPos(startPos), - atLineStart(true), - atLineEnd(false), - state(initStyle & chMask), // Mask off all bits which aren't in the chMask. - chPrev(0), - ch(0), - chNext(0) { - styler.StartAt(startPos, chMask); - styler.StartSegment(startPos); - unsigned int pos = currentPos; - ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos)); - if (styler.IsLeadByte(static_cast<char>(ch))) { - pos++; - ch = ch << 8; - ch |= static_cast<unsigned char>(styler.SafeGetCharAt(pos)); - } - GetNextChar(pos); - } - void Complete() { - styler.ColourTo(currentPos - 1, state); - } - bool More() const { - return currentPos < endPos; - } - void Forward() { - if (currentPos < endPos) { - atLineStart = atLineEnd; - chPrev = ch; - currentPos++; - if (ch >= 0x100) - currentPos++; - ch = chNext; - GetNextChar(currentPos + ((ch >= 0x100) ? 1 : 0)); - } else { - atLineStart = false; - chPrev = ' '; - ch = ' '; - chNext = ' '; - atLineEnd = true; - } - } - void Forward(int nb) { - for (int i = 0; i < nb; i++) { - Forward(); - } - } - void ChangeState(int state_) { - state = state_; - } - void SetState(int state_) { - styler.ColourTo(currentPos - 1, state); - state = state_; - } - void ForwardSetState(int state_) { - Forward(); - styler.ColourTo(currentPos - 1, state); - state = state_; - } - int LengthCurrent() { - return currentPos - styler.GetStartSegment(); - } - int GetRelative(int n) { - return static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+n)); - } - 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)) - return false; - s++; - } - return true; - } - bool MatchIgnoreCase(const char *s) { - if (tolower(ch) != static_cast<unsigned char>(*s)) - return false; - s++; - if (tolower(chNext) != static_cast<unsigned char>(*s)) - return false; - s++; - for (int n=2; *s; n++) { - if (static_cast<unsigned char>(*s) != - tolower(static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+n)))) - return false; - s++; - } - return true; - } - // Non-inline - void GetCurrent(char *s, unsigned int len); - void GetCurrentLowered(char *s, unsigned int len); -}; - -#ifdef SCI_NAMESPACE -} -#endif - -inline bool IsASpace(unsigned int ch) { - return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); -} - -inline bool IsASpaceOrTab(unsigned int ch) { - return (ch == ' ') || (ch == '\t'); -} - -inline bool IsADigit(unsigned int ch) { - return (ch >= '0') && (ch <= '9'); -} - -inline bool IsADigit(unsigned int ch, unsigned int base) { - if (base <= 10) { - return (ch >= '0') && (ch < '0' + base); - } else { - return ((ch >= '0') && (ch <= '9')) || - ((ch >= 'A') && (ch < 'A' + base - 10)) || - ((ch >= 'a') && (ch < 'a' + base - 10)); - } -} |