diff options
Diffstat (limited to 'examples/regex_to_grammar.py')
-rw-r--r-- | examples/regex_to_grammar.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/regex_to_grammar.py b/examples/regex_to_grammar.py new file mode 100644 index 00000000..5cd9210a --- /dev/null +++ b/examples/regex_to_grammar.py @@ -0,0 +1,20 @@ +import json, subprocess, sys, os + +assert len(sys.argv) >= 2 +[_, pattern, *rest] = sys.argv + +print(subprocess.check_output( + [ + "python", + os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "json_schema_to_grammar.py"), + *rest, + "-", + "--raw-pattern", + ], + text=True, + input=json.dumps({ + "type": "string", + "pattern": pattern, + }, indent=2))) |