Replace jsqlparser with antlr gramma#1298
Conversation
There was a problem hiding this comment.
In general we tend to use mixed case even for acronyms in class names, so PostgreSqlLexer.g4 not PostgreSQLLexer.g4 etc.
| public void reportAmbiguity(Parser recognizer, | ||
| DFA dfa, | ||
| int startIndex, | ||
| int stopIndex, | ||
| boolean exact, | ||
| BitSet ambigAlts, | ||
| ATNConfigSet configs) |
There was a problem hiding this comment.
Formatting, also other methods.
| public class ParserDispatchingErrorListener implements ANTLRErrorListener | ||
| { | ||
| @SuppressWarnings("checkstyle:MemberName") | ||
| Parser _parent; |
There was a problem hiding this comment.
What's going on here with the non-standard field naming?
| String msg, | ||
| RecognitionException e) | ||
| { | ||
| var foo = new ProxyErrorListener(_parent.getErrorListeners()); |
| public SQLTableCommandListener.TableInfo parseTable( | ||
| String sql) | ||
| { | ||
| CharStream input = CharStreams.fromString(sql); | ||
| lexer.reset(); | ||
| lexer.setInputStream(input); | ||
|
|
||
| tokens.setTokenSource(lexer); | ||
| parser.setTokenStream(tokens); | ||
|
|
||
| walker.walk(tableCommand, parser.root()); | ||
|
|
||
| return tableCommand.tableInfo(); | ||
| } |
| import org.antlr.v4.runtime.TokenStream; | ||
|
|
||
| @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) | ||
| public abstract class PostgreSQLParserBase extends Parser |
There was a problem hiding this comment.
| public abstract class PostgreSQLParserBase extends Parser | |
| public abstract class PostgreSqlParserBase extends Parser |
| String tableName, | ||
| Map<String, String> columns, | ||
| Set<String> primaryKeys | ||
| ) |
There was a problem hiding this comment.
This close paren should be on previous line, like methods.
| <include>org/junit/**</include> | ||
| <include>com/google/**</include> | ||
| <include>org/checkerframework/**</include> | ||
| <include>com/github/jsqlparser/**</include> |
| <artifactId>jsqlparser</artifactId> | ||
| <groupId>io.aklivity.zilla</groupId> | ||
| <artifactId>binding-pgsql</artifactId> | ||
| <scope>provided</scope> |
There was a problem hiding this comment.
This provided scope should be removed - similar to openapi dependency in openapi-asyncapi binding.
| import org.antlr.v4.runtime.CharStream; | ||
| import org.antlr.v4.runtime.Lexer; | ||
|
|
||
| public abstract class PostgreSqlLexerBase extends Lexer |
There was a problem hiding this comment.
Is this generated? If so then we shouldn't need to check it in.
Same for any other generated code.
There was a problem hiding this comment.
No it is not auto generated the gramma is written around that
https://github.com/antlr/grammars-v4/tree/master/sql/postgresql/Java
|
|
||
| public class SqlCreateStreamListener extends PostgreSqlParserBaseListener | ||
| { | ||
| private String name; |
There was a problem hiding this comment.
Move the non-final fields below the final fields, makes it easier to read the intent of the code.
| * WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| */ | ||
| package io.aklivity.zilla.runtime.binding.pgsql.parser.module; |
There was a problem hiding this comment.
Why module as the subpackage name?
There was a problem hiding this comment.
Sorry I didn't understand the question
| String name, | ||
| String select) |
There was a problem hiding this comment.
| String name, | |
| String select) | |
| String name, | |
| String select) |
|
|
||
| exports io.aklivity.zilla.runtime.binding.pgsql.parser; | ||
| exports io.aklivity.zilla.runtime.binding.pgsql.parser.listener; | ||
| exports io.aklivity.zilla.runtime.binding.pgsql.parser.module; |
There was a problem hiding this comment.
| exports io.aklivity.zilla.runtime.binding.pgsql.parser.module; | |
| exports io.aklivity.zilla.runtime.binding.pgsql.parser.model; |
Perhaps you meant model?
| .build() | ||
| .build()} | ||
| write "CREATE FUNCTION gcd(int , int)\n" | ||
| write "CREATE FUNCTION gcd(int, int)\n" |
There was a problem hiding this comment.
Was this changed because it didn't work with the space?
If so, then is the grammar perhaps too strict?
| read "CREATE FUNCTION key_value(bytea)\n" | ||
| "RETURNS struct < key varchar , value varchar >\n" | ||
| "AS key_value\n" | ||
| "RETURNS struct<key varchar, value varchar>\n" |
There was a problem hiding this comment.
Same question here about spaces? Checking if they are no longer permitted or not.
Fixes #1301