G
Guest
Hello
I am making a syntax highlighter for T-SQL, and I am going to hardcode the
words into it for speed's sake (I will probably have thought up enough new
features for a new version when the next version of SQL comes out).
My main algorithm is going to go through all the words in the RICHEDIT
control, and pass each valid word it finds to a word-checking function, which
I want to operate as fast as possible as it will be called frequently. For
these purposes, I was going to try and have a b-tree based algorithm. My
thinking is that if, say, the words it has to find are (hypothetically) get,
set, and select, then it could be of the form
int getwordtype(word)
{
if((word[0] == 'g') && (word[1] == 'e') && (word[2] == 't'))
return WORDTYPE_GET;
if((word[0] == 's') && (word[1] == 'e'))
{
if((word[2] == 't')) return WORDTYPE_SET;
if((word[3] == 'l') && (word[4] == 'e') && (word[5] == 'c') &&
(word[6] == 't')) return WORDTYPE_SELECT;
}
return WORDTYPE_NONE;
}
would this the fastest method? I do want to implement a b-tree.
Obviously I am not going to type out the whole algorithm with all the words
in SQL, I am going to write a program in C# to generate the .cpp file which
will hold it.
Any tips?
Thanks!
I am making a syntax highlighter for T-SQL, and I am going to hardcode the
words into it for speed's sake (I will probably have thought up enough new
features for a new version when the next version of SQL comes out).
My main algorithm is going to go through all the words in the RICHEDIT
control, and pass each valid word it finds to a word-checking function, which
I want to operate as fast as possible as it will be called frequently. For
these purposes, I was going to try and have a b-tree based algorithm. My
thinking is that if, say, the words it has to find are (hypothetically) get,
set, and select, then it could be of the form
int getwordtype(word)
{
if((word[0] == 'g') && (word[1] == 'e') && (word[2] == 't'))
return WORDTYPE_GET;
if((word[0] == 's') && (word[1] == 'e'))
{
if((word[2] == 't')) return WORDTYPE_SET;
if((word[3] == 'l') && (word[4] == 'e') && (word[5] == 'c') &&
(word[6] == 't')) return WORDTYPE_SELECT;
}
return WORDTYPE_NONE;
}
would this the fastest method? I do want to implement a b-tree.
Obviously I am not going to type out the whole algorithm with all the words
in SQL, I am going to write a program in C# to generate the .cpp file which
will hold it.
Any tips?
Thanks!