Actually, I thought the way to handle it would be to duplicate the backend lexer as nearly as possible. Most of the productions would have empty bodies probably, but doing it that way would guarantee that in fact psql and the backend would lex a string the same way, which is exactly the problem we are facing here. You'd fall out of the lexer only upon detecting backslash (unless we want to put backslash command lexing into the flex code, which might or might not be a good idea), or upon detecting a ';' at parenthesis depth 0, or upon hitting end of string. In the last case the lexer state would indicate which prompt we need to give.
You know what would be really sweet? If the lexing was made available as a public function. eg. So I could parse queries in phpPgAdmin before sending them to the backend, etc...
Chris
---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]