Posted 18 years ago
by Karl Grambow

Hi,
I was wondering if you could advise me as to whether I can get some better performance out of SyntaxEditor 4.0 with respect to something I'm trying to do.
Essentially, I'm parsing a document and looking for "GO" keywords on new lines. Initially I did this using regular expressions and that worked really well, and fast. This is what my regular expression looked likeThe problem is that I now need to find "GO" keywords that are of a particular token. Specifically, I want to ignore any occurrence of the "GO" word if it occurs inside comments or quoted strings. So, what I've done is, put the Script string into a SyntaxDocument and basically just look for a specific token called "GOToken", which is defined in the language.xml file that I loaded into the SyntaxDocument.
This works great and does exactly what I want it to do. But it's about 40 times slower than using the regular expression (400 milliseconds as opposed to 10 milliseconds)
What I'd like to know is if if there's a better way (performance-wise) that I can achieve what I'm trying to do using SyntaxEditor.
Thanks,
Karl
I was wondering if you could advise me as to whether I can get some better performance out of SyntaxEditor 4.0 with respect to something I'm trying to do.
Essentially, I'm parsing a document and looking for "GO" keywords on new lines. Initially I did this using regular expressions and that worked really well, and fast. This is what my regular expression looked like
'look for any newline beginning with "GO" (allowing for white space beforehand and white space after
Dim GOKeyWord As Regex = New Regex("(?<=\r\n\s*)(?=\b)(GO)(?<=\b\s*)", RegexOptions.IgnoreCase)
Dim m As Match = GOKeyWord.Match(Script)
While m.Success
'some code
End While
'SyntaxDocument.Text = ObjectScript
Dim oStream As TokenStream = SyntaxDocument.GetTokenStream(SyntaxDocument.Tokens.IndexOf(0))
Dim oToken As IToken
'let's get the next GOToken
oToken = GetNextToken("GOToken", oStream) 'this method reads through the stream until it finds the supplied token
While Not oToken Is Nothing
'some code
End While
What I'd like to know is if if there's a better way (performance-wise) that I can achieve what I'm trying to do using SyntaxEditor.
Thanks,
Karl