Closed kaby76 closed 1 week ago
The code is used in a special sub-parser. Not entirely clear why it's a sub-parser using the same PostgreSQL grammar. I will need to investigate this further. For now, I won't remove the code until I understand why it's being done this way rather than directly.
Consider the input in aggregates.sql: https://github.com/antlr/grammars-v4/blob/199a5121ece05d2f2e7eca330d0738220499e80c/sql/postgresql/examples/aggregates.sql#L778-L798
This input contains text that is a function body. However, the body syntax depends on a literal after the input text: https://github.com/antlr/grammars-v4/blob/199a5121ece05d2f2e7eca330d0738220499e80c/sql/postgresql/examples/aggregates.sql#L798
Is a sub-parser created because the parser has a difficult time synching back up once an error is detected?
The sub-parse is correct but it is implemented incorrectly. The sub-parser is for pl/pgsql, which is a distinctly different language. Unfortunately the grammar for pl/pgsql was merged into that for postgresql. I've removed the rules for pl/pgsql. The sub-parser will be implemented in a separate Antlr grammar.
The PostgreSQL grammar defines error listeners LexerDispatchingErrorListener.cs, ParserDispatchingErrorListener.cs, LexerDispatchingErrorListener.java, and ParserDispatchingErrorListener.java. But these error listeners have absolutely nothing to do with the grammar, don't reference any symbols from the grammar, and should therefore not be in the grammar.