From add8fee04ad856c16517886e1c788e699097cabf Mon Sep 17 00:00:00 2001 From: ochafik Date: Sun, 10 Mar 2024 13:23:00 +0000 Subject: [PATCH] Create regex-to-grammar.py --- examples/regex-to-grammar.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/regex-to-grammar.py diff --git a/examples/regex-to-grammar.py b/examples/regex-to-grammar.py new file mode 100644 index 000000000..cec4fe01e --- /dev/null +++ b/examples/regex-to-grammar.py @@ -0,0 +1,18 @@ +import json, subprocess, sys, os + +assert len(sys.argv) == 2 +[_, pattern] = sys.argv + +print(subprocess.check_output( + [ + "python", + os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "json-schema-to-grammar.py"), + "-", + ], + text=True, + input=json.dumps({ + "type": "string", + "pattern": pattern, + }, indent=2))) \ No newline at end of file