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

negation operator is needed to make json schema working correctly #57

Open
Saibo-creator opened this issue Jun 9, 2024 · 1 comment

Comments

@Saibo-creator
Copy link
Collaborator

Saibo-creator commented Jun 9, 2024

It seems currently the json schema constrain is not working correctly yet

by loading the example student grammar

 # Load grammar
 with open("examples/grammars/custom_json_grammars/grammars/student.ebnf", "r") as file:
      grammar_str = file.read()

And run a simple generation we get :

{ "name": "\\"\\"", "age": 20, "courses": [ "\\"\\"", "\\"\\"", "\\"\\"", "\\"\\"", "\\"\\"", "\\"\\"", "\\"\\"", "\\"\\"", "\\"\\"", "\\"\\"",']

The origin of the problem is that the grammar converted from the json schema, i.e. examples/grammars/custom_json_grammars/grammars/student.ebnf contains a usage of negation operator ^ at line 4, i.e. char ::= [^"\\]

Since we haven't yet added the support for negation operator , this simply doesn't work and only allows to generate escaped backslashes. #21

A quick fix is to replace it with char ::= [A-z]

And we get

{ "name": "John", "age": 20, "courses": [ "Math", "English" ] }
@Saibo-creator Saibo-creator added bug Something isn't working and removed bug Something isn't working labels Jun 9, 2024
@Saibo-creator
Copy link
Collaborator Author

Saibo-creator commented Sep 19, 2024

As a follow up work of #21 , we should now be able to support json schema. Negation was the only missing operator. See here for more details of how to use json schema

@nathanrchn

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

2 participants