@@ -39,8 +39,16 @@ enum {
3939};
4040// KeywordIndex--Autogenerated -- end of section automatically generated
4141
42- constexpr bool IsSqlWordChar (int ch, bool sqlAllowDottedWord) noexcept {
43- return IsAlphaNumeric (ch) || ch == ' _' || (sqlAllowDottedWord && ch == ' .' );
42+ enum SqlOption {
43+ SqlOption_BackticksIdentifier = 1 ,
44+ SqlOption_NumberSignComment = 2 ,
45+ SqlOption_BackslashEscapes = 4 ,
46+ SqlOption_AllowDottedWord = 8 ,
47+ SqlOption_Default = SqlOption_BackticksIdentifier | SqlOption_NumberSignComment | SqlOption_BackslashEscapes,
48+ };
49+
50+ constexpr bool IsSqlWordChar (int ch, SqlOption option) noexcept {
51+ return IsAlphaNumeric (ch) || ch == ' _' || ((option & SqlOption_AllowDottedWord) && ch == ' .' );
4452}
4553
4654constexpr bool IsANumberChar (int ch, int chPrev) noexcept {
@@ -68,10 +76,11 @@ void ColouriseSqlDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
6876 // const WordList &kw_user3 = keywordLists[6];
6977 // const WordList &kw_user4 = keywordLists[7];
7078
71- const bool sqlBackticksIdentifier = styler.GetPropertyBool (" lexer.sql.backticks.identifier" , true );
72- const bool sqlNumbersignComment = styler.GetPropertyBool (" lexer.sql.numbersign.comment" , true );
73- const bool sqlBackslashEscapes = styler.GetPropertyBool (" lexer.sql.backslash.escapes" , true );
74- const bool sqlAllowDottedWord = styler.GetPropertyBool (" lexer.sql.allow.dotted.word" , false );
79+ // const bool sqlBackticksIdentifier = styler.GetPropertyBool("lexer.sql.backticks.identifier", true);
80+ // const bool sqlNumbersignComment = styler.GetPropertyBool("lexer.sql.numbersign.comment", true);
81+ // const bool sqlBackslashEscapes = styler.GetPropertyBool("lexer.sql.backslash.escapes", true);
82+ // const bool sqlAllowDottedWord = styler.GetPropertyBool("lexer.sql.allow.dotted.word", false);
83+ const SqlOption option = static_cast <SqlOption>(styler.GetPropertyInt (" lexer.lang" , SqlOption_Default));
7584
7685 StyleContext sc (startPos, length, initStyle, styler);
7786 // int styleBeforeDCKeyword = SCE_SQL_DEFAULT;
@@ -114,7 +123,7 @@ void ColouriseSqlDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
114123 }
115124 break ;
116125 case SCE_SQL_IDENTIFIER :
117- if (!IsSqlWordChar (sc.ch , sqlAllowDottedWord )) {
126+ if (!IsSqlWordChar (sc.ch , option )) {
118127 constexpr int nextState = SCE_SQL_DEFAULT ;
119128 char s[MaxKeywordSize];
120129 const int chNext = sc.GetDocNextChar ();
@@ -148,8 +157,8 @@ void ColouriseSqlDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
148157 }
149158 break ;
150159 case SCE_SQL_QUOTEDIDENTIFIER :
151- if (sc.ch == 0x60 ) {
152- if (sc.chNext == 0x60 ) {
160+ if (sc.ch == ' ` ' ) {
161+ if (sc.chNext == ' ` ' ) {
153162 sc.Forward (); // Ignore it
154163 } else {
155164 sc.ForwardSetState (SCE_SQL_DEFAULT );
@@ -171,7 +180,7 @@ void ColouriseSqlDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
171180 }
172181 break ;
173182 case SCE_SQL_STRING_SQ :
174- if ((sqlBackslashEscapes && sc.ch == ' \\ ' ) || (sc.ch == ' \' ' && sc.chNext == ' \' ' )) {
183+ if (((option & SqlOption_BackslashEscapes) && sc.ch == ' \\ ' ) || (sc.ch == ' \' ' && sc.chNext == ' \' ' )) {
175184 // Escape sequence
176185 sc.SetState (SCE_SQL_ESCAPECHAR );
177186 sc.Forward ();
@@ -183,7 +192,7 @@ void ColouriseSqlDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
183192 }
184193 break ;
185194 case SCE_SQL_STRING_DQ :
186- if ((sqlBackslashEscapes && sc.ch == ' \\ ' ) || (sc.ch == ' \" ' && sc.chNext == ' \" ' )) {
195+ if (((option & SqlOption_BackslashEscapes) && sc.ch == ' \\ ' ) || (sc.ch == ' \" ' && sc.chNext == ' \" ' )) {
187196 // Escape sequence
188197 sc.SetState (SCE_SQL_ESCAPECHAR );
189198 sc.Forward ();
@@ -250,7 +259,7 @@ void ColouriseSqlDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
250259 sc.SetState (SCE_SQL_VARIABLE );
251260 } else if (iswordstart (sc.ch )) {
252261 sc.SetState (SCE_SQL_IDENTIFIER );
253- } else if (sc.ch == 0x60 && sqlBackticksIdentifier ) {
262+ } else if (sc.ch == ' ` ' && (option & SqlOption_BackticksIdentifier) ) {
254263 sc.SetState (SCE_SQL_QUOTEDIDENTIFIER );
255264 } else if (sc.Match (' /' , ' *' )) {
256265 sc.SetState (SCE_SQL_COMMENT );
@@ -261,7 +270,7 @@ void ColouriseSqlDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
261270 // Perhaps we should enforce that with proper property:
262271 // ~} else if (sc.Match('-', '-', ' ')) {
263272 sc.SetState (SCE_SQL_COMMENTLINE );
264- } else if (sc.ch == ' #' && sqlNumbersignComment ) {
273+ } else if (sc.ch == ' #' && (option & SqlOption_NumberSignComment) ) {
265274 sc.SetState (SCE_SQL_COMMENTLINEDOC );
266275 } else if (sc.ch == ' \' ' ) {
267276 sc.SetState (SCE_SQL_STRING_SQ );
0 commit comments