I'm in the process of integrating my existing lexer to a programmatic lexer without change much in my existing lexer. The strategy is to create a shell lexer component that 'knows' about the actipro lexer interfaces and then call my existing lexer. Because it's used elsewhere in the code I don't want to make the existing lexer have any knowledge of the actipro interfaces.
So the shell gets control (and I position to start of line) and call OnPreParse with new offset. I then create a reader with that offset. Now here is the tricky part and the question. My existing lexer takes a string (once at initialization) and then I call GetNextoken on it and it returns my tokenid int. So the idea is to get the string from the reader using reader.GetSubString(offset, reader.Lengh - offset) and pass that string to my lexer. I then proceed to call in a loop my GetNextToken in my own lexer and with each return I will call OnTokenParsed. The question is will this work or will the actipro lexer interface be confused about where that token came from in the line (since I took in an entire substring? If so what is the best solution to keep it synchronized? or in general when doing this?
Thanks,
Bernie
So the shell gets control (and I position to start of line) and call OnPreParse with new offset. I then create a reader with that offset. Now here is the tricky part and the question. My existing lexer takes a string (once at initialization) and then I call GetNextoken on it and it returns my tokenid int. So the idea is to get the string from the reader using reader.GetSubString(offset, reader.Lengh - offset) and pass that string to my lexer. I then proceed to call in a loop my GetNextToken in my own lexer and with each return I will call OnTokenParsed. The question is will this work or will the actipro lexer interface be confused about where that token came from in the line (since I took in an entire substring? If so what is the best solution to keep it synchronized? or in general when doing this?
Thanks,
Bernie