Antrlv4 hangs while parsing PostgreSQLParser.g4

82 views
Skip to first unread message

Mercurial

unread,
Jul 5, 2024, 12:22:24 AM7/5/24
to antlr-discussion
Hi,

I believe that in that grammar "root" is the start rule.

so I run this command on the command line


antlr4-parse PostgreSQLParser.g4 root

and then I get around 600 lines of warnings like

warning(125): PostgreSQLParser.g4:51:12: implicit definition of token SEMI in parser
warning(125): PostgreSQLParser.g4:183:6: implicit definition of token MetaCommand in parser
warning(125): PostgreSQLParser.g4:183:18: implicit definition of token EndMetaCommand in parser
warning(125): PostgreSQLParser.g4:187:6: implicit definition of token CALL in parser
warning(125): PostgreSQLParser.g4:191:6: implicit definition of token CREATE in parser

and then I enter a sample sql statement like
select id from person where age > 10;
and press enter.
but that doesn't do anything
I can just a a cursor blinking.
and then when I do ctrl-c a couple of times

I get this message.
Exception in thread "main" java.lang.IllegalStateException: A lexer interpreter can only be created for a lexer or combined grammar.

Am I doing something wrong here?

Michael Rachow

unread,
Jul 17, 2024, 8:28:15 AM7/17/24
to antlr-discussion
Hi Mercurial,

You have to provide both parts of the PostgreSQL grammar,
e.g. lexer and parser grammar.

antlr4-parse PostgreSQLLexer.g4 PostgreSQLParser.g4 ...

All the implicit warnings are a result of the missing definition from the lexer part of this splitted grammar.

Regards,
Michael
Reply all
Reply to author
Forward
0 new messages