-
Notifications
You must be signed in to change notification settings - Fork 56
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
No generator, no whitespace? Please help #33
Comments
Hey @docfate111 ! The way you generate the generator is correct. With the command above the generated fuzzer, aka. generator will be placed in the out folder of your current working directory. The way you use the grammarinator-generate utility is outdated: instead of referencing the generator file, you must use fully qualified names. In this case the command should look like:
The Your next problem will be that the original grammar specifies a superclass for both the lexer and the parser. These superclasses give additional information to the parser, which are useless for the fuzzer, ofc. Hence, I suggest to comment out these lines for now. If you still need some superclasses for your generated fuzzer, then you should write them for yourself. To add spaces to your output you need to write a serializer. Serializers and transformers are similar things, they both work on grammar trees, but while serializers produce string outputs, transformers produce tree outputs. So, to add spaces to your output you need a serializer. A basic serializer, that inserts spaces after every UnparserRule (i.e., inner node of the grammar tree) is implemented here. To use it you should extend the previous generator command as shown below (serializers are also referred with fully qualified names just like the generator):
|
@docfate111 I hope serializers (plus the additional details in @renatahodovan 's reply) did solve your problem. Closing this issue now as 5 months have passed since the Q and the A. However, if the problem still stands, feel free to re-open this issue (or open a new one). |
How do I generate a ? None of the tests have whitespace and the input often gives invalid characters.
I got the g4 for https://github.com/antlr/grammars-v4/blob/master/javascript/javascript/
MacOS Python3.9
What is a generator do I need to write a generator program?
How do I write a transformer or change the grammar to add spaces? (Looking at the closed issue this is the solution but I have no idea what a transformer is).
The text was updated successfully, but these errors were encountered: