regex_to_grammar.py 431 B

1234567891011121314151617181920
  1. import json, subprocess, sys, os
  2. assert len(sys.argv) >= 2
  3. [_, pattern, *rest] = sys.argv
  4. print(subprocess.check_output(
  5. [
  6. "python",
  7. os.path.join(
  8. os.path.dirname(os.path.realpath(__file__)),
  9. "json_schema_to_grammar.py"),
  10. *rest,
  11. "-",
  12. "--raw-pattern",
  13. ],
  14. text=True,
  15. input=json.dumps({
  16. "type": "string",
  17. "pattern": pattern,
  18. }, indent=2)))