From 83f5a42086d9db3941d12b75477f13f7f9e35655 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 21 Oct 2005 00:06:57 +0000 Subject: Patch from Iago implements new quoted identifier lexical class for SQL. --- src/LexSQL.cxx | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/LexSQL.cxx b/src/LexSQL.cxx index 6f2a703fb..b1b2c1624 100644 --- a/src/LexSQL.cxx +++ b/src/LexSQL.cxx @@ -109,7 +109,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, bool fold = styler.GetPropertyInt("fold") != 0; bool sqlBackslashEscapes = styler.GetPropertyInt("sql.backslash.escapes", 0) != 0; - bool sqlBackticksString = styler.GetPropertyInt("sql.backticks.string", 0) != 0; + bool sqlBackticksIdentifier = styler.GetPropertyInt("sql.backticks.identifier", 0) != 0; int lineCurrent = styler.GetLine(startPos); int spaceFlags = 0; @@ -170,9 +170,12 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, } else if (ch == '\'') { styler.ColourTo(i - 1, state); state = SCE_SQL_CHARACTER; - } else if (ch == '"' || (sqlBackticksString && ch == 0x60)) { + } else if (ch == '"') { styler.ColourTo(i - 1, state); state = SCE_SQL_STRING; + } else if (ch == 0x60 && sqlBackticksIdentifier) { + styler.ColourTo(i - 1, state); + state = SCE_SQL_QUOTEDIDENTIFIER; } else if (isoperator(ch)) { styler.ColourTo(i - 1, state); styler.ColourTo(i, SCE_SQL_OPERATOR); @@ -193,8 +196,10 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, state = SCE_SQL_COMMENTLINEDOC; } else if (ch == '\'') { state = SCE_SQL_CHARACTER; - } else if (ch == '"' || (sqlBackticksString && ch == 0x60)) { + } else if (ch == '"') { state = SCE_SQL_STRING; + } else if (ch == 0x60 && sqlBackticksIdentifier) { + state = SCE_SQL_QUOTEDIDENTIFIER; } else if (isoperator(ch)) { styler.ColourTo(i, SCE_SQL_OPERATOR); } @@ -262,7 +267,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, chNext = styler.SafeGetCharAt(i + 1); } } else if (state == SCE_SQL_STRING) { - if (ch == '"' || (sqlBackticksString && ch == 0x60)) { + if (ch == '"') { if (chNext == '"') { i++; } else { @@ -273,6 +278,18 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, ch = chNext; chNext = styler.SafeGetCharAt(i + 1); } + } else if (state == SCE_SQL_QUOTEDIDENTIFIER) { + if (ch == 0x60) { + if (chNext == 0x60) { + i++; + } else { + styler.ColourTo(i, state); + state = SCE_SQL_DEFAULT; + i++; + } + ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + } } if (state == SCE_SQL_DEFAULT) { // One of the above succeeded if (ch == '/' && chNext == '*') { @@ -291,8 +308,10 @@ static void ColouriseSQLDoc(unsigned int startPos, int length, state = SCE_SQL_SQLPLUS_PROMPT; } else if (ch == '\'') { state = SCE_SQL_CHARACTER; - } else if (ch == '"' || (sqlBackticksString && ch == 0x60)) { + } else if (ch == '"') { state = SCE_SQL_STRING; + } else if (ch == 0x60 && sqlBackticksIdentifier) { + state = SCE_SQL_QUOTEDIDENTIFIER; } else if (iswordstart(ch)) { state = SCE_SQL_WORD; } else if (isoperator(ch)) { -- cgit v1.2.3