File: regex_to_grammar.py

package info (click to toggle)
llama.cpp 5882%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 34,040 kB
  • sloc: cpp: 189,548; ansic: 115,889; python: 24,977; objc: 6,050; sh: 5,819; lisp: 5,741; makefile: 1,293; javascript: 807; xml: 259
file content (20 lines) | stat: -rw-r--r-- 431 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)))