-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid files generated for the working example #215
Comments
Hi @Beliefuture ! Thanks for your interest in Grammarinator! Empty output are generated by HTMLGenerator if all the quantified components of the starting htmlDocument rule decides to stop generation at the first iteration. Since there is 0.5 chance for stopping and continuing the loop at every iteration and since there is 6 quantified components in As per the invalid output... these output might look as invalid HTMLs (and some of them are indeed), however they fulfill all the requirements defined by the grammar. The grammar doesn't have any information about tag or attribute names or attribute values. It doesn't know anything about spaces between the tokens. It doesn't know the semantics of style, script or xml tags. Etc. This is simply because these grammars are parser grammars. They are responsible to check only the syntax of an input and all the further checks are usually implemented manually. Similarly, if these grammars are used to generate output, then the additional information needed to be defined manually. Either by editing the grammar itself with rule rewrites, custom predicates or actions (probably with loosing the possibility of using the grammar for parsing) or by implementing custom generator subclasses and/or models/listeners/serializers etc. HTMLCustomGenerator is a basic example for such a custom generator. Regarding the PostgreSQL issue, are you sure you commented out the superClass options both in the lexer and parser grammars and regenerated the generator? Another option to control the superclass of the produced generator is rewriting the superClass option from CLI like this: grammarinator-process -DsuperClass=Generator ... Getting only empty output from PostgreSQL is weird. Although stmtmulti is completely quantified, it should only result at most 50% empty result. Could you paste the command you used resulting in only empty output? |
Hi @renatahodovan ! Thanks for your detailed explanation and sorry for the late response.
Please leave messages if you have any questions :) |
Besides, I have found that the generated SQLs for PostgreSQL are typically incomplete and not executable that fail to obey the grammar rule strictly?
|
Maybe the incomplete queries generated can be attributed to the truncation due to the parameter |
Hi!
Thanks for your efforts on this project!
I have tried the working example with the latest version of this project.
The commands are listed below:
The first line in the generated file of the
Generator
contains the information about the version.However, I have found the generated files of the testing cases don't work properly as expected.
Specifically, these files are either blank without any content or filled with wrong codes (i.e., invalid with incorrect grammar according to the original
antlr
grammar file).Case 1:
Case 2:
Case 3:
The issues persist when I directly utilize the
HTMLCustomGenerator.py
in the repository, i.e.,Another problem is that when I utilize the grammar file to generate queries for PostgreSQL,
(i.e., https://github.com/antlr/grammars-v4/blob/master/sql/postgresql/PostgreSQLLexer.g4 and
https://github.com/antlr/grammars-v4/blob/master/sql/postgresql/PostgreSQLParser.g4)
the generated file
PostgreSQLGenerator
subclass thePostgreSQLLexerBase
class even when I comment the option in the grammar files. Could I ask where I can fix this issue, e.g., find thePostgreSQLLexerBase
file.I change the class
PostgreSQLLexerBase
toGenerator
and the generated files are all blank.The text was updated successfully, but these errors were encountered: