Skip to content
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

Is it possible to generate valid Java programs using Grammarinator? #233

Open
volodya-lombrozo opened this issue Jul 31, 2024 · 1 comment

Comments

@volodya-lombrozo
Copy link

I am trying to generate valid, compilable Java programs using Grammarinator. To achieve this, I downloaded the Java 8 ANTR Grammar and executed the following command to create a new generator:

grammarinator-process Java8Lexer.g4 Java8Parser.g4 -o fuzzer/

Next, I attempted to use this generator to produce several Java programs with the command:

grammarinator-generate Java8Generator.Java8Generator -r compilationUnit -d 20 \
  -o results/app%d.java -n 100 --sys-path fuzzer/

However, the resulting programs are invalid and cannot be compiled. Below are some examples of the generated programs:

// Example 1 
@ၡൈؓ.ꬮ۰੍.@ߺ.@ℓ᪅..({})@ꩀৢ(=@,ﹲ={},={@ቾ࠙(),},=@ᮮᢩ⁠..ਸ਼({{{}},}),Ῐಂꦂি=@ଡ଼.({@ˮ᱄.,}),J={{,},})packageꮉ..;importঢ়ၭే;importใ;importstaticૹ‌.ࡅ୦ᬸꩌᢆ.ਫ਼;;%                 

// Example 2 
packageὙ;

// Example 3 
packageಐ.ⸯၱඃ;importၡ.ꪱ഻;importꩀ.*;% 

As shown, the generated code is difficult to understand, and it appears that whitespaces are ignored.
Is there a way to adjust the command or configuration to generate valid Java programs? Or is it fundamentally impossible to generate compilable Java programs using Grammarinator?

@volodya-lombrozo
Copy link
Author

@renatahodovan Could you help, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant