Upload folder using huggingface_hub (part 6)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/is_word_char.py +7 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/is_word_char_test.py +22 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/parse_char.py +53 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/parse_char_test.py +42 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/parse_name.py +36 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/parse_name_test.py +52 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/parse_space.py +10 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/parse_space_test.py +56 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/rules_builder.py +217 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/rules_builder_test.py +1478 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/symbol_ids.py +44 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/type_guards.py +55 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/types.py +68 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/whitespace.py +7 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/__init__.py +0 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/__init__.py +0 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/build_error_position.py +23 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/build_error_position_test.py +110 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/get_input_as_string.py +13 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/get_input_as_string_test.py +19 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/grammar_parse_error.py +20 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/grammar_parse_error_test.py +22 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/input_parse_error.py +47 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/input_parse_error_test.py +43 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/is_point_in_range.py +3 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/is_point_in_range_test.py +18 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/json_stringify.py +26 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/integration_tests/generated/iteration/grammars_test.py +0 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/integration_tests/generated/iteration/iteration_test.py +63 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/integration_tests/generated/iteration/iteration_with_additional_strings_test.py +289 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/integration_tests/generated/iteration/iteration_with_an_initial_string_test.py +285 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/integration_tests/generated/validation/validate_grammar_test.py +49 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/integration_tests/generated/validation/validate_input_test.py +123 -0
- v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/pyproject.toml +38 -0
- v2-models-effort/runs/20261111-214430-spring-scene/proxy.log +15 -0
- v2-models-effort/runs/20261111-214430-spring-scene/result.json +1 -0
- v2-models-effort/runs/20261111-214430-spring-scene/run.json +28 -0
- v2-models-effort/runs/20261111-214430-spring-scene/run.lock +0 -0
- v2-models-effort/runs/20261111-214430-spring-scene/stderr.log +0 -0
- v2-models-effort/runs/20261111-214430-spring-scene/stderr.txt +2 -0
- v2-models-effort/runs/20261111-214430-spring-scene/stdout.log +1 -0
- v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/adbc157d-c956-4966-b96a-a12bba8a4285.jsonl +0 -0
- v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/adbc157d-c956-4966-b96a-a12bba8a4285/subagents/agent-a2c07bb5517d717f5.jsonl +0 -0
- v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/adbc157d-c956-4966-b96a-a12bba8a4285/subagents/agent-a2c07bb5517d717f5.meta.json +1 -0
- v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/memory/MEMORY.md +3 -0
- v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/memory/gbnf-python-port.md +29 -0
- v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/memory/unicode-escapes-in-tool-parameters.md +20 -0
- v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/memory/write-in-small-pieces.md +19 -0
- v2-models-effort/runs/20261111-214430-steep-field/credentials.log +133 -0
- v2-models-effort/runs/20261111-214430-steep-field/git-diff.patch +0 -0
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/is_word_char.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
+
_WORD_CHAR = re.compile(r"[a-zA-Z]")
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def is_word_char(c: str) -> bool:
|
| 7 |
+
return _WORD_CHAR.search(c) is not None
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/is_word_char_test.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from gbnf.rules_builder.is_word_char import is_word_char
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def describe_is_word_char_function():
|
| 5 |
+
def it_should_return_true_for_lowercase_letters():
|
| 6 |
+
assert is_word_char("a") is True
|
| 7 |
+
assert is_word_char("z") is True
|
| 8 |
+
|
| 9 |
+
def it_should_return_true_for_uppercase_letters():
|
| 10 |
+
assert is_word_char("A") is True
|
| 11 |
+
assert is_word_char("Z") is True
|
| 12 |
+
|
| 13 |
+
def it_should_return_false_for_digits():
|
| 14 |
+
assert is_word_char("0") is False
|
| 15 |
+
assert is_word_char("9") is False
|
| 16 |
+
|
| 17 |
+
def it_should_return_false_for_non_word_characters():
|
| 18 |
+
assert is_word_char("-") is False
|
| 19 |
+
assert is_word_char("@") is False
|
| 20 |
+
assert is_word_char("_") is False
|
| 21 |
+
assert is_word_char("?") is False
|
| 22 |
+
assert is_word_char(" ") is False
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/parse_char.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
import re
|
| 3 |
+
|
| 4 |
+
from ..utils.errors.grammar_parse_error import GrammarParseError
|
| 5 |
+
from .whitespace import WHITESPACE
|
| 6 |
+
|
| 7 |
+
_HEX_DIGITS = re.compile(r"[0-9a-fA-F]+")
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _parse_hex(digits: str) -> int | float:
|
| 11 |
+
# Escapes are read as leniently as the reference implementation reads them
|
| 12 |
+
# (with parseInt), so that both accept exactly the same grammars: an optional
|
| 13 |
+
# sign and 0x prefix are allowed, reading stops at the first character that
|
| 14 |
+
# is not a hex digit, and no digits at all gives NaN, which matches nothing.
|
| 15 |
+
digits = digits.lstrip(WHITESPACE)
|
| 16 |
+
sign = 1
|
| 17 |
+
if digits[:1] in ("+", "-"):
|
| 18 |
+
sign = -1 if digits[0] == "-" else 1
|
| 19 |
+
digits = digits[1:]
|
| 20 |
+
if digits[:2] in ("0x", "0X"):
|
| 21 |
+
digits = digits[2:]
|
| 22 |
+
match = _HEX_DIGITS.match(digits)
|
| 23 |
+
if match is None:
|
| 24 |
+
return math.nan
|
| 25 |
+
return sign * int(match.group(), 16)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def parse_char(src: str, pos: int) -> tuple[int | float, int]:
|
| 29 |
+
char = src[pos : pos + 1]
|
| 30 |
+
if char == "\\":
|
| 31 |
+
match src[pos + 1 : pos + 2]:
|
| 32 |
+
case "x":
|
| 33 |
+
return _parse_hex(src[pos + 2 : pos + 4]), 4
|
| 34 |
+
case "u":
|
| 35 |
+
return _parse_hex(src[pos + 2 : pos + 6]), 6
|
| 36 |
+
case "U":
|
| 37 |
+
return _parse_hex(src[pos + 2 : pos + 10]), 10
|
| 38 |
+
case "t":
|
| 39 |
+
return ord("\t"), 2
|
| 40 |
+
case "r":
|
| 41 |
+
return ord("\r"), 2
|
| 42 |
+
case "n":
|
| 43 |
+
return ord("\n"), 2
|
| 44 |
+
case '"' | "[" | "]" | "\\" as escaped:
|
| 45 |
+
return ord(escaped), 2
|
| 46 |
+
case _:
|
| 47 |
+
raise GrammarParseError(src, pos, f"Unknown escape at {char}")
|
| 48 |
+
|
| 49 |
+
if not char:
|
| 50 |
+
raise GrammarParseError(
|
| 51 |
+
src, pos, "Unexpected end of grammar input, failed to complete parse"
|
| 52 |
+
)
|
| 53 |
+
return ord(char), 1
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/parse_char_test.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from gbnf.rules_builder.parse_char import parse_char
|
| 4 |
+
from gbnf.utils.errors.grammar_parse_error import GrammarParseError
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def describe_parse_char():
|
| 8 |
+
@pytest.mark.parametrize(
|
| 9 |
+
("_key", "char", "code_point"),
|
| 10 |
+
[
|
| 11 |
+
("escaped 8-bit unicode char", "a", ord("a")),
|
| 12 |
+
("escaped 8-bit unicode char", "9", ord("9")),
|
| 13 |
+
],
|
| 14 |
+
)
|
| 15 |
+
def it_parses_char(_key, char, code_point):
|
| 16 |
+
grammar = f'root ::= "{char}" "foo"'
|
| 17 |
+
assert parse_char(grammar, len('root ::= "')) == (code_point, 1)
|
| 18 |
+
|
| 19 |
+
@pytest.mark.parametrize(
|
| 20 |
+
("_key", "escaped_char", "code_point", "inc_pos"),
|
| 21 |
+
[
|
| 22 |
+
("escaped 8-bit unicode char", "\\x2A", ord("\x2a"), 4),
|
| 23 |
+
("escaped 16-bit unicode char", "\\u006F", ord("\u006f"), 6),
|
| 24 |
+
("escaped 32-bit unicode char", "\\U0001F4A9", 128169, 10),
|
| 25 |
+
("escaped tab char", "\\t", ord("\t"), 2),
|
| 26 |
+
("escaped new line char", "\\n", ord("\n"), 2),
|
| 27 |
+
("escaped \r char", "\\r", ord("\r"), 2),
|
| 28 |
+
("escaped quote char", '\\"', ord('"'), 2),
|
| 29 |
+
("escaped [ char", "\\[", ord("["), 2),
|
| 30 |
+
("escaped ] char", "\\]", ord("]"), 2),
|
| 31 |
+
("escaped \\ char", "\\\\", ord("\\"), 2),
|
| 32 |
+
],
|
| 33 |
+
)
|
| 34 |
+
def it_parses_escaped_char(_key, escaped_char, code_point, inc_pos):
|
| 35 |
+
grammar = f'root ::= "{escaped_char}" "foo"'
|
| 36 |
+
assert parse_char(grammar, len('root ::= "')) == (code_point, inc_pos)
|
| 37 |
+
|
| 38 |
+
def it_throws_on_invalid_input():
|
| 39 |
+
with pytest.raises(GrammarParseError):
|
| 40 |
+
parse_char("", 0)
|
| 41 |
+
with pytest.raises(GrammarParseError):
|
| 42 |
+
parse_char("a", 1)
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/parse_name.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
+
from ..utils.errors.grammar_parse_error import GrammarParseError
|
| 4 |
+
|
| 5 |
+
PARSE_NAME_ERROR = "Failed to find a valid name"
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def get_invalid_char_error(char: str) -> str:
|
| 9 |
+
return (
|
| 10 |
+
f'Invalid character "{char}" when parsing name, '
|
| 11 |
+
"only lowercase letters and hyphens are allowed."
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
_VALID_CHAR = re.compile(r"[a-zA-Z-]")
|
| 16 |
+
_INVALID_NEXT_CHAR = re.compile(r"[_0-9]")
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def _is_valid_char(char: str) -> bool:
|
| 20 |
+
return _VALID_CHAR.search(char) is not None
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def _is_invalid_next_char(char: str) -> bool:
|
| 24 |
+
return _INVALID_NEXT_CHAR.search(char) is not None
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def parse_name(grammar: str, pos: int) -> str:
|
| 28 |
+
name = ""
|
| 29 |
+
while pos < len(grammar) and _is_valid_char(grammar[pos]):
|
| 30 |
+
name += grammar[pos]
|
| 31 |
+
pos += 1
|
| 32 |
+
if not name:
|
| 33 |
+
raise GrammarParseError(grammar, pos, PARSE_NAME_ERROR)
|
| 34 |
+
if pos < len(grammar) and _is_invalid_next_char(grammar[pos]):
|
| 35 |
+
raise GrammarParseError(grammar, pos, get_invalid_char_error(grammar[pos]))
|
| 36 |
+
return name
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/parse_name_test.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from gbnf.rules_builder.parse_name import PARSE_NAME_ERROR, get_invalid_char_error, parse_name
|
| 4 |
+
from gbnf.utils.errors.grammar_parse_error import GrammarParseError
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def describe_parse_name():
|
| 8 |
+
@pytest.mark.parametrize(
|
| 9 |
+
"src",
|
| 10 |
+
[
|
| 11 |
+
"v",
|
| 12 |
+
"valid",
|
| 13 |
+
"valid-name",
|
| 14 |
+
"valid-name-foo",
|
| 15 |
+
"validName",
|
| 16 |
+
"validName-foo",
|
| 17 |
+
],
|
| 18 |
+
)
|
| 19 |
+
def it_should_return_correct_position_when_encountering_a_valid_name(src):
|
| 20 |
+
name = parse_name(src, 0)
|
| 21 |
+
assert name == src
|
| 22 |
+
|
| 23 |
+
@pytest.mark.parametrize(
|
| 24 |
+
("src", "position", "expectation"),
|
| 25 |
+
[
|
| 26 |
+
("123valid", 3, "valid"),
|
| 27 |
+
("123valid-name", 3, "valid-name"),
|
| 28 |
+
("123valid _Name", 3, "valid"),
|
| 29 |
+
("123valid\\n_Name", 3, "valid"),
|
| 30 |
+
("123valid\\t_Name", 3, "valid"),
|
| 31 |
+
("123valid\\r_Name", 3, "valid"),
|
| 32 |
+
],
|
| 33 |
+
)
|
| 34 |
+
def it_should_return_correct_position_when_encountering_a_valid_name_at_a_non_zero_position(
|
| 35 |
+
src, position, expectation
|
| 36 |
+
):
|
| 37 |
+
name = parse_name(src.replace("\\n", "\n"), position)
|
| 38 |
+
assert name == expectation
|
| 39 |
+
|
| 40 |
+
@pytest.mark.parametrize(
|
| 41 |
+
("src", "error"),
|
| 42 |
+
[
|
| 43 |
+
("123", GrammarParseError("123", 0, PARSE_NAME_ERROR)),
|
| 44 |
+
("valid_name", GrammarParseError("valid_name", 5, get_invalid_char_error("_"))),
|
| 45 |
+
("valid123", GrammarParseError("valid123", 5, get_invalid_char_error("1"))),
|
| 46 |
+
# ("validName", GrammarParseError("validName", 5, get_invalid_char_error("N"))),
|
| 47 |
+
],
|
| 48 |
+
)
|
| 49 |
+
def it_should_throw_an_error_when_encountering_an_invalid_name(src, error):
|
| 50 |
+
with pytest.raises(GrammarParseError) as raised:
|
| 51 |
+
parse_name(src, 0)
|
| 52 |
+
assert str(raised.value) == str(error)
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/parse_space.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def parse_space(src: str, pos: int, newline_ok: bool) -> int:
|
| 2 |
+
while pos < len(src) and (
|
| 3 |
+
src[pos] in " \t#" or (newline_ok and src[pos] in "\r\n")
|
| 4 |
+
):
|
| 5 |
+
if src[pos] == "#":
|
| 6 |
+
while pos < len(src) and src[pos] not in "\r\n":
|
| 7 |
+
pos += 1
|
| 8 |
+
else:
|
| 9 |
+
pos += 1
|
| 10 |
+
return pos
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/parse_space_test.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from gbnf.rules_builder.parse_space import parse_space
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def describe_parse_space_function():
|
| 5 |
+
def it_should_return_the_input_string_when_no_whitespace_or_comments_are_present():
|
| 6 |
+
input = "abcdefghijk"
|
| 7 |
+
pos = parse_space(input, 0, True)
|
| 8 |
+
assert input[pos:] == input
|
| 9 |
+
|
| 10 |
+
def it_should_skip_leading_spaces_and_tabs():
|
| 11 |
+
input = " \t abcdefghijk"
|
| 12 |
+
expected = "abcdefghijk"
|
| 13 |
+
pos = parse_space(input, 0, True)
|
| 14 |
+
assert input[pos:] == expected
|
| 15 |
+
|
| 16 |
+
def it_should_skip_leading_newline_characters_when_newline_ok_is_true():
|
| 17 |
+
input = "\n\n\r\n\r\nabcdefghijk"
|
| 18 |
+
expected = "abcdefghijk"
|
| 19 |
+
pos = parse_space(input, 0, True)
|
| 20 |
+
assert input[pos:] == expected
|
| 21 |
+
|
| 22 |
+
def it_should_not_skip_leading_newline_characters_when_newline_ok_is_false():
|
| 23 |
+
input = "\n\n\r\n\r\nabcdefghijk"
|
| 24 |
+
expected = "\n\n\r\n\r\nabcdefghijk"
|
| 25 |
+
pos = parse_space(input, 0, False)
|
| 26 |
+
assert input[pos:] == expected
|
| 27 |
+
|
| 28 |
+
def it_should_skip_comments_and_leading_spaces():
|
| 29 |
+
input = " # This is a comment\n\t abcdefghijk"
|
| 30 |
+
expected = "abcdefghijk"
|
| 31 |
+
pos = parse_space(input, 0, True)
|
| 32 |
+
assert input[pos:] == expected
|
| 33 |
+
|
| 34 |
+
def it_should_skip_comments_and_leading_newline_characters_when_newline_ok_is_true():
|
| 35 |
+
input = "\n\n # This is a comment\n\r\n\r\nabcdefghijk"
|
| 36 |
+
expected = "abcdefghijk"
|
| 37 |
+
pos = parse_space(input, 0, True)
|
| 38 |
+
assert input[pos:] == expected
|
| 39 |
+
|
| 40 |
+
def it_should_skip_comments_and_leading_newline_characters_when_newline_ok_is_false():
|
| 41 |
+
input = "\n\n # This is a comment\n\r\n\r\nabcdefghijk"
|
| 42 |
+
expected = "\n\n # This is a comment\n\r\n\r\nabcdefghijk"
|
| 43 |
+
pos = parse_space(input, 0, False)
|
| 44 |
+
assert input[pos:] == expected
|
| 45 |
+
|
| 46 |
+
def it_should_return_an_empty_string_if_the_input_is_all_whitespace_and_comments():
|
| 47 |
+
input = " \t# Comment\n# Another comment\n\n"
|
| 48 |
+
expected = ""
|
| 49 |
+
pos = parse_space(input, 0, True)
|
| 50 |
+
assert input[pos:] == expected
|
| 51 |
+
|
| 52 |
+
def it_should_return_an_empty_string_for_an_empty_input_string():
|
| 53 |
+
input = ""
|
| 54 |
+
expected = ""
|
| 55 |
+
pos = parse_space(input, 0, True)
|
| 56 |
+
assert input[pos:] == expected
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/rules_builder.py
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import time
|
| 2 |
+
|
| 3 |
+
from ..utils.errors.grammar_parse_error import GrammarParseError
|
| 4 |
+
from .is_word_char import is_word_char
|
| 5 |
+
from .parse_char import parse_char
|
| 6 |
+
from .parse_name import parse_name
|
| 7 |
+
from .parse_space import parse_space
|
| 8 |
+
from .symbol_ids import SymbolIds
|
| 9 |
+
from .types import InternalRuleDef, InternalRuleType
|
| 10 |
+
from .whitespace import WHITESPACE
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def _now() -> float:
|
| 14 |
+
# the current time in milliseconds
|
| 15 |
+
return time.perf_counter() * 1000
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _char_at(src: str, pos: int) -> str:
|
| 19 |
+
# the character at pos, or an empty string once pos is past the end of src
|
| 20 |
+
return src[pos : pos + 1]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class RulesBuilder:
|
| 24 |
+
def __init__(self, src: str, limit: float = 1000) -> None:
|
| 25 |
+
self._pos = 0
|
| 26 |
+
self.symbol_ids = SymbolIds()
|
| 27 |
+
self.rules: list[list[InternalRuleDef]] = []
|
| 28 |
+
self.src = src
|
| 29 |
+
self.start = _now()
|
| 30 |
+
self._time_limit = limit
|
| 31 |
+
self._parse(src)
|
| 32 |
+
|
| 33 |
+
def _parse(self, src: str) -> None:
|
| 34 |
+
# move cursor forward until we reach non-whitespace content
|
| 35 |
+
self._pos = parse_space(src, 0, True)
|
| 36 |
+
|
| 37 |
+
while self._pos < len(src):
|
| 38 |
+
self._parse_rule(src)
|
| 39 |
+
|
| 40 |
+
# Validate the state to ensure that all rules are defined
|
| 41 |
+
for rule in self.rules:
|
| 42 |
+
if rule is None:
|
| 43 |
+
# an undefined rule that comes before the rules referring to it
|
| 44 |
+
# ends the parse here, as it does in the reference implementation
|
| 45 |
+
raise TypeError("rule is not iterable")
|
| 46 |
+
for elem in rule:
|
| 47 |
+
if elem["type"] == InternalRuleType.RULE_REF:
|
| 48 |
+
# Ensure that the rule at that location exists
|
| 49 |
+
rule_exists = elem["value"] < len(self.rules) and bool(
|
| 50 |
+
self.rules[elem["value"]]
|
| 51 |
+
)
|
| 52 |
+
if not rule_exists:
|
| 53 |
+
missing_rule_name = self.symbol_ids.reverse_get(elem["value"])
|
| 54 |
+
missing_rule_pos = self.symbol_ids.get_pos(missing_rule_name)
|
| 55 |
+
|
| 56 |
+
# Skip over the ::= and any whitespace
|
| 57 |
+
while missing_rule_pos < len(src) and (
|
| 58 |
+
src[missing_rule_pos] in ":="
|
| 59 |
+
or src[missing_rule_pos] in WHITESPACE
|
| 60 |
+
):
|
| 61 |
+
missing_rule_pos += 1
|
| 62 |
+
|
| 63 |
+
raise GrammarParseError(
|
| 64 |
+
src,
|
| 65 |
+
missing_rule_pos,
|
| 66 |
+
f'Undefined rule identifier "{missing_rule_name}"',
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
def _parse_rule(self, src: str) -> None:
|
| 70 |
+
name = parse_name(src, self._pos)
|
| 71 |
+
self._pos = parse_space(src, self._pos + len(name), False)
|
| 72 |
+
rule_id = self.get_symbol_id(name, len(name))
|
| 73 |
+
|
| 74 |
+
# Skip over whitespace characters and find the ::= sequence
|
| 75 |
+
self._pos = parse_space(src, self._pos, True)
|
| 76 |
+
if not src.startswith("::=", self._pos):
|
| 77 |
+
raise GrammarParseError(src, self._pos, f"Expecting ::= at {self._pos}")
|
| 78 |
+
self._pos = parse_space(src, self._pos + 3, True)
|
| 79 |
+
|
| 80 |
+
self.parse_alternates(name, rule_id)
|
| 81 |
+
|
| 82 |
+
if _char_at(src, self._pos) == "\r":
|
| 83 |
+
self._pos += 2 if _char_at(src, self._pos + 1) == "\n" else 1
|
| 84 |
+
elif _char_at(src, self._pos) == "\n":
|
| 85 |
+
self._pos += 1
|
| 86 |
+
elif _char_at(src, self._pos):
|
| 87 |
+
raise GrammarParseError(
|
| 88 |
+
src, self._pos, f"Expecting newline or end at {self._pos}"
|
| 89 |
+
)
|
| 90 |
+
self._pos = parse_space(src, self._pos, True)
|
| 91 |
+
|
| 92 |
+
def get_symbol_id(self, src: str, length: int) -> int:
|
| 93 |
+
next_id = len(self.symbol_ids)
|
| 94 |
+
key = src[:length]
|
| 95 |
+
if not self.symbol_ids.has(key):
|
| 96 |
+
self.symbol_ids.set(key, next_id, self._pos)
|
| 97 |
+
return self.symbol_ids.get(key)
|
| 98 |
+
|
| 99 |
+
def generate_symbol_id(self, base_name: str) -> int:
|
| 100 |
+
next_id = len(self.symbol_ids)
|
| 101 |
+
self.symbol_ids.set(f"{base_name}_{next_id}", next_id, self._pos)
|
| 102 |
+
return next_id
|
| 103 |
+
|
| 104 |
+
def add_rule(self, rule_id: int, rule: list[InternalRuleDef]) -> None:
|
| 105 |
+
# a rule can be referred to, and so be given an id, before it is defined;
|
| 106 |
+
# until it is, its place in the list of rules stays empty.
|
| 107 |
+
while len(self.rules) <= rule_id:
|
| 108 |
+
self.rules.append(None) # type: ignore[arg-type]
|
| 109 |
+
self.rules[rule_id] = rule
|
| 110 |
+
|
| 111 |
+
def check_duration(self) -> None:
|
| 112 |
+
if _now() - self.start > self._time_limit:
|
| 113 |
+
raise GrammarParseError(
|
| 114 |
+
self.src, self._pos, f"duration of {self._time_limit} exceeded:"
|
| 115 |
+
)
|
| 116 |
+
|
| 117 |
+
def parse_sequence(
|
| 118 |
+
self,
|
| 119 |
+
rule_name: str,
|
| 120 |
+
out_elements: list[InternalRuleDef],
|
| 121 |
+
depth: int = 0,
|
| 122 |
+
) -> None:
|
| 123 |
+
is_nested = depth != 0
|
| 124 |
+
src = self.src
|
| 125 |
+
last_sym_start = len(out_elements)
|
| 126 |
+
while self._pos < len(src):
|
| 127 |
+
char = src[self._pos]
|
| 128 |
+
if char == '"':
|
| 129 |
+
self._pos += 1
|
| 130 |
+
last_sym_start = len(out_elements)
|
| 131 |
+
while _char_at(src, self._pos) != '"':
|
| 132 |
+
self.check_duration()
|
| 133 |
+
value, inc_pos = parse_char(src, self._pos)
|
| 134 |
+
out_elements.append({"type": InternalRuleType.CHAR, "value": [value]})
|
| 135 |
+
# Adjusting pos by the length of parsed characters
|
| 136 |
+
self._pos += inc_pos
|
| 137 |
+
self._pos = parse_space(src, self._pos + 1, is_nested)
|
| 138 |
+
elif char == "[":
|
| 139 |
+
self._pos += 1
|
| 140 |
+
start_type = InternalRuleType.CHAR
|
| 141 |
+
if _char_at(src, self._pos) == "^":
|
| 142 |
+
self._pos += 1
|
| 143 |
+
start_type = InternalRuleType.CHAR_NOT
|
| 144 |
+
last_sym_start = len(out_elements)
|
| 145 |
+
while _char_at(src, self._pos) != "]":
|
| 146 |
+
self.check_duration()
|
| 147 |
+
type_ = (
|
| 148 |
+
InternalRuleType.CHAR_ALT
|
| 149 |
+
if last_sym_start < len(out_elements)
|
| 150 |
+
else start_type
|
| 151 |
+
)
|
| 152 |
+
startchar_value, inc_pos = parse_char(src, self._pos)
|
| 153 |
+
self._pos += inc_pos
|
| 154 |
+
if type_ in (InternalRuleType.CHAR, InternalRuleType.CHAR_NOT):
|
| 155 |
+
out_elements.append({"type": type_, "value": [startchar_value]})
|
| 156 |
+
else:
|
| 157 |
+
out_elements.append({"type": type_, "value": startchar_value})
|
| 158 |
+
|
| 159 |
+
if (
|
| 160 |
+
_char_at(src, self._pos) == "-"
|
| 161 |
+
and _char_at(src, self._pos + 1) != "]"
|
| 162 |
+
):
|
| 163 |
+
self._pos += 1
|
| 164 |
+
endchar_value, inc_pos = parse_char(src, self._pos)
|
| 165 |
+
out_elements.append(
|
| 166 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": endchar_value}
|
| 167 |
+
)
|
| 168 |
+
self._pos += inc_pos
|
| 169 |
+
self._pos = parse_space(src, self._pos + 1, is_nested)
|
| 170 |
+
elif is_word_char(char):
|
| 171 |
+
name = parse_name(src, self._pos)
|
| 172 |
+
ref_rule_id = self.get_symbol_id(name, len(name))
|
| 173 |
+
self._pos += len(name)
|
| 174 |
+
self._pos = parse_space(src, self._pos, is_nested)
|
| 175 |
+
|
| 176 |
+
last_sym_start = len(out_elements)
|
| 177 |
+
out_elements.append({"type": InternalRuleType.RULE_REF, "value": ref_rule_id})
|
| 178 |
+
elif char == "(":
|
| 179 |
+
self._pos = parse_space(src, self._pos + 1, True)
|
| 180 |
+
sub_rule_id = self.generate_symbol_id(rule_name)
|
| 181 |
+
self.parse_alternates(rule_name, sub_rule_id, depth + 1)
|
| 182 |
+
last_sym_start = len(out_elements)
|
| 183 |
+
out_elements.append({"type": InternalRuleType.RULE_REF, "value": sub_rule_id})
|
| 184 |
+
if _char_at(src, self._pos) != ")":
|
| 185 |
+
raise GrammarParseError(src, self._pos, f"Expecting ')' at {self._pos}")
|
| 186 |
+
self._pos = parse_space(src, self._pos + 1, is_nested)
|
| 187 |
+
elif char in ("*", "+", "?"):
|
| 188 |
+
if last_sym_start == len(out_elements):
|
| 189 |
+
raise GrammarParseError(
|
| 190 |
+
src, self._pos, f"Expecting preceding item to */+/? at {self._pos}"
|
| 191 |
+
)
|
| 192 |
+
sub_rule_id = self.generate_symbol_id(rule_name)
|
| 193 |
+
sub_rule = out_elements[last_sym_start:]
|
| 194 |
+
if char in ("*", "+"):
|
| 195 |
+
sub_rule.append({"type": InternalRuleType.RULE_REF, "value": sub_rule_id})
|
| 196 |
+
sub_rule.append({"type": InternalRuleType.ALT})
|
| 197 |
+
if char == "+":
|
| 198 |
+
sub_rule.extend(out_elements[last_sym_start:])
|
| 199 |
+
sub_rule.append({"type": InternalRuleType.END})
|
| 200 |
+
self.add_rule(sub_rule_id, sub_rule)
|
| 201 |
+
del out_elements[last_sym_start:]
|
| 202 |
+
out_elements.append({"type": InternalRuleType.RULE_REF, "value": sub_rule_id})
|
| 203 |
+
self._pos = parse_space(src, self._pos + 1, is_nested)
|
| 204 |
+
else:
|
| 205 |
+
break
|
| 206 |
+
|
| 207 |
+
def parse_alternates(self, rule_name: str, rule_id: int, depth: int = 0) -> None:
|
| 208 |
+
src = self.src
|
| 209 |
+
rule: list[InternalRuleDef] = []
|
| 210 |
+
self.parse_sequence(rule_name, rule, depth)
|
| 211 |
+
while _char_at(src, self._pos) == "|":
|
| 212 |
+
self.check_duration()
|
| 213 |
+
rule.append({"type": InternalRuleType.ALT})
|
| 214 |
+
self._pos = parse_space(src, self._pos + 1, True)
|
| 215 |
+
self.parse_sequence(rule_name, rule, depth)
|
| 216 |
+
rule.append({"type": InternalRuleType.END})
|
| 217 |
+
self.add_rule(rule_id, rule)
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/rules_builder_test.py
ADDED
|
@@ -0,0 +1,1478 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import TypedDict
|
| 2 |
+
|
| 3 |
+
import pytest
|
| 4 |
+
|
| 5 |
+
from gbnf.rules_builder.rules_builder import RulesBuilder
|
| 6 |
+
from gbnf.rules_builder.types import InternalRuleDef, InternalRuleType
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class Expectation(TypedDict):
|
| 10 |
+
symbol_ids: list[tuple[str, int]]
|
| 11 |
+
rules: list[list[InternalRuleDef]]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
TEST_CASES: list[tuple[str, str, Expectation]] = [
|
| 15 |
+
(
|
| 16 |
+
"single-string",
|
| 17 |
+
'root ::= "foo"',
|
| 18 |
+
{
|
| 19 |
+
"symbol_ids": [("root", 0)],
|
| 20 |
+
"rules": [
|
| 21 |
+
[
|
| 22 |
+
{"type": InternalRuleType.CHAR, "value": [ord("f")]},
|
| 23 |
+
{"type": InternalRuleType.CHAR, "value": [ord("o")]},
|
| 24 |
+
{"type": InternalRuleType.CHAR, "value": [ord("o")]},
|
| 25 |
+
{"type": InternalRuleType.END},
|
| 26 |
+
],
|
| 27 |
+
],
|
| 28 |
+
},
|
| 29 |
+
),
|
| 30 |
+
(
|
| 31 |
+
"quote character",
|
| 32 |
+
'root::= "\\""',
|
| 33 |
+
{
|
| 34 |
+
"symbol_ids": [("root", 0)],
|
| 35 |
+
"rules": [
|
| 36 |
+
[
|
| 37 |
+
{"type": InternalRuleType.CHAR, "value": [ord('"')]},
|
| 38 |
+
{"type": InternalRuleType.END},
|
| 39 |
+
],
|
| 40 |
+
],
|
| 41 |
+
},
|
| 42 |
+
),
|
| 43 |
+
(
|
| 44 |
+
"two-lines-referencing-expression",
|
| 45 |
+
"""root ::= foo
|
| 46 |
+
foo ::= "bar"
|
| 47 |
+
""",
|
| 48 |
+
{
|
| 49 |
+
"symbol_ids": [("root", 0), ("foo", 1)],
|
| 50 |
+
"rules": [
|
| 51 |
+
[
|
| 52 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 53 |
+
{"type": InternalRuleType.END},
|
| 54 |
+
],
|
| 55 |
+
[
|
| 56 |
+
{"type": InternalRuleType.CHAR, "value": [ord("b")]},
|
| 57 |
+
{"type": InternalRuleType.CHAR, "value": [ord("a")]},
|
| 58 |
+
{"type": InternalRuleType.CHAR, "value": [ord("r")]},
|
| 59 |
+
{"type": InternalRuleType.END},
|
| 60 |
+
],
|
| 61 |
+
],
|
| 62 |
+
},
|
| 63 |
+
),
|
| 64 |
+
(
|
| 65 |
+
"expression with dash",
|
| 66 |
+
"""root ::= foo-bar
|
| 67 |
+
foo-bar ::= "bar"
|
| 68 |
+
""",
|
| 69 |
+
{
|
| 70 |
+
"symbol_ids": [("root", 0), ("foo-bar", 1)],
|
| 71 |
+
"rules": [
|
| 72 |
+
[
|
| 73 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 74 |
+
{"type": InternalRuleType.END},
|
| 75 |
+
],
|
| 76 |
+
[
|
| 77 |
+
{"type": InternalRuleType.CHAR, "value": [ord("b")]},
|
| 78 |
+
{"type": InternalRuleType.CHAR, "value": [ord("a")]},
|
| 79 |
+
{"type": InternalRuleType.CHAR, "value": [ord("r")]},
|
| 80 |
+
{"type": InternalRuleType.END},
|
| 81 |
+
],
|
| 82 |
+
],
|
| 83 |
+
},
|
| 84 |
+
),
|
| 85 |
+
(
|
| 86 |
+
"simple-grammar",
|
| 87 |
+
"""
|
| 88 |
+
root ::= (expr "=" term "\n")+
|
| 89 |
+
expr ::= term ([-+*/] term)*
|
| 90 |
+
term ::= [0-9]+
|
| 91 |
+
|
| 92 |
+
""",
|
| 93 |
+
{
|
| 94 |
+
"symbol_ids": [
|
| 95 |
+
("root", 0),
|
| 96 |
+
("root_1", 1),
|
| 97 |
+
("expr", 2),
|
| 98 |
+
("term", 3),
|
| 99 |
+
("root_4", 4),
|
| 100 |
+
("expr_5", 5),
|
| 101 |
+
("expr_6", 6),
|
| 102 |
+
("term_7", 7),
|
| 103 |
+
],
|
| 104 |
+
"rules": [
|
| 105 |
+
[
|
| 106 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 107 |
+
{"type": InternalRuleType.END},
|
| 108 |
+
],
|
| 109 |
+
[
|
| 110 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 111 |
+
{"type": InternalRuleType.CHAR, "value": [61]},
|
| 112 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 113 |
+
{"type": InternalRuleType.CHAR, "value": [10]},
|
| 114 |
+
{"type": InternalRuleType.END},
|
| 115 |
+
],
|
| 116 |
+
[
|
| 117 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 118 |
+
{"type": InternalRuleType.RULE_REF, "value": 6},
|
| 119 |
+
{"type": InternalRuleType.END},
|
| 120 |
+
],
|
| 121 |
+
[
|
| 122 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 123 |
+
{"type": InternalRuleType.END},
|
| 124 |
+
],
|
| 125 |
+
[
|
| 126 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 127 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 128 |
+
{"type": InternalRuleType.ALT},
|
| 129 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 130 |
+
{"type": InternalRuleType.END},
|
| 131 |
+
],
|
| 132 |
+
[
|
| 133 |
+
{"type": InternalRuleType.CHAR, "value": [45]},
|
| 134 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 43},
|
| 135 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 42},
|
| 136 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 47},
|
| 137 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 138 |
+
{"type": InternalRuleType.END},
|
| 139 |
+
],
|
| 140 |
+
[
|
| 141 |
+
{"type": InternalRuleType.RULE_REF, "value": 5},
|
| 142 |
+
{"type": InternalRuleType.RULE_REF, "value": 6},
|
| 143 |
+
{"type": InternalRuleType.ALT},
|
| 144 |
+
{"type": InternalRuleType.END},
|
| 145 |
+
],
|
| 146 |
+
[
|
| 147 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 148 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 149 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 150 |
+
{"type": InternalRuleType.ALT},
|
| 151 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 152 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 153 |
+
{"type": InternalRuleType.END},
|
| 154 |
+
],
|
| 155 |
+
],
|
| 156 |
+
},
|
| 157 |
+
),
|
| 158 |
+
(
|
| 159 |
+
"longer-grammar",
|
| 160 |
+
"""root ::= (expr "=" ws term "\\n")+
|
| 161 |
+
expr ::= term ([-+*/] term)*
|
| 162 |
+
term ::= ident | num | "(" ws expr ")" ws
|
| 163 |
+
ident ::= [a-z] [a-z0-9_]* ws
|
| 164 |
+
num ::= [0-9]+ ws
|
| 165 |
+
ws ::= [ \\t\\n]*""",
|
| 166 |
+
{
|
| 167 |
+
"symbol_ids": [
|
| 168 |
+
("root", 0),
|
| 169 |
+
("root_1", 1),
|
| 170 |
+
("expr", 2),
|
| 171 |
+
("ws", 3),
|
| 172 |
+
("term", 4),
|
| 173 |
+
("root_5", 5),
|
| 174 |
+
("expr_6", 6),
|
| 175 |
+
("expr_7", 7),
|
| 176 |
+
("ident", 8),
|
| 177 |
+
("num", 9),
|
| 178 |
+
("ident_10", 10),
|
| 179 |
+
("num_11", 11),
|
| 180 |
+
("ws_12", 12),
|
| 181 |
+
],
|
| 182 |
+
"rules": [
|
| 183 |
+
[
|
| 184 |
+
{"value": 5, "type": InternalRuleType.RULE_REF},
|
| 185 |
+
{"type": InternalRuleType.END},
|
| 186 |
+
],
|
| 187 |
+
[
|
| 188 |
+
{"value": 2, "type": InternalRuleType.RULE_REF},
|
| 189 |
+
{"value": [61], "type": InternalRuleType.CHAR},
|
| 190 |
+
{"value": 3, "type": InternalRuleType.RULE_REF},
|
| 191 |
+
{"value": 4, "type": InternalRuleType.RULE_REF},
|
| 192 |
+
{"value": [10], "type": InternalRuleType.CHAR},
|
| 193 |
+
{"type": InternalRuleType.END},
|
| 194 |
+
],
|
| 195 |
+
[
|
| 196 |
+
{"value": 4, "type": InternalRuleType.RULE_REF},
|
| 197 |
+
{"value": 7, "type": InternalRuleType.RULE_REF},
|
| 198 |
+
{"type": InternalRuleType.END},
|
| 199 |
+
],
|
| 200 |
+
[
|
| 201 |
+
{"value": 12, "type": InternalRuleType.RULE_REF},
|
| 202 |
+
{"type": InternalRuleType.END},
|
| 203 |
+
],
|
| 204 |
+
[
|
| 205 |
+
{"value": 8, "type": InternalRuleType.RULE_REF},
|
| 206 |
+
{"type": InternalRuleType.ALT},
|
| 207 |
+
{"value": 9, "type": InternalRuleType.RULE_REF},
|
| 208 |
+
{"type": InternalRuleType.ALT},
|
| 209 |
+
{"value": [40], "type": InternalRuleType.CHAR},
|
| 210 |
+
{"value": 3, "type": InternalRuleType.RULE_REF},
|
| 211 |
+
{"value": 2, "type": InternalRuleType.RULE_REF},
|
| 212 |
+
{"value": [41], "type": InternalRuleType.CHAR},
|
| 213 |
+
{"value": 3, "type": InternalRuleType.RULE_REF},
|
| 214 |
+
{"type": InternalRuleType.END},
|
| 215 |
+
],
|
| 216 |
+
[
|
| 217 |
+
{"value": 1, "type": InternalRuleType.RULE_REF},
|
| 218 |
+
{"value": 5, "type": InternalRuleType.RULE_REF},
|
| 219 |
+
{"type": InternalRuleType.ALT},
|
| 220 |
+
{"value": 1, "type": InternalRuleType.RULE_REF},
|
| 221 |
+
{"type": InternalRuleType.END},
|
| 222 |
+
],
|
| 223 |
+
[
|
| 224 |
+
{"value": [45], "type": InternalRuleType.CHAR},
|
| 225 |
+
{"value": 43, "type": InternalRuleType.CHAR_ALT},
|
| 226 |
+
{"value": 42, "type": InternalRuleType.CHAR_ALT},
|
| 227 |
+
{"value": 47, "type": InternalRuleType.CHAR_ALT},
|
| 228 |
+
{"value": 4, "type": InternalRuleType.RULE_REF},
|
| 229 |
+
{"type": InternalRuleType.END},
|
| 230 |
+
],
|
| 231 |
+
[
|
| 232 |
+
{"value": 6, "type": InternalRuleType.RULE_REF},
|
| 233 |
+
{"value": 7, "type": InternalRuleType.RULE_REF},
|
| 234 |
+
{"type": InternalRuleType.ALT},
|
| 235 |
+
{"type": InternalRuleType.END},
|
| 236 |
+
],
|
| 237 |
+
[
|
| 238 |
+
{"value": [97], "type": InternalRuleType.CHAR},
|
| 239 |
+
{"value": 122, "type": InternalRuleType.CHAR_RNG_UPPER},
|
| 240 |
+
{"value": 10, "type": InternalRuleType.RULE_REF},
|
| 241 |
+
{"value": 3, "type": InternalRuleType.RULE_REF},
|
| 242 |
+
{"type": InternalRuleType.END},
|
| 243 |
+
],
|
| 244 |
+
[
|
| 245 |
+
{"value": 11, "type": InternalRuleType.RULE_REF},
|
| 246 |
+
{"value": 3, "type": InternalRuleType.RULE_REF},
|
| 247 |
+
{"type": InternalRuleType.END},
|
| 248 |
+
],
|
| 249 |
+
[
|
| 250 |
+
{"value": [97], "type": InternalRuleType.CHAR},
|
| 251 |
+
{"value": 122, "type": InternalRuleType.CHAR_RNG_UPPER},
|
| 252 |
+
{"value": 48, "type": InternalRuleType.CHAR_ALT},
|
| 253 |
+
{"value": 57, "type": InternalRuleType.CHAR_RNG_UPPER},
|
| 254 |
+
{"value": 95, "type": InternalRuleType.CHAR_ALT},
|
| 255 |
+
{"value": 10, "type": InternalRuleType.RULE_REF},
|
| 256 |
+
{"type": InternalRuleType.ALT},
|
| 257 |
+
{"type": InternalRuleType.END},
|
| 258 |
+
],
|
| 259 |
+
[
|
| 260 |
+
{"value": [48], "type": InternalRuleType.CHAR},
|
| 261 |
+
{"value": 57, "type": InternalRuleType.CHAR_RNG_UPPER},
|
| 262 |
+
{"value": 11, "type": InternalRuleType.RULE_REF},
|
| 263 |
+
{"type": InternalRuleType.ALT},
|
| 264 |
+
{"value": [48], "type": InternalRuleType.CHAR},
|
| 265 |
+
{"value": 57, "type": InternalRuleType.CHAR_RNG_UPPER},
|
| 266 |
+
{"type": InternalRuleType.END},
|
| 267 |
+
],
|
| 268 |
+
[
|
| 269 |
+
{"value": [32], "type": InternalRuleType.CHAR},
|
| 270 |
+
{"value": 9, "type": InternalRuleType.CHAR_ALT},
|
| 271 |
+
{"value": 10, "type": InternalRuleType.CHAR_ALT},
|
| 272 |
+
{"value": 12, "type": InternalRuleType.RULE_REF},
|
| 273 |
+
{"type": InternalRuleType.ALT},
|
| 274 |
+
{"type": InternalRuleType.END},
|
| 275 |
+
],
|
| 276 |
+
],
|
| 277 |
+
},
|
| 278 |
+
),
|
| 279 |
+
(
|
| 280 |
+
"character unicode grammar",
|
| 281 |
+
"root ::= [ぁ-ゟ]",
|
| 282 |
+
{
|
| 283 |
+
"symbol_ids": [("root", 0)],
|
| 284 |
+
"rules": [
|
| 285 |
+
[
|
| 286 |
+
{"type": InternalRuleType.CHAR, "value": [ord("ぁ")]},
|
| 287 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": ord("ゟ")},
|
| 288 |
+
{"type": InternalRuleType.END},
|
| 289 |
+
],
|
| 290 |
+
],
|
| 291 |
+
},
|
| 292 |
+
),
|
| 293 |
+
(
|
| 294 |
+
"character alts grammar",
|
| 295 |
+
"root ::= [az]",
|
| 296 |
+
{
|
| 297 |
+
"symbol_ids": [("root", 0)],
|
| 298 |
+
"rules": [
|
| 299 |
+
[
|
| 300 |
+
{"type": InternalRuleType.CHAR, "value": [ord("a")]},
|
| 301 |
+
{"type": InternalRuleType.CHAR_ALT, "value": ord("z")},
|
| 302 |
+
{"type": InternalRuleType.END},
|
| 303 |
+
],
|
| 304 |
+
],
|
| 305 |
+
},
|
| 306 |
+
),
|
| 307 |
+
(
|
| 308 |
+
"character range grammar",
|
| 309 |
+
"root ::= [a-zA-Z0-9]",
|
| 310 |
+
{
|
| 311 |
+
"symbol_ids": [("root", 0)],
|
| 312 |
+
"rules": [
|
| 313 |
+
[
|
| 314 |
+
{"type": InternalRuleType.CHAR, "value": [ord("a")]},
|
| 315 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": ord("z")},
|
| 316 |
+
{"type": InternalRuleType.CHAR_ALT, "value": ord("A")},
|
| 317 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": ord("Z")},
|
| 318 |
+
{"type": InternalRuleType.CHAR_ALT, "value": ord("0")},
|
| 319 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": ord("9")},
|
| 320 |
+
{"type": InternalRuleType.END},
|
| 321 |
+
],
|
| 322 |
+
],
|
| 323 |
+
},
|
| 324 |
+
),
|
| 325 |
+
(
|
| 326 |
+
"character range grammar with dash at end",
|
| 327 |
+
"root ::= [a-z-]",
|
| 328 |
+
{
|
| 329 |
+
"symbol_ids": [("root", 0)],
|
| 330 |
+
"rules": [
|
| 331 |
+
[
|
| 332 |
+
{"type": InternalRuleType.CHAR, "value": [ord("a")]},
|
| 333 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": ord("z")},
|
| 334 |
+
{"type": InternalRuleType.CHAR_ALT, "value": ord("-")},
|
| 335 |
+
{"type": InternalRuleType.END},
|
| 336 |
+
],
|
| 337 |
+
],
|
| 338 |
+
},
|
| 339 |
+
),
|
| 340 |
+
(
|
| 341 |
+
"grouping",
|
| 342 |
+
'root ::= "f" ("b" | "a")',
|
| 343 |
+
{
|
| 344 |
+
"symbol_ids": [("root", 0), ("root_1", 1)],
|
| 345 |
+
"rules": [
|
| 346 |
+
[
|
| 347 |
+
{"type": InternalRuleType.CHAR, "value": [ord("f")]},
|
| 348 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 349 |
+
{"type": InternalRuleType.END},
|
| 350 |
+
],
|
| 351 |
+
[
|
| 352 |
+
{"type": InternalRuleType.CHAR, "value": [ord("b")]},
|
| 353 |
+
{"type": InternalRuleType.ALT},
|
| 354 |
+
{"type": InternalRuleType.CHAR, "value": [ord("a")]},
|
| 355 |
+
{"type": InternalRuleType.END},
|
| 356 |
+
],
|
| 357 |
+
],
|
| 358 |
+
},
|
| 359 |
+
),
|
| 360 |
+
(
|
| 361 |
+
"optional",
|
| 362 |
+
'root ::= "f"?',
|
| 363 |
+
{
|
| 364 |
+
"symbol_ids": [("root", 0), ("root_1", 1)],
|
| 365 |
+
"rules": [
|
| 366 |
+
[
|
| 367 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 368 |
+
{"type": InternalRuleType.END},
|
| 369 |
+
],
|
| 370 |
+
[
|
| 371 |
+
{"type": InternalRuleType.CHAR, "value": [ord("f")]},
|
| 372 |
+
{"type": InternalRuleType.ALT},
|
| 373 |
+
{"type": InternalRuleType.END},
|
| 374 |
+
],
|
| 375 |
+
],
|
| 376 |
+
},
|
| 377 |
+
),
|
| 378 |
+
(
|
| 379 |
+
"repeating",
|
| 380 |
+
'root ::= "f"*',
|
| 381 |
+
{
|
| 382 |
+
"symbol_ids": [("root", 0), ("root_1", 1)],
|
| 383 |
+
"rules": [
|
| 384 |
+
[
|
| 385 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 386 |
+
{"type": InternalRuleType.END},
|
| 387 |
+
],
|
| 388 |
+
[
|
| 389 |
+
{"type": InternalRuleType.CHAR, "value": [ord("f")]},
|
| 390 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 391 |
+
{"type": InternalRuleType.ALT},
|
| 392 |
+
{"type": InternalRuleType.END},
|
| 393 |
+
],
|
| 394 |
+
],
|
| 395 |
+
},
|
| 396 |
+
),
|
| 397 |
+
(
|
| 398 |
+
"repeating-at-least-once",
|
| 399 |
+
'root ::= "f"+',
|
| 400 |
+
{
|
| 401 |
+
"symbol_ids": [("root", 0), ("root_1", 1)],
|
| 402 |
+
"rules": [
|
| 403 |
+
[
|
| 404 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 405 |
+
{"type": InternalRuleType.END},
|
| 406 |
+
],
|
| 407 |
+
[
|
| 408 |
+
{"type": InternalRuleType.CHAR, "value": [ord("f")]},
|
| 409 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 410 |
+
{"type": InternalRuleType.ALT},
|
| 411 |
+
{"type": InternalRuleType.CHAR, "value": [ord("f")]},
|
| 412 |
+
{"type": InternalRuleType.END},
|
| 413 |
+
],
|
| 414 |
+
],
|
| 415 |
+
},
|
| 416 |
+
),
|
| 417 |
+
(
|
| 418 |
+
"character range with optional repeating",
|
| 419 |
+
"root ::= [a-zA-Z0-9]*",
|
| 420 |
+
{
|
| 421 |
+
"symbol_ids": [("root", 0), ("root_1", 1)],
|
| 422 |
+
"rules": [
|
| 423 |
+
[
|
| 424 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 425 |
+
{"type": InternalRuleType.END},
|
| 426 |
+
],
|
| 427 |
+
[
|
| 428 |
+
{"type": InternalRuleType.CHAR, "value": [ord("a")]},
|
| 429 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": ord("z")},
|
| 430 |
+
{"type": InternalRuleType.CHAR_ALT, "value": ord("A")},
|
| 431 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": ord("Z")},
|
| 432 |
+
{"type": InternalRuleType.CHAR_ALT, "value": ord("0")},
|
| 433 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": ord("9")},
|
| 434 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 435 |
+
{"type": InternalRuleType.ALT},
|
| 436 |
+
{"type": InternalRuleType.END},
|
| 437 |
+
],
|
| 438 |
+
],
|
| 439 |
+
},
|
| 440 |
+
),
|
| 441 |
+
(
|
| 442 |
+
"grouping-repeating",
|
| 443 |
+
'root ::= "f" ("b" | "a")*',
|
| 444 |
+
{
|
| 445 |
+
"symbol_ids": [("root", 0), ("root_1", 1), ("root_2", 2)],
|
| 446 |
+
"rules": [
|
| 447 |
+
[
|
| 448 |
+
{"type": InternalRuleType.CHAR, "value": [ord("f")]},
|
| 449 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 450 |
+
{"type": InternalRuleType.END},
|
| 451 |
+
],
|
| 452 |
+
[
|
| 453 |
+
{"type": InternalRuleType.CHAR, "value": [ord("b")]},
|
| 454 |
+
{"type": InternalRuleType.ALT},
|
| 455 |
+
{"type": InternalRuleType.CHAR, "value": [ord("a")]},
|
| 456 |
+
{"type": InternalRuleType.END},
|
| 457 |
+
],
|
| 458 |
+
[
|
| 459 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 460 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 461 |
+
{"type": InternalRuleType.ALT},
|
| 462 |
+
{"type": InternalRuleType.END},
|
| 463 |
+
],
|
| 464 |
+
],
|
| 465 |
+
},
|
| 466 |
+
),
|
| 467 |
+
(
|
| 468 |
+
"negation",
|
| 469 |
+
"root ::= [^\n]",
|
| 470 |
+
{
|
| 471 |
+
"symbol_ids": [("root", 0)],
|
| 472 |
+
"rules": [
|
| 473 |
+
[
|
| 474 |
+
{"type": InternalRuleType.CHAR_NOT, "value": [ord("\n")]},
|
| 475 |
+
{"type": InternalRuleType.END},
|
| 476 |
+
],
|
| 477 |
+
],
|
| 478 |
+
},
|
| 479 |
+
),
|
| 480 |
+
(
|
| 481 |
+
"negation of range",
|
| 482 |
+
"root ::= [^0-9]",
|
| 483 |
+
{
|
| 484 |
+
"symbol_ids": [("root", 0)],
|
| 485 |
+
"rules": [
|
| 486 |
+
[
|
| 487 |
+
{"type": InternalRuleType.CHAR_NOT, "value": [ord("0")]},
|
| 488 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": ord("9")},
|
| 489 |
+
{"type": InternalRuleType.END},
|
| 490 |
+
],
|
| 491 |
+
],
|
| 492 |
+
},
|
| 493 |
+
),
|
| 494 |
+
(
|
| 495 |
+
"negation with after",
|
| 496 |
+
'root ::= [^\n]+ "\n"',
|
| 497 |
+
{
|
| 498 |
+
"symbol_ids": [("root", 0), ("root_1", 1)],
|
| 499 |
+
"rules": [
|
| 500 |
+
[
|
| 501 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 502 |
+
{"type": InternalRuleType.CHAR, "value": [ord("\n")]},
|
| 503 |
+
{"type": InternalRuleType.END},
|
| 504 |
+
],
|
| 505 |
+
[
|
| 506 |
+
{"type": InternalRuleType.CHAR_NOT, "value": [ord("\n")]},
|
| 507 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 508 |
+
{"type": InternalRuleType.ALT},
|
| 509 |
+
{"type": InternalRuleType.CHAR_NOT, "value": [ord("\n")]},
|
| 510 |
+
{"type": InternalRuleType.END},
|
| 511 |
+
],
|
| 512 |
+
],
|
| 513 |
+
},
|
| 514 |
+
),
|
| 515 |
+
(
|
| 516 |
+
"longer negation",
|
| 517 |
+
'root ::= "\\"" ( [^"abcdefgh])* ',
|
| 518 |
+
{
|
| 519 |
+
"symbol_ids": [("root", 0), ("root_1", 1), ("root_2", 2)],
|
| 520 |
+
"rules": [
|
| 521 |
+
[
|
| 522 |
+
{"type": InternalRuleType.CHAR, "value": [34]},
|
| 523 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 524 |
+
{"type": InternalRuleType.END},
|
| 525 |
+
],
|
| 526 |
+
[
|
| 527 |
+
{"type": InternalRuleType.CHAR_NOT, "value": [34]},
|
| 528 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 97},
|
| 529 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 98},
|
| 530 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 99},
|
| 531 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 100},
|
| 532 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 101},
|
| 533 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 102},
|
| 534 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 103},
|
| 535 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 104},
|
| 536 |
+
{"type": InternalRuleType.END},
|
| 537 |
+
],
|
| 538 |
+
[
|
| 539 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 540 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 541 |
+
{"type": InternalRuleType.ALT},
|
| 542 |
+
{"type": InternalRuleType.END},
|
| 543 |
+
],
|
| 544 |
+
],
|
| 545 |
+
},
|
| 546 |
+
),
|
| 547 |
+
(
|
| 548 |
+
"longer negation with a range",
|
| 549 |
+
'root ::= "\\"" ( [^"abcdefghA-Z])* ',
|
| 550 |
+
{
|
| 551 |
+
"symbol_ids": [("root", 0), ("root_1", 1), ("root_2", 2)],
|
| 552 |
+
"rules": [
|
| 553 |
+
[
|
| 554 |
+
{"type": InternalRuleType.CHAR, "value": [34]},
|
| 555 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 556 |
+
{"type": InternalRuleType.END},
|
| 557 |
+
],
|
| 558 |
+
[
|
| 559 |
+
{"type": InternalRuleType.CHAR_NOT, "value": [34]},
|
| 560 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 97},
|
| 561 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 98},
|
| 562 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 99},
|
| 563 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 100},
|
| 564 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 101},
|
| 565 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 102},
|
| 566 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 103},
|
| 567 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 104},
|
| 568 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 65},
|
| 569 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 90},
|
| 570 |
+
{"type": InternalRuleType.END},
|
| 571 |
+
],
|
| 572 |
+
[
|
| 573 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 574 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 575 |
+
{"type": InternalRuleType.ALT},
|
| 576 |
+
{"type": InternalRuleType.END},
|
| 577 |
+
],
|
| 578 |
+
],
|
| 579 |
+
},
|
| 580 |
+
),
|
| 581 |
+
*[
|
| 582 |
+
(
|
| 583 |
+
key,
|
| 584 |
+
f'root ::= "{escaped_char}"',
|
| 585 |
+
{
|
| 586 |
+
"symbol_ids": [("root", 0)],
|
| 587 |
+
"rules": [
|
| 588 |
+
[
|
| 589 |
+
{"type": InternalRuleType.CHAR, "value": [actual_char]},
|
| 590 |
+
{"type": InternalRuleType.END},
|
| 591 |
+
],
|
| 592 |
+
],
|
| 593 |
+
},
|
| 594 |
+
)
|
| 595 |
+
for key, escaped_char, actual_char in [
|
| 596 |
+
("escaped 8-bit unicode char", "\\x2A", ord("\x2a")),
|
| 597 |
+
("escaped 16-bit unicode char", "\\u006F", ord("\u006f")),
|
| 598 |
+
("escaped 32-bit unicode char", "\\U0001F4A9", 128169),
|
| 599 |
+
("escaped tab char", "\\t", ord("\t")),
|
| 600 |
+
("escaped new line char", "\\n", ord("\n")),
|
| 601 |
+
("escaped \r char", "\\r", ord("\r")),
|
| 602 |
+
("escaped quote char", '\\"', ord('"')),
|
| 603 |
+
("escaped [ char", "\\[", ord("[")),
|
| 604 |
+
("escaped ] char", "\\]", ord("]")),
|
| 605 |
+
("escaped \\ char", "\\\\", ord("\\")),
|
| 606 |
+
]
|
| 607 |
+
],
|
| 608 |
+
(
|
| 609 |
+
"simple arithmetic",
|
| 610 |
+
"""
|
| 611 |
+
root ::= (expr "=" term "\n")+
|
| 612 |
+
expr ::= term ([-+*/] term)*
|
| 613 |
+
term ::= [0-9]+
|
| 614 |
+
""",
|
| 615 |
+
{
|
| 616 |
+
"symbol_ids": [
|
| 617 |
+
("root", 0),
|
| 618 |
+
("root_1", 1),
|
| 619 |
+
("expr", 2),
|
| 620 |
+
("term", 3),
|
| 621 |
+
("root_4", 4),
|
| 622 |
+
("expr_5", 5),
|
| 623 |
+
("expr_6", 6),
|
| 624 |
+
("term_7", 7),
|
| 625 |
+
],
|
| 626 |
+
"rules": [
|
| 627 |
+
[
|
| 628 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 629 |
+
{"type": InternalRuleType.END},
|
| 630 |
+
],
|
| 631 |
+
[
|
| 632 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 633 |
+
{"type": InternalRuleType.CHAR, "value": [61]},
|
| 634 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 635 |
+
{"type": InternalRuleType.CHAR, "value": [10]},
|
| 636 |
+
{"type": InternalRuleType.END},
|
| 637 |
+
],
|
| 638 |
+
[
|
| 639 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 640 |
+
{"type": InternalRuleType.RULE_REF, "value": 6},
|
| 641 |
+
{"type": InternalRuleType.END},
|
| 642 |
+
],
|
| 643 |
+
[
|
| 644 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 645 |
+
{"type": InternalRuleType.END},
|
| 646 |
+
],
|
| 647 |
+
[
|
| 648 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 649 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 650 |
+
{"type": InternalRuleType.ALT},
|
| 651 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 652 |
+
{"type": InternalRuleType.END},
|
| 653 |
+
],
|
| 654 |
+
[
|
| 655 |
+
{"type": InternalRuleType.CHAR, "value": [45]},
|
| 656 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 43},
|
| 657 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 42},
|
| 658 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 47},
|
| 659 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 660 |
+
{"type": InternalRuleType.END},
|
| 661 |
+
],
|
| 662 |
+
[
|
| 663 |
+
{"type": InternalRuleType.RULE_REF, "value": 5},
|
| 664 |
+
{"type": InternalRuleType.RULE_REF, "value": 6},
|
| 665 |
+
{"type": InternalRuleType.ALT},
|
| 666 |
+
{"type": InternalRuleType.END},
|
| 667 |
+
],
|
| 668 |
+
[
|
| 669 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 670 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 671 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 672 |
+
{"type": InternalRuleType.ALT},
|
| 673 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 674 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 675 |
+
{"type": InternalRuleType.END},
|
| 676 |
+
],
|
| 677 |
+
],
|
| 678 |
+
},
|
| 679 |
+
),
|
| 680 |
+
(
|
| 681 |
+
"ranges with chars",
|
| 682 |
+
"""
|
| 683 |
+
root ::= [a-z0-9_]*
|
| 684 |
+
""",
|
| 685 |
+
{
|
| 686 |
+
"symbol_ids": [("root", 0), ("root_1", 1)],
|
| 687 |
+
"rules": [
|
| 688 |
+
[
|
| 689 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 690 |
+
{"type": InternalRuleType.END},
|
| 691 |
+
],
|
| 692 |
+
[
|
| 693 |
+
{"type": InternalRuleType.CHAR, "value": [97]},
|
| 694 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 122},
|
| 695 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 48},
|
| 696 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 697 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 95},
|
| 698 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 699 |
+
{"type": InternalRuleType.ALT},
|
| 700 |
+
{"type": InternalRuleType.END},
|
| 701 |
+
],
|
| 702 |
+
],
|
| 703 |
+
},
|
| 704 |
+
),
|
| 705 |
+
(
|
| 706 |
+
"nested ranges with chars",
|
| 707 |
+
"""
|
| 708 |
+
root ::= [a-z] [a-z0-9_]*
|
| 709 |
+
""",
|
| 710 |
+
{
|
| 711 |
+
"symbol_ids": [("root", 0), ("root_1", 1)],
|
| 712 |
+
"rules": [
|
| 713 |
+
[
|
| 714 |
+
{"type": InternalRuleType.CHAR, "value": [97]},
|
| 715 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 122},
|
| 716 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 717 |
+
{"type": InternalRuleType.END},
|
| 718 |
+
],
|
| 719 |
+
[
|
| 720 |
+
{"type": InternalRuleType.CHAR, "value": [97]},
|
| 721 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 122},
|
| 722 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 48},
|
| 723 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 724 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 95},
|
| 725 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 726 |
+
{"type": InternalRuleType.ALT},
|
| 727 |
+
{"type": InternalRuleType.END},
|
| 728 |
+
],
|
| 729 |
+
],
|
| 730 |
+
},
|
| 731 |
+
),
|
| 732 |
+
(
|
| 733 |
+
"expression with nested range with chars",
|
| 734 |
+
"""
|
| 735 |
+
root ::= ident
|
| 736 |
+
ident ::= [a-z] [a-z0-9_]* ws
|
| 737 |
+
ws ::= [ \\t\\n]*
|
| 738 |
+
""",
|
| 739 |
+
{
|
| 740 |
+
"symbol_ids": [("root", 0), ("ident", 1), ("ident_2", 2), ("ws", 3), ("ws_4", 4)],
|
| 741 |
+
"rules": [
|
| 742 |
+
[
|
| 743 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 744 |
+
{"type": InternalRuleType.END},
|
| 745 |
+
],
|
| 746 |
+
[
|
| 747 |
+
{"type": InternalRuleType.CHAR, "value": [97]},
|
| 748 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 122},
|
| 749 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 750 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 751 |
+
{"type": InternalRuleType.END},
|
| 752 |
+
],
|
| 753 |
+
[
|
| 754 |
+
{"type": InternalRuleType.CHAR, "value": [97]},
|
| 755 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 122},
|
| 756 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 48},
|
| 757 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 758 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 95},
|
| 759 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 760 |
+
{"type": InternalRuleType.ALT},
|
| 761 |
+
{"type": InternalRuleType.END},
|
| 762 |
+
],
|
| 763 |
+
[
|
| 764 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 765 |
+
{"type": InternalRuleType.END},
|
| 766 |
+
],
|
| 767 |
+
[
|
| 768 |
+
{"type": InternalRuleType.CHAR, "value": [32]},
|
| 769 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 9},
|
| 770 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 10},
|
| 771 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 772 |
+
{"type": InternalRuleType.ALT},
|
| 773 |
+
{"type": InternalRuleType.END},
|
| 774 |
+
],
|
| 775 |
+
],
|
| 776 |
+
},
|
| 777 |
+
),
|
| 778 |
+
(
|
| 779 |
+
"lots of escapes",
|
| 780 |
+
'root ::= "\\x2A" "\\u006F" "\\U0001F4A9" "\\t" "\\n" "\\r" "\\"" "\\[" "\\]" "\\\\"',
|
| 781 |
+
{
|
| 782 |
+
"symbol_ids": [("root", 0)],
|
| 783 |
+
"rules": [
|
| 784 |
+
[
|
| 785 |
+
{"type": InternalRuleType.CHAR, "value": [42]},
|
| 786 |
+
{"type": InternalRuleType.CHAR, "value": [111]},
|
| 787 |
+
{"type": InternalRuleType.CHAR, "value": [128169]},
|
| 788 |
+
{"type": InternalRuleType.CHAR, "value": [9]},
|
| 789 |
+
{"type": InternalRuleType.CHAR, "value": [10]},
|
| 790 |
+
{"type": InternalRuleType.CHAR, "value": [13]},
|
| 791 |
+
{"type": InternalRuleType.CHAR, "value": [34]},
|
| 792 |
+
{"type": InternalRuleType.CHAR, "value": [91]},
|
| 793 |
+
{"type": InternalRuleType.CHAR, "value": [93]},
|
| 794 |
+
{"type": InternalRuleType.CHAR, "value": [92]},
|
| 795 |
+
{"type": InternalRuleType.END},
|
| 796 |
+
],
|
| 797 |
+
],
|
| 798 |
+
},
|
| 799 |
+
),
|
| 800 |
+
(
|
| 801 |
+
"lots of escape and alternate escapes",
|
| 802 |
+
(
|
| 803 |
+
'root ::= "\\x2A" "\\u006F" "\\U0001F4A9" "\\t" "\\n" "\\r" "\\"" "\\[" "\\]" "\\\\" '
|
| 804 |
+
'("\\x2A" | "\\u006F" | "\\U0001F4A9" | "\\t" | "\\n" | "\\r" | "\\"" | "\\[" | "\\]" '
|
| 805 |
+
'| "\\\\" )'
|
| 806 |
+
),
|
| 807 |
+
{
|
| 808 |
+
"symbol_ids": [("root", 0), ("root_1", 1)],
|
| 809 |
+
"rules": [
|
| 810 |
+
[
|
| 811 |
+
{"type": InternalRuleType.CHAR, "value": [42]},
|
| 812 |
+
{"type": InternalRuleType.CHAR, "value": [111]},
|
| 813 |
+
{"type": InternalRuleType.CHAR, "value": [128169]},
|
| 814 |
+
{"type": InternalRuleType.CHAR, "value": [9]},
|
| 815 |
+
{"type": InternalRuleType.CHAR, "value": [10]},
|
| 816 |
+
{"type": InternalRuleType.CHAR, "value": [13]},
|
| 817 |
+
{"type": InternalRuleType.CHAR, "value": [34]},
|
| 818 |
+
{"type": InternalRuleType.CHAR, "value": [91]},
|
| 819 |
+
{"type": InternalRuleType.CHAR, "value": [93]},
|
| 820 |
+
{"type": InternalRuleType.CHAR, "value": [92]},
|
| 821 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 822 |
+
{"type": InternalRuleType.END},
|
| 823 |
+
],
|
| 824 |
+
[
|
| 825 |
+
{"type": InternalRuleType.CHAR, "value": [42]},
|
| 826 |
+
{"type": InternalRuleType.ALT},
|
| 827 |
+
{"type": InternalRuleType.CHAR, "value": [111]},
|
| 828 |
+
{"type": InternalRuleType.ALT},
|
| 829 |
+
{"type": InternalRuleType.CHAR, "value": [128169]},
|
| 830 |
+
{"type": InternalRuleType.ALT},
|
| 831 |
+
{"type": InternalRuleType.CHAR, "value": [9]},
|
| 832 |
+
{"type": InternalRuleType.ALT},
|
| 833 |
+
{"type": InternalRuleType.CHAR, "value": [10]},
|
| 834 |
+
{"type": InternalRuleType.ALT},
|
| 835 |
+
{"type": InternalRuleType.CHAR, "value": [13]},
|
| 836 |
+
{"type": InternalRuleType.ALT},
|
| 837 |
+
{"type": InternalRuleType.CHAR, "value": [34]},
|
| 838 |
+
{"type": InternalRuleType.ALT},
|
| 839 |
+
{"type": InternalRuleType.CHAR, "value": [91]},
|
| 840 |
+
{"type": InternalRuleType.ALT},
|
| 841 |
+
{"type": InternalRuleType.CHAR, "value": [93]},
|
| 842 |
+
{"type": InternalRuleType.ALT},
|
| 843 |
+
{"type": InternalRuleType.CHAR, "value": [92]},
|
| 844 |
+
{"type": InternalRuleType.END},
|
| 845 |
+
],
|
| 846 |
+
],
|
| 847 |
+
},
|
| 848 |
+
),
|
| 849 |
+
(
|
| 850 |
+
"arithmetic",
|
| 851 |
+
"""
|
| 852 |
+
root ::= (expr "=" ws term "\\n")+
|
| 853 |
+
expr ::= term ([-+*/] term)*
|
| 854 |
+
term ::= ident | num | "(" ws expr ")" ws
|
| 855 |
+
ident ::= [a-z] [a-z0-9_]* ws
|
| 856 |
+
num ::= [0-9]+ ws
|
| 857 |
+
ws ::= [ \\t\\n]*
|
| 858 |
+
""",
|
| 859 |
+
{
|
| 860 |
+
"symbol_ids": [
|
| 861 |
+
("root", 0),
|
| 862 |
+
("root_1", 1),
|
| 863 |
+
("expr", 2),
|
| 864 |
+
("ws", 3),
|
| 865 |
+
("term", 4),
|
| 866 |
+
("root_5", 5),
|
| 867 |
+
("expr_6", 6),
|
| 868 |
+
("expr_7", 7),
|
| 869 |
+
("ident", 8),
|
| 870 |
+
("num", 9),
|
| 871 |
+
("ident_10", 10),
|
| 872 |
+
("num_11", 11),
|
| 873 |
+
("ws_12", 12),
|
| 874 |
+
],
|
| 875 |
+
"rules": [
|
| 876 |
+
[
|
| 877 |
+
{"type": InternalRuleType.RULE_REF, "value": 5},
|
| 878 |
+
{"type": InternalRuleType.END},
|
| 879 |
+
],
|
| 880 |
+
[
|
| 881 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 882 |
+
{"type": InternalRuleType.CHAR, "value": [61]},
|
| 883 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 884 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 885 |
+
{"type": InternalRuleType.CHAR, "value": [10]},
|
| 886 |
+
{"type": InternalRuleType.END},
|
| 887 |
+
],
|
| 888 |
+
[
|
| 889 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 890 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 891 |
+
{"type": InternalRuleType.END},
|
| 892 |
+
],
|
| 893 |
+
[
|
| 894 |
+
{"type": InternalRuleType.RULE_REF, "value": 12},
|
| 895 |
+
{"type": InternalRuleType.END},
|
| 896 |
+
],
|
| 897 |
+
[
|
| 898 |
+
{"type": InternalRuleType.RULE_REF, "value": 8},
|
| 899 |
+
{"type": InternalRuleType.ALT},
|
| 900 |
+
{"type": InternalRuleType.RULE_REF, "value": 9},
|
| 901 |
+
{"type": InternalRuleType.ALT},
|
| 902 |
+
{"type": InternalRuleType.CHAR, "value": [40]},
|
| 903 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 904 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 905 |
+
{"type": InternalRuleType.CHAR, "value": [41]},
|
| 906 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 907 |
+
{"type": InternalRuleType.END},
|
| 908 |
+
],
|
| 909 |
+
[
|
| 910 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 911 |
+
{"type": InternalRuleType.RULE_REF, "value": 5},
|
| 912 |
+
{"type": InternalRuleType.ALT},
|
| 913 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 914 |
+
{"type": InternalRuleType.END},
|
| 915 |
+
],
|
| 916 |
+
[
|
| 917 |
+
{"type": InternalRuleType.CHAR, "value": [45]},
|
| 918 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 43},
|
| 919 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 42},
|
| 920 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 47},
|
| 921 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 922 |
+
{"type": InternalRuleType.END},
|
| 923 |
+
],
|
| 924 |
+
[
|
| 925 |
+
{"type": InternalRuleType.RULE_REF, "value": 6},
|
| 926 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 927 |
+
{"type": InternalRuleType.ALT},
|
| 928 |
+
{"type": InternalRuleType.END},
|
| 929 |
+
],
|
| 930 |
+
[
|
| 931 |
+
{"type": InternalRuleType.CHAR, "value": [97]},
|
| 932 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 122},
|
| 933 |
+
{"type": InternalRuleType.RULE_REF, "value": 10},
|
| 934 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 935 |
+
{"type": InternalRuleType.END},
|
| 936 |
+
],
|
| 937 |
+
[
|
| 938 |
+
{"type": InternalRuleType.RULE_REF, "value": 11},
|
| 939 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 940 |
+
{"type": InternalRuleType.END},
|
| 941 |
+
],
|
| 942 |
+
[
|
| 943 |
+
{"type": InternalRuleType.CHAR, "value": [97]},
|
| 944 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 122},
|
| 945 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 48},
|
| 946 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 947 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 95},
|
| 948 |
+
{"type": InternalRuleType.RULE_REF, "value": 10},
|
| 949 |
+
{"type": InternalRuleType.ALT},
|
| 950 |
+
{"type": InternalRuleType.END},
|
| 951 |
+
],
|
| 952 |
+
[
|
| 953 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 954 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 955 |
+
{"type": InternalRuleType.RULE_REF, "value": 11},
|
| 956 |
+
{"type": InternalRuleType.ALT},
|
| 957 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 958 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 959 |
+
{"type": InternalRuleType.END},
|
| 960 |
+
],
|
| 961 |
+
[
|
| 962 |
+
{"type": InternalRuleType.CHAR, "value": [32]},
|
| 963 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 9},
|
| 964 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 10},
|
| 965 |
+
{"type": InternalRuleType.RULE_REF, "value": 12},
|
| 966 |
+
{"type": InternalRuleType.ALT},
|
| 967 |
+
{"type": InternalRuleType.END},
|
| 968 |
+
],
|
| 969 |
+
],
|
| 970 |
+
},
|
| 971 |
+
),
|
| 972 |
+
(
|
| 973 |
+
"json.gbnf (string)",
|
| 974 |
+
"""
|
| 975 |
+
root ::=
|
| 976 |
+
"\\"" (
|
| 977 |
+
[^"\\\\\x7f\\x00-\\x1F] |
|
| 978 |
+
"\\\\" (["\\\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
|
| 979 |
+
)* "\\""
|
| 980 |
+
""",
|
| 981 |
+
{
|
| 982 |
+
"symbol_ids": [("root", 0), ("root_1", 1), ("root_2", 2), ("root_3", 3)],
|
| 983 |
+
"rules": [
|
| 984 |
+
[
|
| 985 |
+
{"type": InternalRuleType.CHAR, "value": [34]},
|
| 986 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 987 |
+
{"type": InternalRuleType.CHAR, "value": [34]},
|
| 988 |
+
{"type": InternalRuleType.END},
|
| 989 |
+
],
|
| 990 |
+
[
|
| 991 |
+
{"type": InternalRuleType.CHAR_NOT, "value": [34]},
|
| 992 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 92},
|
| 993 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 127},
|
| 994 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 0},
|
| 995 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 31},
|
| 996 |
+
{"type": InternalRuleType.ALT},
|
| 997 |
+
{"type": InternalRuleType.CHAR, "value": [92]},
|
| 998 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 999 |
+
{"type": InternalRuleType.END},
|
| 1000 |
+
],
|
| 1001 |
+
[
|
| 1002 |
+
{"type": InternalRuleType.CHAR, "value": [34]},
|
| 1003 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 92},
|
| 1004 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 47},
|
| 1005 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 98},
|
| 1006 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 102},
|
| 1007 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 110},
|
| 1008 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 114},
|
| 1009 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 116},
|
| 1010 |
+
{"type": InternalRuleType.ALT},
|
| 1011 |
+
{"type": InternalRuleType.CHAR, "value": [117]},
|
| 1012 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1013 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1014 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 97},
|
| 1015 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 102},
|
| 1016 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 65},
|
| 1017 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 70},
|
| 1018 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1019 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1020 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 97},
|
| 1021 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 102},
|
| 1022 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 65},
|
| 1023 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 70},
|
| 1024 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1025 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1026 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 97},
|
| 1027 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 102},
|
| 1028 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 65},
|
| 1029 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 70},
|
| 1030 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1031 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1032 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 97},
|
| 1033 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 102},
|
| 1034 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 65},
|
| 1035 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 70},
|
| 1036 |
+
{"type": InternalRuleType.END},
|
| 1037 |
+
],
|
| 1038 |
+
[
|
| 1039 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 1040 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 1041 |
+
{"type": InternalRuleType.ALT},
|
| 1042 |
+
{"type": InternalRuleType.END},
|
| 1043 |
+
],
|
| 1044 |
+
],
|
| 1045 |
+
},
|
| 1046 |
+
),
|
| 1047 |
+
(
|
| 1048 |
+
"json.gbnf (full)",
|
| 1049 |
+
"""
|
| 1050 |
+
root ::= object
|
| 1051 |
+
value ::= object | array | string | number | ("true" | "false" | "null") ws
|
| 1052 |
+
|
| 1053 |
+
object ::=
|
| 1054 |
+
"{" ws (
|
| 1055 |
+
string ":" ws value
|
| 1056 |
+
("," ws string ":" ws value)*
|
| 1057 |
+
)? "}" ws
|
| 1058 |
+
|
| 1059 |
+
array ::=
|
| 1060 |
+
"[" ws (
|
| 1061 |
+
value
|
| 1062 |
+
("," ws value)*
|
| 1063 |
+
)? "]" ws
|
| 1064 |
+
|
| 1065 |
+
string ::=
|
| 1066 |
+
"\\"" (
|
| 1067 |
+
[^"\\\\\x7f\\x00-\\x1F] |
|
| 1068 |
+
"\\\\" (["\\\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
|
| 1069 |
+
)* "\\"" ws
|
| 1070 |
+
|
| 1071 |
+
number ::= ("-"? ([0-9] | [1-9] [0-9]*)) ("." [0-9]+)? ([eE] [-+]? [0-9]+)? ws
|
| 1072 |
+
|
| 1073 |
+
# Optional space: by convention, applied in this grammar after literal chars when allowed
|
| 1074 |
+
ws ::= ([ \\t\\n] ws)?
|
| 1075 |
+
|
| 1076 |
+
""",
|
| 1077 |
+
{
|
| 1078 |
+
"symbol_ids": [
|
| 1079 |
+
("root", 0),
|
| 1080 |
+
("object", 1),
|
| 1081 |
+
("value", 2),
|
| 1082 |
+
("array", 3),
|
| 1083 |
+
("string", 4),
|
| 1084 |
+
("number", 5),
|
| 1085 |
+
("value_6", 6),
|
| 1086 |
+
("ws", 7),
|
| 1087 |
+
("object_8", 8),
|
| 1088 |
+
("object_9", 9),
|
| 1089 |
+
("object_10", 10),
|
| 1090 |
+
("object_11", 11),
|
| 1091 |
+
("array_12", 12),
|
| 1092 |
+
("array_13", 13),
|
| 1093 |
+
("array_14", 14),
|
| 1094 |
+
("array_15", 15),
|
| 1095 |
+
("string_16", 16),
|
| 1096 |
+
("string_17", 17),
|
| 1097 |
+
("string_18", 18),
|
| 1098 |
+
("number_19", 19),
|
| 1099 |
+
("number_20", 20),
|
| 1100 |
+
("number_21", 21),
|
| 1101 |
+
("number_22", 22),
|
| 1102 |
+
("number_23", 23),
|
| 1103 |
+
("number_24", 24),
|
| 1104 |
+
("number_25", 25),
|
| 1105 |
+
("number_26", 26),
|
| 1106 |
+
("number_27", 27),
|
| 1107 |
+
("number_28", 28),
|
| 1108 |
+
("number_29", 29),
|
| 1109 |
+
("ws_30", 30),
|
| 1110 |
+
("ws_31", 31),
|
| 1111 |
+
],
|
| 1112 |
+
"rules": [
|
| 1113 |
+
[
|
| 1114 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 1115 |
+
{"type": InternalRuleType.END},
|
| 1116 |
+
],
|
| 1117 |
+
[
|
| 1118 |
+
{"type": InternalRuleType.CHAR, "value": [123]},
|
| 1119 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1120 |
+
{"type": InternalRuleType.RULE_REF, "value": 11},
|
| 1121 |
+
{"type": InternalRuleType.CHAR, "value": [125]},
|
| 1122 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1123 |
+
{"type": InternalRuleType.END},
|
| 1124 |
+
],
|
| 1125 |
+
[
|
| 1126 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 1127 |
+
{"type": InternalRuleType.ALT},
|
| 1128 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 1129 |
+
{"type": InternalRuleType.ALT},
|
| 1130 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 1131 |
+
{"type": InternalRuleType.ALT},
|
| 1132 |
+
{"type": InternalRuleType.RULE_REF, "value": 5},
|
| 1133 |
+
{"type": InternalRuleType.ALT},
|
| 1134 |
+
{"type": InternalRuleType.RULE_REF, "value": 6},
|
| 1135 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1136 |
+
{"type": InternalRuleType.END},
|
| 1137 |
+
],
|
| 1138 |
+
[
|
| 1139 |
+
{"type": InternalRuleType.CHAR, "value": [91]},
|
| 1140 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1141 |
+
{"type": InternalRuleType.RULE_REF, "value": 15},
|
| 1142 |
+
{"type": InternalRuleType.CHAR, "value": [93]},
|
| 1143 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1144 |
+
{"type": InternalRuleType.END},
|
| 1145 |
+
],
|
| 1146 |
+
[
|
| 1147 |
+
{"type": InternalRuleType.CHAR, "value": [34]},
|
| 1148 |
+
{"type": InternalRuleType.RULE_REF, "value": 18},
|
| 1149 |
+
{"type": InternalRuleType.CHAR, "value": [34]},
|
| 1150 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1151 |
+
{"type": InternalRuleType.END},
|
| 1152 |
+
],
|
| 1153 |
+
[
|
| 1154 |
+
{"type": InternalRuleType.RULE_REF, "value": 19},
|
| 1155 |
+
{"type": InternalRuleType.RULE_REF, "value": 25},
|
| 1156 |
+
{"type": InternalRuleType.RULE_REF, "value": 29},
|
| 1157 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1158 |
+
{"type": InternalRuleType.END},
|
| 1159 |
+
],
|
| 1160 |
+
[
|
| 1161 |
+
{"type": InternalRuleType.CHAR, "value": [116]},
|
| 1162 |
+
{"type": InternalRuleType.CHAR, "value": [114]},
|
| 1163 |
+
{"type": InternalRuleType.CHAR, "value": [117]},
|
| 1164 |
+
{"type": InternalRuleType.CHAR, "value": [101]},
|
| 1165 |
+
{"type": InternalRuleType.ALT},
|
| 1166 |
+
{"type": InternalRuleType.CHAR, "value": [102]},
|
| 1167 |
+
{"type": InternalRuleType.CHAR, "value": [97]},
|
| 1168 |
+
{"type": InternalRuleType.CHAR, "value": [108]},
|
| 1169 |
+
{"type": InternalRuleType.CHAR, "value": [115]},
|
| 1170 |
+
{"type": InternalRuleType.CHAR, "value": [101]},
|
| 1171 |
+
{"type": InternalRuleType.ALT},
|
| 1172 |
+
{"type": InternalRuleType.CHAR, "value": [110]},
|
| 1173 |
+
{"type": InternalRuleType.CHAR, "value": [117]},
|
| 1174 |
+
{"type": InternalRuleType.CHAR, "value": [108]},
|
| 1175 |
+
{"type": InternalRuleType.CHAR, "value": [108]},
|
| 1176 |
+
{"type": InternalRuleType.END},
|
| 1177 |
+
],
|
| 1178 |
+
[
|
| 1179 |
+
{"type": InternalRuleType.RULE_REF, "value": 31},
|
| 1180 |
+
{"type": InternalRuleType.END},
|
| 1181 |
+
],
|
| 1182 |
+
[
|
| 1183 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 1184 |
+
{"type": InternalRuleType.CHAR, "value": [58]},
|
| 1185 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1186 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 1187 |
+
{"type": InternalRuleType.RULE_REF, "value": 10},
|
| 1188 |
+
{"type": InternalRuleType.END},
|
| 1189 |
+
],
|
| 1190 |
+
[
|
| 1191 |
+
{"type": InternalRuleType.CHAR, "value": [44]},
|
| 1192 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1193 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 1194 |
+
{"type": InternalRuleType.CHAR, "value": [58]},
|
| 1195 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1196 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 1197 |
+
{"type": InternalRuleType.END},
|
| 1198 |
+
],
|
| 1199 |
+
[
|
| 1200 |
+
{"type": InternalRuleType.RULE_REF, "value": 9},
|
| 1201 |
+
{"type": InternalRuleType.RULE_REF, "value": 10},
|
| 1202 |
+
{"type": InternalRuleType.ALT},
|
| 1203 |
+
{"type": InternalRuleType.END},
|
| 1204 |
+
],
|
| 1205 |
+
[
|
| 1206 |
+
{"type": InternalRuleType.RULE_REF, "value": 8},
|
| 1207 |
+
{"type": InternalRuleType.ALT},
|
| 1208 |
+
{"type": InternalRuleType.END},
|
| 1209 |
+
],
|
| 1210 |
+
[
|
| 1211 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 1212 |
+
{"type": InternalRuleType.RULE_REF, "value": 14},
|
| 1213 |
+
{"type": InternalRuleType.END},
|
| 1214 |
+
],
|
| 1215 |
+
[
|
| 1216 |
+
{"type": InternalRuleType.CHAR, "value": [44]},
|
| 1217 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1218 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 1219 |
+
{"type": InternalRuleType.END},
|
| 1220 |
+
],
|
| 1221 |
+
[
|
| 1222 |
+
{"type": InternalRuleType.RULE_REF, "value": 13},
|
| 1223 |
+
{"type": InternalRuleType.RULE_REF, "value": 14},
|
| 1224 |
+
{"type": InternalRuleType.ALT},
|
| 1225 |
+
{"type": InternalRuleType.END},
|
| 1226 |
+
],
|
| 1227 |
+
[
|
| 1228 |
+
{"type": InternalRuleType.RULE_REF, "value": 12},
|
| 1229 |
+
{"type": InternalRuleType.ALT},
|
| 1230 |
+
{"type": InternalRuleType.END},
|
| 1231 |
+
],
|
| 1232 |
+
[
|
| 1233 |
+
{"type": InternalRuleType.CHAR_NOT, "value": [34]},
|
| 1234 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 92},
|
| 1235 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 127},
|
| 1236 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 0},
|
| 1237 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 31},
|
| 1238 |
+
{"type": InternalRuleType.ALT},
|
| 1239 |
+
{"type": InternalRuleType.CHAR, "value": [92]},
|
| 1240 |
+
{"type": InternalRuleType.RULE_REF, "value": 17},
|
| 1241 |
+
{"type": InternalRuleType.END},
|
| 1242 |
+
],
|
| 1243 |
+
[
|
| 1244 |
+
{"type": InternalRuleType.CHAR, "value": [34]},
|
| 1245 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 92},
|
| 1246 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 47},
|
| 1247 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 98},
|
| 1248 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 102},
|
| 1249 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 110},
|
| 1250 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 114},
|
| 1251 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 116},
|
| 1252 |
+
{"type": InternalRuleType.ALT},
|
| 1253 |
+
{"type": InternalRuleType.CHAR, "value": [117]},
|
| 1254 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1255 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1256 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 97},
|
| 1257 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 102},
|
| 1258 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 65},
|
| 1259 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 70},
|
| 1260 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1261 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1262 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 97},
|
| 1263 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 102},
|
| 1264 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 65},
|
| 1265 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 70},
|
| 1266 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1267 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1268 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 97},
|
| 1269 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 102},
|
| 1270 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 65},
|
| 1271 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 70},
|
| 1272 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1273 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1274 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 97},
|
| 1275 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 102},
|
| 1276 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 65},
|
| 1277 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 70},
|
| 1278 |
+
{"type": InternalRuleType.END},
|
| 1279 |
+
],
|
| 1280 |
+
[
|
| 1281 |
+
{"type": InternalRuleType.RULE_REF, "value": 16},
|
| 1282 |
+
{"type": InternalRuleType.RULE_REF, "value": 18},
|
| 1283 |
+
{"type": InternalRuleType.ALT},
|
| 1284 |
+
{"type": InternalRuleType.END},
|
| 1285 |
+
],
|
| 1286 |
+
[
|
| 1287 |
+
{"type": InternalRuleType.RULE_REF, "value": 20},
|
| 1288 |
+
{"type": InternalRuleType.RULE_REF, "value": 21},
|
| 1289 |
+
{"type": InternalRuleType.END},
|
| 1290 |
+
],
|
| 1291 |
+
[
|
| 1292 |
+
{"type": InternalRuleType.CHAR, "value": [45]},
|
| 1293 |
+
{"type": InternalRuleType.ALT},
|
| 1294 |
+
{"type": InternalRuleType.END},
|
| 1295 |
+
],
|
| 1296 |
+
[
|
| 1297 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1298 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1299 |
+
{"type": InternalRuleType.ALT},
|
| 1300 |
+
{"type": InternalRuleType.CHAR, "value": [49]},
|
| 1301 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1302 |
+
{"type": InternalRuleType.RULE_REF, "value": 22},
|
| 1303 |
+
{"type": InternalRuleType.END},
|
| 1304 |
+
],
|
| 1305 |
+
[
|
| 1306 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1307 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1308 |
+
{"type": InternalRuleType.RULE_REF, "value": 22},
|
| 1309 |
+
{"type": InternalRuleType.ALT},
|
| 1310 |
+
{"type": InternalRuleType.END},
|
| 1311 |
+
],
|
| 1312 |
+
[
|
| 1313 |
+
{"type": InternalRuleType.CHAR, "value": [46]},
|
| 1314 |
+
{"type": InternalRuleType.RULE_REF, "value": 24},
|
| 1315 |
+
{"type": InternalRuleType.END},
|
| 1316 |
+
],
|
| 1317 |
+
[
|
| 1318 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1319 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1320 |
+
{"type": InternalRuleType.RULE_REF, "value": 24},
|
| 1321 |
+
{"type": InternalRuleType.ALT},
|
| 1322 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1323 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1324 |
+
{"type": InternalRuleType.END},
|
| 1325 |
+
],
|
| 1326 |
+
[
|
| 1327 |
+
{"type": InternalRuleType.RULE_REF, "value": 23},
|
| 1328 |
+
{"type": InternalRuleType.ALT},
|
| 1329 |
+
{"type": InternalRuleType.END},
|
| 1330 |
+
],
|
| 1331 |
+
[
|
| 1332 |
+
{"type": InternalRuleType.CHAR, "value": [101]},
|
| 1333 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 69},
|
| 1334 |
+
{"type": InternalRuleType.RULE_REF, "value": 27},
|
| 1335 |
+
{"type": InternalRuleType.RULE_REF, "value": 28},
|
| 1336 |
+
{"type": InternalRuleType.END},
|
| 1337 |
+
],
|
| 1338 |
+
[
|
| 1339 |
+
{"type": InternalRuleType.CHAR, "value": [45]},
|
| 1340 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 43},
|
| 1341 |
+
{"type": InternalRuleType.ALT},
|
| 1342 |
+
{"type": InternalRuleType.END},
|
| 1343 |
+
],
|
| 1344 |
+
[
|
| 1345 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1346 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1347 |
+
{"type": InternalRuleType.RULE_REF, "value": 28},
|
| 1348 |
+
{"type": InternalRuleType.ALT},
|
| 1349 |
+
{"type": InternalRuleType.CHAR, "value": [48]},
|
| 1350 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 57},
|
| 1351 |
+
{"type": InternalRuleType.END},
|
| 1352 |
+
],
|
| 1353 |
+
[
|
| 1354 |
+
{"type": InternalRuleType.RULE_REF, "value": 26},
|
| 1355 |
+
{"type": InternalRuleType.ALT},
|
| 1356 |
+
{"type": InternalRuleType.END},
|
| 1357 |
+
],
|
| 1358 |
+
[
|
| 1359 |
+
{"type": InternalRuleType.CHAR, "value": [32]},
|
| 1360 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 9},
|
| 1361 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 10},
|
| 1362 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1363 |
+
{"type": InternalRuleType.END},
|
| 1364 |
+
],
|
| 1365 |
+
[
|
| 1366 |
+
{"type": InternalRuleType.RULE_REF, "value": 30},
|
| 1367 |
+
{"type": InternalRuleType.ALT},
|
| 1368 |
+
{"type": InternalRuleType.END},
|
| 1369 |
+
],
|
| 1370 |
+
],
|
| 1371 |
+
},
|
| 1372 |
+
),
|
| 1373 |
+
(
|
| 1374 |
+
"japanese",
|
| 1375 |
+
"""
|
| 1376 |
+
# A probably incorrect grammar for Japanese
|
| 1377 |
+
root ::= jp-char+ ([ \\t\\n] jp-char+)*
|
| 1378 |
+
jp-char ::= hiragana | katakana | punctuation | cjk
|
| 1379 |
+
hiragana ::= [ぁ-ゟ]
|
| 1380 |
+
katakana ::= [ァ-ヿ]
|
| 1381 |
+
punctuation ::= [、-〾]
|
| 1382 |
+
cjk ::= [一-鿿]
|
| 1383 |
+
|
| 1384 |
+
""",
|
| 1385 |
+
{
|
| 1386 |
+
"symbol_ids": [
|
| 1387 |
+
("root", 0),
|
| 1388 |
+
("jp-char", 1),
|
| 1389 |
+
("root_2", 2),
|
| 1390 |
+
("root_3", 3),
|
| 1391 |
+
("root_4", 4),
|
| 1392 |
+
("root_5", 5),
|
| 1393 |
+
("hiragana", 6),
|
| 1394 |
+
("katakana", 7),
|
| 1395 |
+
("punctuation", 8),
|
| 1396 |
+
("cjk", 9),
|
| 1397 |
+
],
|
| 1398 |
+
"rules": [
|
| 1399 |
+
[
|
| 1400 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 1401 |
+
{"type": InternalRuleType.RULE_REF, "value": 5},
|
| 1402 |
+
{"type": InternalRuleType.END},
|
| 1403 |
+
],
|
| 1404 |
+
[
|
| 1405 |
+
{"type": InternalRuleType.RULE_REF, "value": 6},
|
| 1406 |
+
{"type": InternalRuleType.ALT},
|
| 1407 |
+
{"type": InternalRuleType.RULE_REF, "value": 7},
|
| 1408 |
+
{"type": InternalRuleType.ALT},
|
| 1409 |
+
{"type": InternalRuleType.RULE_REF, "value": 8},
|
| 1410 |
+
{"type": InternalRuleType.ALT},
|
| 1411 |
+
{"type": InternalRuleType.RULE_REF, "value": 9},
|
| 1412 |
+
{"type": InternalRuleType.END},
|
| 1413 |
+
],
|
| 1414 |
+
[
|
| 1415 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 1416 |
+
{"type": InternalRuleType.RULE_REF, "value": 2},
|
| 1417 |
+
{"type": InternalRuleType.ALT},
|
| 1418 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 1419 |
+
{"type": InternalRuleType.END},
|
| 1420 |
+
],
|
| 1421 |
+
[
|
| 1422 |
+
{"type": InternalRuleType.CHAR, "value": [32]},
|
| 1423 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 9},
|
| 1424 |
+
{"type": InternalRuleType.CHAR_ALT, "value": 10},
|
| 1425 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 1426 |
+
{"type": InternalRuleType.END},
|
| 1427 |
+
],
|
| 1428 |
+
[
|
| 1429 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 1430 |
+
{"type": InternalRuleType.RULE_REF, "value": 4},
|
| 1431 |
+
{"type": InternalRuleType.ALT},
|
| 1432 |
+
{"type": InternalRuleType.RULE_REF, "value": 1},
|
| 1433 |
+
{"type": InternalRuleType.END},
|
| 1434 |
+
],
|
| 1435 |
+
[
|
| 1436 |
+
{"type": InternalRuleType.RULE_REF, "value": 3},
|
| 1437 |
+
{"type": InternalRuleType.RULE_REF, "value": 5},
|
| 1438 |
+
{"type": InternalRuleType.ALT},
|
| 1439 |
+
{"type": InternalRuleType.END},
|
| 1440 |
+
],
|
| 1441 |
+
[
|
| 1442 |
+
{"type": InternalRuleType.CHAR, "value": [12353]},
|
| 1443 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 12447},
|
| 1444 |
+
{"type": InternalRuleType.END},
|
| 1445 |
+
],
|
| 1446 |
+
[
|
| 1447 |
+
{"type": InternalRuleType.CHAR, "value": [12449]},
|
| 1448 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 12543},
|
| 1449 |
+
{"type": InternalRuleType.END},
|
| 1450 |
+
],
|
| 1451 |
+
[
|
| 1452 |
+
{"type": InternalRuleType.CHAR, "value": [12289]},
|
| 1453 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 12350},
|
| 1454 |
+
{"type": InternalRuleType.END},
|
| 1455 |
+
],
|
| 1456 |
+
[
|
| 1457 |
+
{"type": InternalRuleType.CHAR, "value": [19968]},
|
| 1458 |
+
{"type": InternalRuleType.CHAR_RNG_UPPER, "value": 40959},
|
| 1459 |
+
{"type": InternalRuleType.END},
|
| 1460 |
+
],
|
| 1461 |
+
],
|
| 1462 |
+
},
|
| 1463 |
+
),
|
| 1464 |
+
]
|
| 1465 |
+
|
| 1466 |
+
|
| 1467 |
+
def describe_grammar_parser_tests():
|
| 1468 |
+
@pytest.mark.parametrize(
|
| 1469 |
+
("_key", "grammar", "expected"),
|
| 1470 |
+
[
|
| 1471 |
+
(key, "\\n".join(line.strip() for line in grammar.split("\n")), expected)
|
| 1472 |
+
for key, grammar, expected in TEST_CASES
|
| 1473 |
+
],
|
| 1474 |
+
)
|
| 1475 |
+
def it_parses_grammar(_key, grammar, expected):
|
| 1476 |
+
parsed_grammar = RulesBuilder(grammar.replace("\\n", "\n"))
|
| 1477 |
+
assert parsed_grammar.rules == expected["rules"]
|
| 1478 |
+
assert list(parsed_grammar.symbol_ids) == expected["symbol_ids"]
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/symbol_ids.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Iterator, KeysView
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class SymbolIds:
|
| 5 |
+
def __init__(self) -> None:
|
| 6 |
+
# we don't need to delete, just preserve relationships
|
| 7 |
+
self._map: dict[str, int] = {}
|
| 8 |
+
self._pos: dict[str, int] = {}
|
| 9 |
+
self._reverse_map: dict[int, str] = {}
|
| 10 |
+
|
| 11 |
+
def __len__(self) -> int:
|
| 12 |
+
return len(self._map)
|
| 13 |
+
|
| 14 |
+
def keys(self) -> KeysView[str]:
|
| 15 |
+
return self._map.keys()
|
| 16 |
+
|
| 17 |
+
def has(self, key: str) -> bool:
|
| 18 |
+
return key in self._map
|
| 19 |
+
|
| 20 |
+
def get(self, key: str) -> int:
|
| 21 |
+
val = self._map.get(key)
|
| 22 |
+
if val is None:
|
| 23 |
+
raise KeyError(f"SymbolIds does not contain key: {key}")
|
| 24 |
+
return val
|
| 25 |
+
|
| 26 |
+
def reverse_get(self, key: int) -> str:
|
| 27 |
+
val = self._reverse_map.get(key)
|
| 28 |
+
if val is None:
|
| 29 |
+
raise KeyError(f"SymbolIds does not contain value: {key}")
|
| 30 |
+
return val
|
| 31 |
+
|
| 32 |
+
def get_pos(self, key: str) -> int:
|
| 33 |
+
pos = self._pos.get(key)
|
| 34 |
+
if pos is None:
|
| 35 |
+
raise KeyError(f"SymbolIds does not contain key: {key}")
|
| 36 |
+
return pos
|
| 37 |
+
|
| 38 |
+
def set(self, key: str, value: int, pos: int) -> None:
|
| 39 |
+
self._map[key] = value
|
| 40 |
+
self._pos[key] = pos
|
| 41 |
+
self._reverse_map[value] = key
|
| 42 |
+
|
| 43 |
+
def __iter__(self) -> Iterator[tuple[str, int]]:
|
| 44 |
+
yield from self._map.items()
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/type_guards.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import TypeGuard
|
| 2 |
+
|
| 3 |
+
from .types import (
|
| 4 |
+
InternalRuleDef,
|
| 5 |
+
InternalRuleDefAlt,
|
| 6 |
+
InternalRuleDefChar,
|
| 7 |
+
InternalRuleDefCharAlt,
|
| 8 |
+
InternalRuleDefCharNot,
|
| 9 |
+
InternalRuleDefCharRngUpper,
|
| 10 |
+
InternalRuleDefEnd,
|
| 11 |
+
InternalRuleDefReference,
|
| 12 |
+
InternalRuleType,
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def is_rule_def_type(type_: object = None) -> TypeGuard[InternalRuleType]:
|
| 17 |
+
return bool(type_) and type_ in InternalRuleType
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def is_rule_def(rule: object = None) -> TypeGuard[InternalRuleDef]:
|
| 21 |
+
return isinstance(rule, dict) and is_rule_def_type(rule.get("type"))
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def is_rule_def_alt(rule: InternalRuleDef | None = None) -> TypeGuard[InternalRuleDefAlt]:
|
| 25 |
+
return rule is not None and rule.get("type") == InternalRuleType.ALT
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def is_rule_def_ref(rule: InternalRuleDef | None = None) -> TypeGuard[InternalRuleDefReference]:
|
| 29 |
+
return rule is not None and rule.get("type") == InternalRuleType.RULE_REF
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def is_rule_def_end(rule: InternalRuleDef | None = None) -> TypeGuard[InternalRuleDefEnd]:
|
| 33 |
+
return rule is not None and rule.get("type") == InternalRuleType.END
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def is_rule_def_char(rule: InternalRuleDef | None = None) -> TypeGuard[InternalRuleDefChar]:
|
| 37 |
+
return rule is not None and rule.get("type") == InternalRuleType.CHAR
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def is_rule_def_char_not(
|
| 41 |
+
rule: InternalRuleDef | None = None,
|
| 42 |
+
) -> TypeGuard[InternalRuleDefCharNot]:
|
| 43 |
+
return rule is not None and rule.get("type") == InternalRuleType.CHAR_NOT
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def is_rule_def_char_alt(
|
| 47 |
+
rule: InternalRuleDef | None = None,
|
| 48 |
+
) -> TypeGuard[InternalRuleDefCharAlt]:
|
| 49 |
+
return rule is not None and rule.get("type") == InternalRuleType.CHAR_ALT
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def is_rule_def_char_rng_upper(
|
| 53 |
+
rule: InternalRuleDef | None = None,
|
| 54 |
+
) -> TypeGuard[InternalRuleDefCharRngUpper]:
|
| 55 |
+
return rule is not None and rule.get("type") == InternalRuleType.CHAR_RNG_UPPER
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/types.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from enum import StrEnum
|
| 2 |
+
from typing import Literal, TypedDict
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class InternalRuleType(StrEnum):
|
| 6 |
+
CHAR = "CHAR"
|
| 7 |
+
CHAR_RNG_UPPER = "CHAR_RNG_UPPER"
|
| 8 |
+
RULE_REF = "RULE_REF"
|
| 9 |
+
ALT = "ALT"
|
| 10 |
+
END = "END"
|
| 11 |
+
|
| 12 |
+
CHAR_NOT = "CHAR_NOT"
|
| 13 |
+
CHAR_ALT = "CHAR_ALT"
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class InternalRuleDefWithNumericValue(TypedDict):
|
| 17 |
+
type: Literal[
|
| 18 |
+
InternalRuleType.RULE_REF,
|
| 19 |
+
InternalRuleType.CHAR_ALT,
|
| 20 |
+
InternalRuleType.CHAR_RNG_UPPER,
|
| 21 |
+
]
|
| 22 |
+
value: int
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class InternalRuleDefChar(TypedDict):
|
| 26 |
+
type: Literal[InternalRuleType.CHAR]
|
| 27 |
+
value: list[int]
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class InternalRuleDefCharNot(TypedDict):
|
| 31 |
+
type: Literal[InternalRuleType.CHAR_NOT]
|
| 32 |
+
value: list[int]
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class InternalRuleDefCharAlt(TypedDict):
|
| 36 |
+
type: Literal[InternalRuleType.CHAR_ALT]
|
| 37 |
+
value: int
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class InternalRuleDefCharRngUpper(TypedDict):
|
| 41 |
+
type: Literal[InternalRuleType.CHAR_RNG_UPPER]
|
| 42 |
+
value: int
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
class InternalRuleDefReference(TypedDict):
|
| 46 |
+
type: Literal[InternalRuleType.RULE_REF]
|
| 47 |
+
value: int
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class InternalRuleDefAlt(TypedDict):
|
| 51 |
+
type: Literal[InternalRuleType.ALT]
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
class InternalRuleDefEnd(TypedDict):
|
| 55 |
+
type: Literal[InternalRuleType.END]
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class InternalRuleDefWithoutValue(TypedDict):
|
| 59 |
+
type: Literal[InternalRuleType.ALT, InternalRuleType.END]
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
type InternalRuleDef = (
|
| 63 |
+
InternalRuleDefChar
|
| 64 |
+
| InternalRuleDefCharNot
|
| 65 |
+
| InternalRuleDefWithNumericValue
|
| 66 |
+
| InternalRuleDefWithoutValue
|
| 67 |
+
)
|
| 68 |
+
type InternalRuleDefCharOrAltChar = InternalRuleDefChar | InternalRuleDefCharAlt
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/rules_builder/whitespace.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The characters that count as white space in the reference implementation
|
| 2 |
+
# (JavaScript's \s, which is also what parseInt skips); str.isspace() differs slightly.
|
| 3 |
+
WHITESPACE = (
|
| 4 |
+
"\t\n\v\f\r \xa0\u1680"
|
| 5 |
+
"\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a"
|
| 6 |
+
"\u2028\u2029\u202f\u205f\u3000\ufeff"
|
| 7 |
+
)
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/__init__.py
ADDED
|
File without changes
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/__init__.py
ADDED
|
File without changes
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/build_error_position.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MAXIMUM_NUMBER_OF_ERROR_LINES_TO_SHOW = 3
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def build_error_position(src: str, pos: int) -> list[str]:
|
| 5 |
+
if src == "":
|
| 6 |
+
return ["No input provided"]
|
| 7 |
+
|
| 8 |
+
lines = src.split("\n")
|
| 9 |
+
|
| 10 |
+
line_idx = 0
|
| 11 |
+
while line_idx < len(lines) and lines[line_idx] and pos > len(lines[line_idx]) - 1:
|
| 12 |
+
pos -= len(lines[line_idx])
|
| 13 |
+
line_idx += 1
|
| 14 |
+
|
| 15 |
+
lines_to_show = [
|
| 16 |
+
# a position past the last line leaves an empty line above the caret
|
| 17 |
+
lines[i] if i < len(lines) else ""
|
| 18 |
+
for i in range(max(0, line_idx - (MAXIMUM_NUMBER_OF_ERROR_LINES_TO_SHOW - 1)), line_idx + 1)
|
| 19 |
+
]
|
| 20 |
+
return [
|
| 21 |
+
*lines_to_show,
|
| 22 |
+
" " * pos + "^",
|
| 23 |
+
]
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/build_error_position_test.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from gbnf.utils.errors.build_error_position import build_error_position
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def describe_build_error_position():
|
| 7 |
+
@pytest.mark.parametrize(
|
| 8 |
+
("grammar", "pos", "expected"),
|
| 9 |
+
[
|
| 10 |
+
(
|
| 11 |
+
'root ::= "foo"',
|
| 12 |
+
1,
|
| 13 |
+
[
|
| 14 |
+
'root ::= "foo"',
|
| 15 |
+
" ^",
|
| 16 |
+
],
|
| 17 |
+
),
|
| 18 |
+
(
|
| 19 |
+
'root ::= "foo"',
|
| 20 |
+
5,
|
| 21 |
+
[
|
| 22 |
+
'root ::= "foo"',
|
| 23 |
+
" ^",
|
| 24 |
+
],
|
| 25 |
+
),
|
| 26 |
+
# multi line grammars with pos on first line
|
| 27 |
+
(
|
| 28 |
+
"aa\\nbb",
|
| 29 |
+
1,
|
| 30 |
+
[
|
| 31 |
+
"aa",
|
| 32 |
+
" ^",
|
| 33 |
+
],
|
| 34 |
+
),
|
| 35 |
+
# multi line grammars with pos on second line, first character
|
| 36 |
+
(
|
| 37 |
+
"aa\\nbb",
|
| 38 |
+
2,
|
| 39 |
+
[
|
| 40 |
+
"aa\\nbb",
|
| 41 |
+
"^",
|
| 42 |
+
],
|
| 43 |
+
),
|
| 44 |
+
# multi line grammars with pos on second line, second character
|
| 45 |
+
(
|
| 46 |
+
"aa\\nbb",
|
| 47 |
+
2 + 1,
|
| 48 |
+
[
|
| 49 |
+
"aa\\nbb",
|
| 50 |
+
" ^",
|
| 51 |
+
],
|
| 52 |
+
),
|
| 53 |
+
# multi line grammars beyond error with pos on second line
|
| 54 |
+
(
|
| 55 |
+
"aa\\nbb\\ncc",
|
| 56 |
+
2 + 1,
|
| 57 |
+
[
|
| 58 |
+
"aa\\nbb",
|
| 59 |
+
" ^",
|
| 60 |
+
],
|
| 61 |
+
),
|
| 62 |
+
# multi line grammars beyond error with pos on third line, first char
|
| 63 |
+
(
|
| 64 |
+
"aa\\nbb\\ncc",
|
| 65 |
+
2 + 2 + 0,
|
| 66 |
+
[
|
| 67 |
+
"aa\\nbb\\ncc",
|
| 68 |
+
"^",
|
| 69 |
+
],
|
| 70 |
+
),
|
| 71 |
+
# multi line grammars beyond error with pos on third line, second char
|
| 72 |
+
(
|
| 73 |
+
"aa\\nbb\\ncc",
|
| 74 |
+
2 + 2 + 1,
|
| 75 |
+
[
|
| 76 |
+
"aa\\nbb\\ncc",
|
| 77 |
+
" ^",
|
| 78 |
+
],
|
| 79 |
+
),
|
| 80 |
+
# multi line grammars beyond error with pos on fourth line, first char
|
| 81 |
+
(
|
| 82 |
+
"aa\\nbb\\ncc\\ndd",
|
| 83 |
+
2 + 2 + 2 + 0,
|
| 84 |
+
[
|
| 85 |
+
"bb\\ncc\\ndd",
|
| 86 |
+
"^",
|
| 87 |
+
],
|
| 88 |
+
),
|
| 89 |
+
# multi line grammars beyond error with pos on fifth line, second char
|
| 90 |
+
(
|
| 91 |
+
"aa\\nbb\\ncc\\ndd\\nee",
|
| 92 |
+
2 + 2 + 2 + 2 + 1,
|
| 93 |
+
[
|
| 94 |
+
"cc\\ndd\\nee",
|
| 95 |
+
" ^",
|
| 96 |
+
],
|
| 97 |
+
),
|
| 98 |
+
],
|
| 99 |
+
)
|
| 100 |
+
def it_correctly_shows_position(grammar, pos, expected):
|
| 101 |
+
grammar_out, pos_out = expected
|
| 102 |
+
result = build_error_position(grammar.replace("\\n", "\n"), pos)
|
| 103 |
+
assert result == [
|
| 104 |
+
*grammar_out.split("\\n"),
|
| 105 |
+
pos_out,
|
| 106 |
+
]
|
| 107 |
+
|
| 108 |
+
def it_renders_a_message_for_empty_input():
|
| 109 |
+
result = build_error_position("", 0)
|
| 110 |
+
assert result == ["No input provided"]
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/get_input_as_string.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import TYPE_CHECKING
|
| 4 |
+
|
| 5 |
+
if TYPE_CHECKING:
|
| 6 |
+
from ...grammar_graph.types import ValidInput
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def get_input_as_string(src: ValidInput) -> str:
|
| 10 |
+
if isinstance(src, str):
|
| 11 |
+
return src
|
| 12 |
+
code_points = src if isinstance(src, list) else [src]
|
| 13 |
+
return "".join(chr(code_point) for code_point in code_points)
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/get_input_as_string_test.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from gbnf.utils.errors.get_input_as_string import get_input_as_string
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def describe_get_input_as_string():
|
| 7 |
+
@pytest.mark.parametrize(
|
| 8 |
+
("input", "expected"),
|
| 9 |
+
[
|
| 10 |
+
("hello", "hello"),
|
| 11 |
+
([104, 101, 108, 108, 111], "hello"),
|
| 12 |
+
(104, "h"),
|
| 13 |
+
(0x1F600, "😀"),
|
| 14 |
+
([0x1F600, 0x1F601], "😀😁"),
|
| 15 |
+
],
|
| 16 |
+
)
|
| 17 |
+
def it_correctly_converts_to_string(input, expected):
|
| 18 |
+
result = get_input_as_string(input)
|
| 19 |
+
assert result == expected
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/grammar_parse_error.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .build_error_position import build_error_position
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def grammar_parser_error_header_message(reason: str) -> str:
|
| 5 |
+
return f"Failed to parse grammar: {reason}"
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class GrammarParseError(Exception):
|
| 9 |
+
def __init__(self, grammar: str, pos: int, reason: str) -> None:
|
| 10 |
+
self.message = "\n".join(
|
| 11 |
+
[
|
| 12 |
+
grammar_parser_error_header_message(reason),
|
| 13 |
+
"",
|
| 14 |
+
*build_error_position(grammar, pos),
|
| 15 |
+
]
|
| 16 |
+
)
|
| 17 |
+
super().__init__(self.message)
|
| 18 |
+
self.grammar = grammar
|
| 19 |
+
self.reason = reason
|
| 20 |
+
self.pos = pos
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/grammar_parse_error_test.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from gbnf.utils.errors.grammar_parse_error import (
|
| 2 |
+
GrammarParseError,
|
| 3 |
+
grammar_parser_error_header_message,
|
| 4 |
+
)
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def describe_grammar_parse_error():
|
| 8 |
+
def it_renders_a_message():
|
| 9 |
+
grammar = "aa\\nbb\\ncc\\ndd\\nee"
|
| 10 |
+
pos = 5
|
| 11 |
+
reason = "reason"
|
| 12 |
+
err = GrammarParseError(grammar.replace("\\n", "\n"), pos, reason)
|
| 13 |
+
assert err.message == "\n".join(
|
| 14 |
+
[
|
| 15 |
+
grammar_parser_error_header_message(reason),
|
| 16 |
+
"",
|
| 17 |
+
"aa",
|
| 18 |
+
"bb",
|
| 19 |
+
"cc",
|
| 20 |
+
" ^",
|
| 21 |
+
]
|
| 22 |
+
)
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/input_parse_error.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import TYPE_CHECKING
|
| 4 |
+
|
| 5 |
+
from .build_error_position import build_error_position
|
| 6 |
+
from .get_input_as_string import get_input_as_string
|
| 7 |
+
|
| 8 |
+
if TYPE_CHECKING:
|
| 9 |
+
from ...grammar_graph.types import ValidInput
|
| 10 |
+
|
| 11 |
+
INPUT_PARSER_ERROR_HEADER_MESSAGE = "Failed to parse input string:"
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class InputParseError(Exception):
|
| 15 |
+
def __init__(
|
| 16 |
+
self,
|
| 17 |
+
most_recent_input: ValidInput,
|
| 18 |
+
pos: int,
|
| 19 |
+
previous_input: ValidInput = "",
|
| 20 |
+
) -> None:
|
| 21 |
+
self._most_recent_input = most_recent_input
|
| 22 |
+
self._pos = pos
|
| 23 |
+
self._previous_input = previous_input
|
| 24 |
+
self.message = "\n".join(
|
| 25 |
+
[
|
| 26 |
+
INPUT_PARSER_ERROR_HEADER_MESSAGE,
|
| 27 |
+
"",
|
| 28 |
+
*build_error_position(self.src, pos + len(get_input_as_string(previous_input))),
|
| 29 |
+
]
|
| 30 |
+
)
|
| 31 |
+
super().__init__(self.message)
|
| 32 |
+
|
| 33 |
+
@property
|
| 34 |
+
def src(self) -> str:
|
| 35 |
+
previous_input = get_input_as_string(self._previous_input)
|
| 36 |
+
most_recent_input = get_input_as_string(self._most_recent_input)
|
| 37 |
+
return f"{previous_input}{most_recent_input}"
|
| 38 |
+
|
| 39 |
+
@property
|
| 40 |
+
def error_for_most_recent_input(self) -> str:
|
| 41 |
+
return "\n".join(
|
| 42 |
+
[
|
| 43 |
+
INPUT_PARSER_ERROR_HEADER_MESSAGE,
|
| 44 |
+
"",
|
| 45 |
+
*build_error_position(get_input_as_string(self._most_recent_input), self._pos),
|
| 46 |
+
]
|
| 47 |
+
)
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/errors/input_parse_error_test.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from gbnf.utils.errors.input_parse_error import (
|
| 2 |
+
INPUT_PARSER_ERROR_HEADER_MESSAGE,
|
| 3 |
+
InputParseError,
|
| 4 |
+
)
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def describe_input_parse_error():
|
| 8 |
+
def it_renders_a_message():
|
| 9 |
+
input = "some input"
|
| 10 |
+
pos = 1
|
| 11 |
+
err = InputParseError(input, pos)
|
| 12 |
+
assert err.message == "\n".join(
|
| 13 |
+
[
|
| 14 |
+
INPUT_PARSER_ERROR_HEADER_MESSAGE,
|
| 15 |
+
"",
|
| 16 |
+
input,
|
| 17 |
+
" ^",
|
| 18 |
+
]
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
def it_renders_a_message_for_code_point():
|
| 22 |
+
pos = 0
|
| 23 |
+
err = InputParseError("a", pos)
|
| 24 |
+
assert err.message == "\n".join(
|
| 25 |
+
[
|
| 26 |
+
INPUT_PARSER_ERROR_HEADER_MESSAGE,
|
| 27 |
+
"",
|
| 28 |
+
"a",
|
| 29 |
+
"^",
|
| 30 |
+
]
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
def it_renders_a_message_for_code_points():
|
| 34 |
+
pos = 2
|
| 35 |
+
err = InputParseError("abcd", pos)
|
| 36 |
+
assert err.message == "\n".join(
|
| 37 |
+
[
|
| 38 |
+
INPUT_PARSER_ERROR_HEADER_MESSAGE,
|
| 39 |
+
"",
|
| 40 |
+
"abcd",
|
| 41 |
+
" ^",
|
| 42 |
+
]
|
| 43 |
+
)
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/is_point_in_range.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def is_point_in_range(point: int, range_: list[int]) -> bool:
|
| 2 |
+
start, end = range_
|
| 3 |
+
return start <= point <= end
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/is_point_in_range_test.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from gbnf.utils.is_point_in_range import is_point_in_range
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def describe_is_point_in_range():
|
| 7 |
+
@pytest.mark.parametrize(
|
| 8 |
+
("point", "expectation", "range_"),
|
| 9 |
+
[
|
| 10 |
+
(96, False, [97, 122]),
|
| 11 |
+
(97, True, [97, 122]),
|
| 12 |
+
(98, True, [97, 122]),
|
| 13 |
+
(122, True, [97, 122]),
|
| 14 |
+
(123, False, [97, 122]),
|
| 15 |
+
],
|
| 16 |
+
)
|
| 17 |
+
def it_checks_if_point_is_in_range(point, expectation, range_):
|
| 18 |
+
assert is_point_in_range(point, range_) == expectation
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/gbnf/utils/json_stringify.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def _own_properties(value: object) -> object:
|
| 5 |
+
# JSON.stringify writes out an object's own enumerable properties, which
|
| 6 |
+
# leaves out private fields, methods and anything that is undefined.
|
| 7 |
+
try:
|
| 8 |
+
properties = vars(value)
|
| 9 |
+
except TypeError:
|
| 10 |
+
return repr(value)
|
| 11 |
+
return {
|
| 12 |
+
key: prop
|
| 13 |
+
for key, prop in properties.items()
|
| 14 |
+
if not key.startswith("_") and prop is not None and not callable(prop)
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
_encoder = json.JSONEncoder(separators=(",", ":"), ensure_ascii=False, default=_own_properties)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def json_stringify(value: object) -> str:
|
| 22 |
+
"""Serializes ``value`` like JavaScript's ``JSON.stringify``.
|
| 23 |
+
|
| 24 |
+
Rule keys and error messages embed this compact form.
|
| 25 |
+
"""
|
| 26 |
+
return _encoder.encode(value)
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/integration_tests/generated/iteration/grammars_test.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/integration_tests/generated/iteration/iteration_test.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from gbnf import GBNF
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def describe_iteration():
|
| 7 |
+
@pytest.mark.parametrize(
|
| 8 |
+
("grammar", "expected"),
|
| 9 |
+
[
|
| 10 |
+
('root ::= "foo"', [{"type": "char", "value": [102]}]),
|
| 11 |
+
(
|
| 12 |
+
'root ::= "foo" | "bar" ',
|
| 13 |
+
[{"type": "char", "value": [102]}, {"type": "char", "value": [98]}],
|
| 14 |
+
),
|
| 15 |
+
(
|
| 16 |
+
'root ::= "foo" | "bar" | "gaz"',
|
| 17 |
+
[
|
| 18 |
+
{"type": "char", "value": [102]},
|
| 19 |
+
{"type": "char", "value": [98]},
|
| 20 |
+
{"type": "char", "value": [103]},
|
| 21 |
+
],
|
| 22 |
+
),
|
| 23 |
+
(
|
| 24 |
+
'root ::= "foo" | "bar" | "baz"',
|
| 25 |
+
[{"type": "char", "value": [102]}, {"type": "char", "value": [98]}],
|
| 26 |
+
),
|
| 27 |
+
("root ::= [^x]", [{"type": "char_exclude", "value": [120]}]),
|
| 28 |
+
('root ::= [^f] "o"', [{"type": "char_exclude", "value": [102]}]),
|
| 29 |
+
("root ::= [^A-Z]", [{"type": "char_exclude", "value": [[65, 90]]}]),
|
| 30 |
+
("root ::= [^A-Z0-9]", [{"type": "char_exclude", "value": [[65, 90], [48, 57]]}]),
|
| 31 |
+
(
|
| 32 |
+
"root ::= [^A-Z0-9_-]",
|
| 33 |
+
[{"type": "char_exclude", "value": [[65, 90], [48, 57], 95, 45]}],
|
| 34 |
+
),
|
| 35 |
+
('\nroot ::= foo\nfoo ::= "foo"\n ', [{"type": "char", "value": [102]}]),
|
| 36 |
+
('\nroot ::= f\nf ::= foo\nfoo ::= "foo"\n ', [{"type": "char", "value": [102]}]),
|
| 37 |
+
(
|
| 38 |
+
'\nroot ::= foo | "bar"\nfoo ::= "foo"',
|
| 39 |
+
[{"type": "char", "value": [102]}, {"type": "char", "value": [98]}],
|
| 40 |
+
),
|
| 41 |
+
(
|
| 42 |
+
'\nroot ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"\n ',
|
| 43 |
+
[{"type": "char", "value": [102]}, {"type": "char", "value": [98]}],
|
| 44 |
+
),
|
| 45 |
+
(
|
| 46 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"\n ',
|
| 47 |
+
[{"type": "char", "value": [102]}, {"type": "char", "value": [98]}],
|
| 48 |
+
),
|
| 49 |
+
("root ::= [a-z]", [{"type": "char", "value": [[97, 122]]}]),
|
| 50 |
+
("root ::= [a-zA-Z]", [{"type": "char", "value": [[97, 122], [65, 90]]}]),
|
| 51 |
+
("root ::= [a-z]?", [{"type": "char", "value": [[97, 122]]}, {"type": "end"}]),
|
| 52 |
+
("root ::= [a-z]+", [{"type": "char", "value": [[97, 122]]}]),
|
| 53 |
+
("root ::= [a-z]*", [{"type": "char", "value": [[97, 122]]}, {"type": "end"}]),
|
| 54 |
+
('\n root ::= "foo"\n foo ::= "foo"', [{"type": "char", "value": [102]}]),
|
| 55 |
+
(
|
| 56 |
+
'\n root ::= (expr "=" term "\\n")+\n expr ::= term ([-+*/] term)*\n term ::= [0-9]+\n ',
|
| 57 |
+
[{"type": "char", "value": [[48, 57]]}],
|
| 58 |
+
),
|
| 59 |
+
],
|
| 60 |
+
)
|
| 61 |
+
def it_returns_parse_state_for_a_grammar(grammar, expected):
|
| 62 |
+
state = GBNF(grammar)
|
| 63 |
+
assert list(state) == expected
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/integration_tests/generated/iteration/iteration_with_additional_strings_test.py
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from gbnf import GBNF, InputParseError
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def describe_iteration():
|
| 7 |
+
@pytest.mark.parametrize(
|
| 8 |
+
("grammar", "starting", "additional"),
|
| 9 |
+
[
|
| 10 |
+
('root ::= "foo"', "f", "1"),
|
| 11 |
+
('root ::= "foo"', "f", "b"),
|
| 12 |
+
('root ::= "foo"', "f", "o1"),
|
| 13 |
+
('root ::= "foo"', "f", "ooo"),
|
| 14 |
+
('root ::= "foo"', "f", "ooooooo"),
|
| 15 |
+
('root ::= "foo" | "bar"', "f", "1"),
|
| 16 |
+
('root ::= "foo" | "bar"', "b", "1"),
|
| 17 |
+
('root ::= "foo" | "bar"', "f", "o1"),
|
| 18 |
+
('root ::= "foo" | "bar"', "b", "a1"),
|
| 19 |
+
('root ::= "foo" | "bar"', "f", "ooo"),
|
| 20 |
+
('root ::= "foo" | "bar"', "b", "arrr"),
|
| 21 |
+
('root ::= "foo" | "bar" | "baz"', "f", "1"),
|
| 22 |
+
('root ::= "foo" | "bar" | "baz"', "f", "z"),
|
| 23 |
+
('root ::= "foo" | "bar" | "baz"', "b", "b1"),
|
| 24 |
+
('root ::= "foo" | "bar" | "baz"', "f", "o1"),
|
| 25 |
+
('root ::= "foo" | "bar" | "baz"', "b", "al"),
|
| 26 |
+
('root ::= "foo" | "bar" | "baz"', "f", "ooo"),
|
| 27 |
+
('root ::= "foo" | "bar" | "baz"', "b", "azrr"),
|
| 28 |
+
('root ::= foo\nfoo ::="foo"', "f", "1"),
|
| 29 |
+
('root ::= foo\nfoo ::="foo"', "f", "b"),
|
| 30 |
+
('root ::= foo\nfoo ::="foo"', "f", "o1"),
|
| 31 |
+
('root ::= foo\nfoo ::="foo"', "f", "ooo"),
|
| 32 |
+
('root::=foo|"bar"\nfoo::="foo"', "f", "1"),
|
| 33 |
+
('root::=foo|"bar"\nfoo::="foo"', "f", "z"),
|
| 34 |
+
('root::=foo|"bar"\nfoo::="foo"', "b", "b1"),
|
| 35 |
+
('root::=foo|"bar"\nfoo::="foo"', "f", "o1"),
|
| 36 |
+
('root::=foo|"bar"\nfoo::="foo"', "f", "ooo"),
|
| 37 |
+
('root::=foo|"bar"\nfoo::="foo"', "b", "arr"),
|
| 38 |
+
('root::= foo | bar\n foo::="foo"\n bar::="bar"', "f", "1"),
|
| 39 |
+
('root::= foo | bar\n foo::="foo"\n bar::="bar"', "f", "z"),
|
| 40 |
+
('root::= foo | bar\n foo::="foo"\n bar::="bar"', "b", "1"),
|
| 41 |
+
('root::= foo | bar\n foo::="foo"\n bar::="bar"', "f", "o1"),
|
| 42 |
+
('root::= foo | bar\n foo::="foo"\n bar::="bar"', "f", "ooo"),
|
| 43 |
+
('root::= foo | bar\n foo::="foo"\n bar::="bar"', "b", "arr"),
|
| 44 |
+
(
|
| 45 |
+
'root ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 46 |
+
"f",
|
| 47 |
+
"1",
|
| 48 |
+
),
|
| 49 |
+
(
|
| 50 |
+
'root ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 51 |
+
"f",
|
| 52 |
+
"z",
|
| 53 |
+
),
|
| 54 |
+
(
|
| 55 |
+
'root ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 56 |
+
"b",
|
| 57 |
+
"1",
|
| 58 |
+
),
|
| 59 |
+
(
|
| 60 |
+
'root ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 61 |
+
"f",
|
| 62 |
+
"o1",
|
| 63 |
+
),
|
| 64 |
+
(
|
| 65 |
+
'root ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 66 |
+
"f",
|
| 67 |
+
"ooo",
|
| 68 |
+
),
|
| 69 |
+
(
|
| 70 |
+
'root ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 71 |
+
"b",
|
| 72 |
+
"arr",
|
| 73 |
+
),
|
| 74 |
+
(
|
| 75 |
+
'root ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 76 |
+
"b",
|
| 77 |
+
"azr",
|
| 78 |
+
),
|
| 79 |
+
("root ::= [a-z]", "a", "A"),
|
| 80 |
+
("root ::= [a-z]", "a", "0"),
|
| 81 |
+
("root ::= [a-z]", "a", "az"),
|
| 82 |
+
("root ::= [a-z]?", "a", "A"),
|
| 83 |
+
("root ::= [a-z]?", "a", "0"),
|
| 84 |
+
("root ::= [a-z]?", "a", "az"),
|
| 85 |
+
("root ::= [a-z]+", "a", "A"),
|
| 86 |
+
("root ::= [a-z]+", "a", "0"),
|
| 87 |
+
("root ::= [a-z]+", "a", "z0"),
|
| 88 |
+
("root ::= [a-z]*", "a", "A"),
|
| 89 |
+
("root ::= [a-z]*", "a", "0"),
|
| 90 |
+
("root ::= [a-z]*", "a", "z0"),
|
| 91 |
+
],
|
| 92 |
+
)
|
| 93 |
+
def it_throws_if_encountering_a_grammar_with_starting_and_additional(
|
| 94 |
+
grammar, starting, additional
|
| 95 |
+
):
|
| 96 |
+
graph = GBNF(grammar, starting)
|
| 97 |
+
with pytest.raises(InputParseError):
|
| 98 |
+
graph.add(additional)
|
| 99 |
+
|
| 100 |
+
@pytest.mark.parametrize(
|
| 101 |
+
("grammar", "starting", "additional", "expected"),
|
| 102 |
+
[
|
| 103 |
+
('root ::= "foo"', "", "f", [{"type": "char", "value": [111]}]),
|
| 104 |
+
('root ::= "foo"', "f", "o", [{"type": "char", "value": [111]}]),
|
| 105 |
+
('root ::= "foo"', "fo", "o", [{"type": "end"}]),
|
| 106 |
+
('root ::= "foo" | "bar" ', "", "f", [{"type": "char", "value": [111]}]),
|
| 107 |
+
('root ::= "foo" | "bar" ', "f", "o", [{"type": "char", "value": [111]}]),
|
| 108 |
+
('root ::= "foo" | "bar" ', "fo", "o", [{"type": "end"}]),
|
| 109 |
+
('root ::= "foo" | "bar" ', "", "b", [{"type": "char", "value": [97]}]),
|
| 110 |
+
('root ::= "foo" | "bar" ', "b", "a", [{"type": "char", "value": [114]}]),
|
| 111 |
+
('root ::= "foo" | "bar" ', "ba", "r", [{"type": "end"}]),
|
| 112 |
+
(
|
| 113 |
+
'root ::= "foo" | "bar" | "baz"',
|
| 114 |
+
"b",
|
| 115 |
+
"a",
|
| 116 |
+
[{"type": "char", "value": [114]}, {"type": "char", "value": [122]}],
|
| 117 |
+
),
|
| 118 |
+
('root ::= [^f] "o"', "g", "o", [{"type": "end"}]),
|
| 119 |
+
("root ::= [^A-Z]", "", "a", [{"type": "end"}]),
|
| 120 |
+
("root ::= [^A-Z0-9]", "", "a", [{"type": "end"}]),
|
| 121 |
+
("root ::= [^A-Z0-9_-]", "", "a", [{"type": "end"}]),
|
| 122 |
+
('root ::= foo\nfoo ::= "foo"', "", "f", [{"type": "char", "value": [111]}]),
|
| 123 |
+
('root ::= foo\nfoo ::= "foo"', "f", "o", [{"type": "char", "value": [111]}]),
|
| 124 |
+
('root ::= foo\nfoo ::= "foo"', "fo", "o", [{"type": "end"}]),
|
| 125 |
+
('root ::= foo | "bar"\nfoo ::= "foo"', "", "f", [{"type": "char", "value": [111]}]),
|
| 126 |
+
('root ::= foo | "bar"\nfoo ::= "foo"', "f", "o", [{"type": "char", "value": [111]}]),
|
| 127 |
+
('root ::= foo | "bar"\nfoo ::= "foo"', "fo", "o", [{"type": "end"}]),
|
| 128 |
+
('root ::= foo | "bar"\nfoo ::= "foo"', "", "b", [{"type": "char", "value": [97]}]),
|
| 129 |
+
('root ::= foo | "bar"\nfoo ::= "foo"', "b", "a", [{"type": "char", "value": [114]}]),
|
| 130 |
+
('root ::= foo | "bar"\nfoo ::= "foo"', "ba", "r", [{"type": "end"}]),
|
| 131 |
+
(
|
| 132 |
+
'root ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"',
|
| 133 |
+
"",
|
| 134 |
+
"f",
|
| 135 |
+
[{"type": "char", "value": [111]}],
|
| 136 |
+
),
|
| 137 |
+
(
|
| 138 |
+
'\nroot ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"',
|
| 139 |
+
"f",
|
| 140 |
+
"o",
|
| 141 |
+
[{"type": "char", "value": [111]}],
|
| 142 |
+
),
|
| 143 |
+
('\nroot ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"', "fo", "o", [{"type": "end"}]),
|
| 144 |
+
(
|
| 145 |
+
'root ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"',
|
| 146 |
+
"",
|
| 147 |
+
"b",
|
| 148 |
+
[{"type": "char", "value": [97]}],
|
| 149 |
+
),
|
| 150 |
+
(
|
| 151 |
+
'root ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"',
|
| 152 |
+
"b",
|
| 153 |
+
"a",
|
| 154 |
+
[{"type": "char", "value": [114]}],
|
| 155 |
+
),
|
| 156 |
+
('root ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"', "ba", "r", [{"type": "end"}]),
|
| 157 |
+
(
|
| 158 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 159 |
+
"",
|
| 160 |
+
"f",
|
| 161 |
+
[{"type": "char", "value": [111]}],
|
| 162 |
+
),
|
| 163 |
+
(
|
| 164 |
+
'root ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 165 |
+
"f",
|
| 166 |
+
"o",
|
| 167 |
+
[{"type": "char", "value": [111]}],
|
| 168 |
+
),
|
| 169 |
+
(
|
| 170 |
+
'root ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 171 |
+
"fo",
|
| 172 |
+
"o",
|
| 173 |
+
[{"type": "end"}],
|
| 174 |
+
),
|
| 175 |
+
(
|
| 176 |
+
'root ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 177 |
+
"",
|
| 178 |
+
"b",
|
| 179 |
+
[{"type": "char", "value": [97]}],
|
| 180 |
+
),
|
| 181 |
+
(
|
| 182 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 183 |
+
"b",
|
| 184 |
+
"a",
|
| 185 |
+
[{"type": "char", "value": [114]}, {"type": "char", "value": [122]}],
|
| 186 |
+
),
|
| 187 |
+
(
|
| 188 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 189 |
+
"ba",
|
| 190 |
+
"r",
|
| 191 |
+
[{"type": "end"}],
|
| 192 |
+
),
|
| 193 |
+
(
|
| 194 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 195 |
+
"ba",
|
| 196 |
+
"z",
|
| 197 |
+
[{"type": "end"}],
|
| 198 |
+
),
|
| 199 |
+
("root ::= [a-z]", "", "a", [{"type": "end"}]),
|
| 200 |
+
("root ::= [a-z]", "", "m", [{"type": "end"}]),
|
| 201 |
+
("root ::= [a-z]", "", "z", [{"type": "end"}]),
|
| 202 |
+
("root ::= [a-zA-Z]", "", "a", [{"type": "end"}]),
|
| 203 |
+
("root ::= [a-zA-Z]", "", "Z", [{"type": "end"}]),
|
| 204 |
+
("root ::= [a-zA-Z0-9]", "", "Z", [{"type": "end"}]),
|
| 205 |
+
("root ::= [a-zA-Z0-9]", "", "0", [{"type": "end"}]),
|
| 206 |
+
("root ::= [a-zA-Z0-9]", "", "9", [{"type": "end"}]),
|
| 207 |
+
("root ::= [a-z]?", "", "a", [{"type": "end"}]),
|
| 208 |
+
("root ::= [a-zA-Z]?", "", "Z", [{"type": "end"}]),
|
| 209 |
+
("root ::= [a-zA-Z0-9]?", "", "0", [{"type": "end"}]),
|
| 210 |
+
("root ::= [a-z]+", "", "a", [{"type": "char", "value": [[97, 122]]}, {"type": "end"}]),
|
| 211 |
+
(
|
| 212 |
+
"root ::= [a-zA-Z]+",
|
| 213 |
+
"",
|
| 214 |
+
"Z",
|
| 215 |
+
[{"type": "char", "value": [[97, 122], [65, 90]]}, {"type": "end"}],
|
| 216 |
+
),
|
| 217 |
+
(
|
| 218 |
+
"root ::= [a-zA-Z]+",
|
| 219 |
+
"azA",
|
| 220 |
+
"Z",
|
| 221 |
+
[{"type": "char", "value": [[97, 122], [65, 90]]}, {"type": "end"}],
|
| 222 |
+
),
|
| 223 |
+
("root ::= [a-z]*", "", "a", [{"type": "char", "value": [[97, 122]]}, {"type": "end"}]),
|
| 224 |
+
(
|
| 225 |
+
"root ::= [a-zA-Z]+",
|
| 226 |
+
"",
|
| 227 |
+
"Z",
|
| 228 |
+
[{"type": "char", "value": [[97, 122], [65, 90]]}, {"type": "end"}],
|
| 229 |
+
),
|
| 230 |
+
(
|
| 231 |
+
"root ::= [a-zA-Z]+",
|
| 232 |
+
"acczABC",
|
| 233 |
+
"Z",
|
| 234 |
+
[{"type": "char", "value": [[97, 122], [65, 90]]}, {"type": "end"}],
|
| 235 |
+
),
|
| 236 |
+
(
|
| 237 |
+
'root ::= "foo" | "bar" | "baz" | "bazaar" | "barrington" ',
|
| 238 |
+
"baza",
|
| 239 |
+
"a",
|
| 240 |
+
[{"type": "char", "value": [114]}],
|
| 241 |
+
),
|
| 242 |
+
(
|
| 243 |
+
'root ::= [^f]+ "o"',
|
| 244 |
+
"aaa",
|
| 245 |
+
"a",
|
| 246 |
+
[{"type": "char_exclude", "value": [102]}, {"type": "char", "value": [111]}],
|
| 247 |
+
),
|
| 248 |
+
(
|
| 249 |
+
"root ::= [^A-Z]+",
|
| 250 |
+
"abc",
|
| 251 |
+
"d",
|
| 252 |
+
[{"type": "char_exclude", "value": [[65, 90]]}, {"type": "end"}],
|
| 253 |
+
),
|
| 254 |
+
(
|
| 255 |
+
"root ::= [^A-Z0-9]*",
|
| 256 |
+
"abc",
|
| 257 |
+
"d",
|
| 258 |
+
[{"type": "char_exclude", "value": [[65, 90], [48, 57]]}, {"type": "end"}],
|
| 259 |
+
),
|
| 260 |
+
(
|
| 261 |
+
"root ::= [^A-Z0-9_-]*",
|
| 262 |
+
"abc",
|
| 263 |
+
"d",
|
| 264 |
+
[{"type": "char_exclude", "value": [[65, 90], [48, 57], 95, 45]}, {"type": "end"}],
|
| 265 |
+
),
|
| 266 |
+
],
|
| 267 |
+
)
|
| 268 |
+
def it_parses_a_grammar_with_starting_and_additional(grammar, starting, additional, expected):
|
| 269 |
+
state = GBNF(grammar, starting)
|
| 270 |
+
state = state.add(additional)
|
| 271 |
+
assert list(state) == expected
|
| 272 |
+
|
| 273 |
+
@pytest.mark.parametrize(
|
| 274 |
+
"error_for_most_recent_input",
|
| 275 |
+
[False, True],
|
| 276 |
+
)
|
| 277 |
+
def it_throws_a_particular_error(error_for_most_recent_input):
|
| 278 |
+
grammar = 'root ::= "bar"'
|
| 279 |
+
state = GBNF(grammar)
|
| 280 |
+
state = state.add("b")
|
| 281 |
+
state = state.add("a")
|
| 282 |
+
with pytest.raises(InputParseError) as raised:
|
| 283 |
+
state.add("z")
|
| 284 |
+
err = raised.value
|
| 285 |
+
expected_err = InputParseError("z", 0, "ba")
|
| 286 |
+
if error_for_most_recent_input:
|
| 287 |
+
assert err.error_for_most_recent_input == expected_err.error_for_most_recent_input
|
| 288 |
+
else:
|
| 289 |
+
assert err.message == expected_err.message
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/integration_tests/generated/iteration/iteration_with_an_initial_string_test.py
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from gbnf import GBNF
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def describe_iteration():
|
| 7 |
+
@pytest.mark.parametrize(
|
| 8 |
+
("grammar", "input", "expected"),
|
| 9 |
+
[
|
| 10 |
+
('root ::= "foo"', "", [{"type": "char", "value": [102]}]),
|
| 11 |
+
('root ::= "foo"', "f", [{"type": "char", "value": [111]}]),
|
| 12 |
+
('root ::= "foo"', "fo", [{"type": "char", "value": [111]}]),
|
| 13 |
+
('root ::= "foo"', "foo", [{"type": "end"}]),
|
| 14 |
+
(
|
| 15 |
+
'root ::= "foo" | "bar" ',
|
| 16 |
+
"",
|
| 17 |
+
[{"type": "char", "value": [102]}, {"type": "char", "value": [98]}],
|
| 18 |
+
),
|
| 19 |
+
('root ::= "foo" | "bar" ', "f", [{"type": "char", "value": [111]}]),
|
| 20 |
+
('root ::= "foo" | "bar" ', "fo", [{"type": "char", "value": [111]}]),
|
| 21 |
+
('root ::= "foo" | "bar" ', "foo", [{"type": "end"}]),
|
| 22 |
+
('root ::= "foo" | "bar" ', "b", [{"type": "char", "value": [97]}]),
|
| 23 |
+
('root ::= "foo" | "bar" ', "ba", [{"type": "char", "value": [114]}]),
|
| 24 |
+
('root ::= "foo" | "bar" ', "bar", [{"type": "end"}]),
|
| 25 |
+
(
|
| 26 |
+
'root ::= "foo" | "bar" | "baz"',
|
| 27 |
+
"ba",
|
| 28 |
+
[{"type": "char", "value": [114]}, {"type": "char", "value": [122]}],
|
| 29 |
+
),
|
| 30 |
+
('root ::= "["', "[", [{"type": "end"}]),
|
| 31 |
+
('root ::= "]"', "]", [{"type": "end"}]),
|
| 32 |
+
('root ::= "[]"', "[]", [{"type": "end"}]),
|
| 33 |
+
('root ::= "{"', "{", [{"type": "end"}]),
|
| 34 |
+
('root ::= "}"', "}", [{"type": "end"}]),
|
| 35 |
+
('root ::= "{}"', "{}", [{"type": "end"}]),
|
| 36 |
+
('root ::= "[{}]"', "[{}]", [{"type": "end"}]),
|
| 37 |
+
('root ::= [^f] "o"', "", [{"type": "char_exclude", "value": [102]}]),
|
| 38 |
+
('root ::= [^f] "o"', "a", [{"type": "char", "value": [111]}]),
|
| 39 |
+
("root ::= [^A-Z]", "", [{"type": "char_exclude", "value": [[65, 90]]}]),
|
| 40 |
+
("root ::= [^A-Z0-9]", "", [{"type": "char_exclude", "value": [[65, 90], [48, 57]]}]),
|
| 41 |
+
(
|
| 42 |
+
"root ::= [^A-Z0-9_-]",
|
| 43 |
+
"",
|
| 44 |
+
[{"type": "char_exclude", "value": [[65, 90], [48, 57], 95, 45]}],
|
| 45 |
+
),
|
| 46 |
+
('\nroot ::= foo\nfoo ::= "foo"', "", [{"type": "char", "value": [102]}]),
|
| 47 |
+
('root ::= foo\nfoo ::= "foo"\n', "f", [{"type": "char", "value": [111]}]),
|
| 48 |
+
('\nroot ::= foo\nfoo ::= "foo"\n', "fo", [{"type": "char", "value": [111]}]),
|
| 49 |
+
('root ::= foo\nfoo ::= "foo"', "foo", [{"type": "end"}]),
|
| 50 |
+
('root ::= f\nf ::= foo\nfoo ::= "foo"', "", [{"type": "char", "value": [102]}]),
|
| 51 |
+
(
|
| 52 |
+
'\nroot ::= foo | "bar"\nfoo ::= "foo"\n',
|
| 53 |
+
"",
|
| 54 |
+
[{"type": "char", "value": [102]}, {"type": "char", "value": [98]}],
|
| 55 |
+
),
|
| 56 |
+
('\nroot ::= foo | "bar"\nfoo ::= "foo"', "f", [{"type": "char", "value": [111]}]),
|
| 57 |
+
('root ::= foo | "bar"\nfoo ::= "foo"', "fo", [{"type": "char", "value": [111]}]),
|
| 58 |
+
('root ::= foo | "bar"\nfoo ::= "foo"', "foo", [{"type": "end"}]),
|
| 59 |
+
('root ::= foo | "bar"\nfoo ::= "foo"', "b", [{"type": "char", "value": [97]}]),
|
| 60 |
+
('root ::= foo | "bar"\nfoo ::= "foo"', "ba", [{"type": "char", "value": [114]}]),
|
| 61 |
+
('root ::= foo | "bar"\nfoo ::= "foo"', "bar", [{"type": "end"}]),
|
| 62 |
+
(
|
| 63 |
+
'\nroot ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"',
|
| 64 |
+
"",
|
| 65 |
+
[{"type": "char", "value": [102]}, {"type": "char", "value": [98]}],
|
| 66 |
+
),
|
| 67 |
+
(
|
| 68 |
+
'\nroot ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"',
|
| 69 |
+
"f",
|
| 70 |
+
[{"type": "char", "value": [111]}],
|
| 71 |
+
),
|
| 72 |
+
(
|
| 73 |
+
'\nroot ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"',
|
| 74 |
+
"fo",
|
| 75 |
+
[{"type": "char", "value": [111]}],
|
| 76 |
+
),
|
| 77 |
+
('\nroot ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"', "foo", [{"type": "end"}]),
|
| 78 |
+
(
|
| 79 |
+
'\nroot ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"',
|
| 80 |
+
"b",
|
| 81 |
+
[{"type": "char", "value": [97]}],
|
| 82 |
+
),
|
| 83 |
+
(
|
| 84 |
+
'\nroot ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"',
|
| 85 |
+
"ba",
|
| 86 |
+
[{"type": "char", "value": [114]}],
|
| 87 |
+
),
|
| 88 |
+
('\nroot ::= foo | bar\nfoo ::= "foo"\nbar ::= "bar"', "bar", [{"type": "end"}]),
|
| 89 |
+
(
|
| 90 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 91 |
+
"",
|
| 92 |
+
[{"type": "char", "value": [102]}, {"type": "char", "value": [98]}],
|
| 93 |
+
),
|
| 94 |
+
(
|
| 95 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 96 |
+
"f",
|
| 97 |
+
[{"type": "char", "value": [111]}],
|
| 98 |
+
),
|
| 99 |
+
(
|
| 100 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 101 |
+
"fo",
|
| 102 |
+
[{"type": "char", "value": [111]}],
|
| 103 |
+
),
|
| 104 |
+
(
|
| 105 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 106 |
+
"foo",
|
| 107 |
+
[{"type": "end"}],
|
| 108 |
+
),
|
| 109 |
+
(
|
| 110 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 111 |
+
"b",
|
| 112 |
+
[{"type": "char", "value": [97]}],
|
| 113 |
+
),
|
| 114 |
+
(
|
| 115 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 116 |
+
"ba",
|
| 117 |
+
[{"type": "char", "value": [114]}, {"type": "char", "value": [122]}],
|
| 118 |
+
),
|
| 119 |
+
(
|
| 120 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 121 |
+
"bar",
|
| 122 |
+
[{"type": "end"}],
|
| 123 |
+
),
|
| 124 |
+
(
|
| 125 |
+
'\nroot ::= f | b\nf ::= fo\nb ::= ba\nfo ::= foo\nba ::= bar | baz\nfoo ::= "foo"\nbar ::= "bar"\nbaz ::= "baz"',
|
| 126 |
+
"baz",
|
| 127 |
+
[{"type": "end"}],
|
| 128 |
+
),
|
| 129 |
+
("root ::= [a-z]", "", [{"type": "char", "value": [[97, 122]]}]),
|
| 130 |
+
("root ::= [a-zA-Z]", "", [{"type": "char", "value": [[97, 122], [65, 90]]}]),
|
| 131 |
+
("root ::= [a-z]", "a", [{"type": "end"}]),
|
| 132 |
+
("root ::= [a-z]", "m", [{"type": "end"}]),
|
| 133 |
+
("root ::= [a-z]", "z", [{"type": "end"}]),
|
| 134 |
+
("root ::= [a-zA-Z]", "a", [{"type": "end"}]),
|
| 135 |
+
("root ::= [a-zA-Z]", "Z", [{"type": "end"}]),
|
| 136 |
+
("root ::= [a-zA-Z0-9]", "Z", [{"type": "end"}]),
|
| 137 |
+
("root ::= [a-zA-Z0-9]", "0", [{"type": "end"}]),
|
| 138 |
+
("root ::= [a-zA-Z0-9]", "9", [{"type": "end"}]),
|
| 139 |
+
("root ::= [a-z]?", "", [{"type": "char", "value": [[97, 122]]}, {"type": "end"}]),
|
| 140 |
+
("root ::= [a-z]?", "a", [{"type": "end"}]),
|
| 141 |
+
("root ::= [a-zA-Z]?", "Z", [{"type": "end"}]),
|
| 142 |
+
("root ::= [a-zA-Z0-9]?", "0", [{"type": "end"}]),
|
| 143 |
+
("root ::= [a-z]+", "", [{"type": "char", "value": [[97, 122]]}]),
|
| 144 |
+
("root ::= [a-z]+", "l", [{"type": "char", "value": [[97, 122]]}, {"type": "end"}]),
|
| 145 |
+
(
|
| 146 |
+
"root ::= [a-zA-Z]+",
|
| 147 |
+
"Z",
|
| 148 |
+
[{"type": "char", "value": [[97, 122], [65, 90]]}, {"type": "end"}],
|
| 149 |
+
),
|
| 150 |
+
(
|
| 151 |
+
"root ::= [a-zA-Z]+",
|
| 152 |
+
"aZ",
|
| 153 |
+
[{"type": "char", "value": [[97, 122], [65, 90]]}, {"type": "end"}],
|
| 154 |
+
),
|
| 155 |
+
(
|
| 156 |
+
"root ::= [a-zA-Z]+",
|
| 157 |
+
"azAZ",
|
| 158 |
+
[{"type": "char", "value": [[97, 122], [65, 90]]}, {"type": "end"}],
|
| 159 |
+
),
|
| 160 |
+
("root ::= [a-z]*", "", [{"type": "char", "value": [[97, 122]]}, {"type": "end"}]),
|
| 161 |
+
("root ::= [a-z]*", "a", [{"type": "char", "value": [[97, 122]]}, {"type": "end"}]),
|
| 162 |
+
(
|
| 163 |
+
"root ::= [a-zA-Z]+",
|
| 164 |
+
"Z",
|
| 165 |
+
[{"type": "char", "value": [[97, 122], [65, 90]]}, {"type": "end"}],
|
| 166 |
+
),
|
| 167 |
+
(
|
| 168 |
+
"root ::= [a-zA-Z]+",
|
| 169 |
+
"abczABCZ",
|
| 170 |
+
[{"type": "char", "value": [[97, 122], [65, 90]]}, {"type": "end"}],
|
| 171 |
+
),
|
| 172 |
+
(
|
| 173 |
+
'root ::= [^f]+ "o"',
|
| 174 |
+
"aaa",
|
| 175 |
+
[{"type": "char_exclude", "value": [102]}, {"type": "char", "value": [111]}],
|
| 176 |
+
),
|
| 177 |
+
(
|
| 178 |
+
"root ::= [^A-Z]+",
|
| 179 |
+
"abc",
|
| 180 |
+
[{"type": "char_exclude", "value": [[65, 90]]}, {"type": "end"}],
|
| 181 |
+
),
|
| 182 |
+
(
|
| 183 |
+
"root ::= [^A-Z0-9]*",
|
| 184 |
+
"abc",
|
| 185 |
+
[{"type": "char_exclude", "value": [[65, 90], [48, 57]]}, {"type": "end"}],
|
| 186 |
+
),
|
| 187 |
+
(
|
| 188 |
+
"root ::= [^A-Z0-9_-]*",
|
| 189 |
+
"abc",
|
| 190 |
+
[{"type": "char_exclude", "value": [[65, 90], [48, 57], 95, 45]}, {"type": "end"}],
|
| 191 |
+
),
|
| 192 |
+
(
|
| 193 |
+
'\nroot ::= [a-z] | xyx\nxyx ::= "foo"',
|
| 194 |
+
"f",
|
| 195 |
+
[{"type": "end"}, {"type": "char", "value": [111]}],
|
| 196 |
+
),
|
| 197 |
+
(
|
| 198 |
+
'root ::= "foo" | "bar" | "baz" | "bazaar" | "barrington" ',
|
| 199 |
+
"bazaa",
|
| 200 |
+
[{"type": "char", "value": [114]}],
|
| 201 |
+
),
|
| 202 |
+
('root ::= ("bar" | "foo") "zyx"', "bar", [{"type": "char", "value": [122]}]),
|
| 203 |
+
(
|
| 204 |
+
'root ::= "z" ("bar" | "foo") "zzzz"',
|
| 205 |
+
"z",
|
| 206 |
+
[{"type": "char", "value": [98]}, {"type": "char", "value": [102]}],
|
| 207 |
+
),
|
| 208 |
+
('root ::= "z" ("bar" | "foo") "zzz"', "zbar", [{"type": "char", "value": [122]}]),
|
| 209 |
+
(
|
| 210 |
+
"\nroot ::= termz ([-+*/] termz)* \ntermz ::= [0-9]+",
|
| 211 |
+
"1",
|
| 212 |
+
[
|
| 213 |
+
{"type": "char", "value": [[48, 57]]},
|
| 214 |
+
{"type": "char", "value": [45, 43, 42, 47]},
|
| 215 |
+
{"type": "end"},
|
| 216 |
+
],
|
| 217 |
+
),
|
| 218 |
+
(
|
| 219 |
+
'\nroot ::= expr "=" termy \nexpr ::= termy ([-+*/] termy)*\ntermy ::= [0-9]+',
|
| 220 |
+
"1",
|
| 221 |
+
[
|
| 222 |
+
{"type": "char", "value": [[48, 57]]},
|
| 223 |
+
{"type": "char", "value": [45, 43, 42, 47]},
|
| 224 |
+
{"type": "char", "value": [61]},
|
| 225 |
+
],
|
| 226 |
+
),
|
| 227 |
+
(
|
| 228 |
+
'\nroot ::= (expr "=" terma "\n")+\nexpr ::= terma ([-+*/] terma)*\nterma ::= [0-9]+',
|
| 229 |
+
"1",
|
| 230 |
+
[
|
| 231 |
+
{"type": "char", "value": [[48, 57]]},
|
| 232 |
+
{"type": "char", "value": [45, 43, 42, 47]},
|
| 233 |
+
{"type": "char", "value": [61]},
|
| 234 |
+
],
|
| 235 |
+
),
|
| 236 |
+
(
|
| 237 |
+
'root ::= (expr "=" termb "\n")+\nexpr ::= termb ([-+*/] termb)*\ntermb ::= [0-9]+',
|
| 238 |
+
"1+",
|
| 239 |
+
[{"type": "char", "value": [[48, 57]]}],
|
| 240 |
+
),
|
| 241 |
+
(
|
| 242 |
+
'\nroot ::= (expr "=" termc "\n")+\nexpr ::= termc ([-+*/] termc)*\ntermc ::= [0-9]+',
|
| 243 |
+
"1=",
|
| 244 |
+
[{"type": "char", "value": [[48, 57]]}],
|
| 245 |
+
),
|
| 246 |
+
(
|
| 247 |
+
'root ::= (expr "=" termd "\n")+\nexpr ::= termd ([-+*/] termd)*\ntermd ::= [0-9]+',
|
| 248 |
+
"1+1",
|
| 249 |
+
[
|
| 250 |
+
{"type": "char", "value": [[48, 57]]},
|
| 251 |
+
{"type": "char", "value": [45, 43, 42, 47]},
|
| 252 |
+
{"type": "char", "value": [61]},
|
| 253 |
+
],
|
| 254 |
+
),
|
| 255 |
+
(
|
| 256 |
+
'root ::= (expr "=" term "\n")+\nexpr ::= term ([-+*/] term)*\nterm ::= [0-9]+',
|
| 257 |
+
"1=1",
|
| 258 |
+
[{"type": "char", "value": [[48, 57]]}, {"type": "char", "value": [10]}],
|
| 259 |
+
),
|
| 260 |
+
(
|
| 261 |
+
'root ::= "\\"" ( [^\\"abcdefghA-Z])* ',
|
| 262 |
+
"\"is not only in its lyrism, its vow to sustin it in its poo-sion, its r,v:l'y, it's tory,",
|
| 263 |
+
[
|
| 264 |
+
{
|
| 265 |
+
"type": "char_exclude",
|
| 266 |
+
"value": [34, 97, 98, 99, 100, 101, 102, 103, 104, [65, 90]],
|
| 267 |
+
},
|
| 268 |
+
{"type": "end"},
|
| 269 |
+
],
|
| 270 |
+
),
|
| 271 |
+
(
|
| 272 |
+
"root ::= ( [^abcdefgh] | [b-z])* ",
|
| 273 |
+
"bcdefghzyxw0123ABCZ",
|
| 274 |
+
[
|
| 275 |
+
{"type": "char_exclude", "value": [97, 98, 99, 100, 101, 102, 103, 104]},
|
| 276 |
+
{"type": "char", "value": [[98, 122]]},
|
| 277 |
+
{"type": "end"},
|
| 278 |
+
],
|
| 279 |
+
),
|
| 280 |
+
],
|
| 281 |
+
)
|
| 282 |
+
def it_returns_parse_state_for_a_grammar_and_initial_string(grammar, input, expected):
|
| 283 |
+
state = GBNF(grammar)
|
| 284 |
+
state = state.add(input)
|
| 285 |
+
assert list(state) == expected
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/integration_tests/generated/validation/validate_grammar_test.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from gbnf import GBNF, GrammarParseError
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def describe_validate_grammar():
|
| 7 |
+
@pytest.mark.parametrize(
|
| 8 |
+
"grammar",
|
| 9 |
+
[
|
| 10 |
+
'root ::= "foo"',
|
| 11 |
+
'root ::= "foo" | "bar"',
|
| 12 |
+
'root ::= ("foo" | "bar")',
|
| 13 |
+
'root ::= ("foo" | "bar")?',
|
| 14 |
+
'root ::= ("foo" | "bar")*',
|
| 15 |
+
'root ::= ("foo" | "bar")+',
|
| 16 |
+
"root ::= [a-z]",
|
| 17 |
+
"root ::= [a-zA-Z]",
|
| 18 |
+
"root ::= [a-zA-Z0-9]",
|
| 19 |
+
"root ::= [a-zA-Z0-9]*",
|
| 20 |
+
"root ::= [a-zA-Z0-9]?",
|
| 21 |
+
"root ::= [a-z]+",
|
| 22 |
+
"root ::= [a-zA-Z0-9]+",
|
| 23 |
+
"root ::= ([a-zA-Z0-9])*",
|
| 24 |
+
"root ::= ([a-zA-Z0-9])?",
|
| 25 |
+
"root ::= ([a-zA-Z0-9])+",
|
| 26 |
+
'\n root ::= foo\n foo ::= "foo"',
|
| 27 |
+
'\n root ::= foo\n foo ::= "foo" | "bar" | ([a-z])?\n ',
|
| 28 |
+
],
|
| 29 |
+
)
|
| 30 |
+
def it_parses_a_grammar(grammar):
|
| 31 |
+
assert GBNF(grammar)
|
| 32 |
+
|
| 33 |
+
@pytest.mark.parametrize(
|
| 34 |
+
("grammar", "error_pos", "error_reason"),
|
| 35 |
+
[
|
| 36 |
+
("", 0, "No rules were found"),
|
| 37 |
+
('root = "foo"', 5, "Expecting ::= at 5"),
|
| 38 |
+
('root ::= foo\nfoo := "foo"\n ', 17, "Expecting ::= at 17"),
|
| 39 |
+
("root ::= foo", 9, 'Undefined rule identifier "foo"'),
|
| 40 |
+
('root ::= foo\nbar ::= "bar"\n ', 9, 'Undefined rule identifier "foo"'),
|
| 41 |
+
('root ::= foo\nfoo ::= baz\nbar ::= "bar"\n ', 21, 'Undefined rule identifier "baz"'),
|
| 42 |
+
("root ::= foo ::= bar", 13, "Expecting newline or end at 13"),
|
| 43 |
+
('root ::= ([a-z]\nfoo ::= "foo"\n ', 20, "Expecting ')' at 20"),
|
| 44 |
+
],
|
| 45 |
+
)
|
| 46 |
+
def it_reports_an_error_for_an_invalid_grammar(grammar, error_pos, error_reason):
|
| 47 |
+
with pytest.raises(GrammarParseError) as raised:
|
| 48 |
+
GBNF(grammar)
|
| 49 |
+
assert str(raised.value) == str(GrammarParseError(grammar, error_pos, error_reason))
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/integration_tests/generated/validation/validate_input_test.py
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from gbnf import GBNF, InputParseError
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def describe_validate_input():
|
| 7 |
+
@pytest.mark.parametrize(
|
| 8 |
+
("grammar", "input"),
|
| 9 |
+
[('root ::= "foo"', "f")],
|
| 10 |
+
)
|
| 11 |
+
def it_parses_a_grammar_and_input(grammar, input):
|
| 12 |
+
assert GBNF(grammar, input)
|
| 13 |
+
|
| 14 |
+
@pytest.mark.parametrize(
|
| 15 |
+
("grammar", "input", "error_pos"),
|
| 16 |
+
[
|
| 17 |
+
('root ::= "foo"', "2", 0),
|
| 18 |
+
('root ::= "foo"', "b", 0),
|
| 19 |
+
('root ::= "foo"', "f1", 1),
|
| 20 |
+
('root ::= "foo"', "fo1", 2),
|
| 21 |
+
('root ::= "foo"', "fooo", 3),
|
| 22 |
+
('root ::= "foo"', "fooooooo", 3),
|
| 23 |
+
('root ::= "foo" | "bar"', "1", 0),
|
| 24 |
+
('root ::= "foo" | "bar"', "z", 0),
|
| 25 |
+
('root ::= "foo" | "bar"', "f1", 1),
|
| 26 |
+
('root ::= "foo" | "bar"', "b1", 1),
|
| 27 |
+
('root ::= "foo" | "bar"', "fo1", 2),
|
| 28 |
+
('root ::= "foo" | "bar"', "ba1", 2),
|
| 29 |
+
('root ::= "foo" | "bar"', "fooo", 3),
|
| 30 |
+
('root ::= "foo" | "bar"', "barrr", 3),
|
| 31 |
+
('root ::= "foo" | "bar" | "baz"', "1", 0),
|
| 32 |
+
('root ::= "foo" | "bar" | "baz"', "z", 0),
|
| 33 |
+
('root ::= "foo" | "bar" | "baz"', "f1", 1),
|
| 34 |
+
('root ::= "foo" | "bar" | "baz"', "b1", 1),
|
| 35 |
+
('root ::= "foo" | "bar" | "baz"', "fo1", 2),
|
| 36 |
+
('root ::= "foo" | "bar" | "baz"', "bal", 2),
|
| 37 |
+
('root ::= "foo" | "bar" | "baz"', "fooo", 3),
|
| 38 |
+
('root ::= "foo" | "bar" | "baz"', "bazrr", 3),
|
| 39 |
+
("root ::= [^a]", "a", 0),
|
| 40 |
+
("root ::= [^abc]", "b", 0),
|
| 41 |
+
("root ::= [^a-z]", "z", 0),
|
| 42 |
+
("root ::= [^a-zA-Z]", "X", 0),
|
| 43 |
+
("root ::= [^a-zA-Z0-9]", "8", 0),
|
| 44 |
+
('\n root ::= foo\n foo ::= "foo"', "1", 0),
|
| 45 |
+
('\n root ::= foo\n foo ::= "foo"', "b", 0),
|
| 46 |
+
('\n root ::= foo\n foo ::= "foo"', "f1", 1),
|
| 47 |
+
('\n root ::= foo\n foo ::= "foo"', "fo1", 2),
|
| 48 |
+
('\n root ::= foo\n foo ::= "foo"', "fooo", 3),
|
| 49 |
+
('\n root::=foo|"bar"\n foo::="foo"', "1", 0),
|
| 50 |
+
('\n root::=foo|"bar"\n foo::="foo"', "z", 0),
|
| 51 |
+
('\n root::=foo|"bar"\n foo::="foo"', "f1", 1),
|
| 52 |
+
('\n root::=foo|"bar"\n foo::="foo"', "b1", 1),
|
| 53 |
+
('\n root::=foo|"bar"\n foo::="foo"', "fo1", 2),
|
| 54 |
+
('\n root::=foo|"bar"\n foo::="foo"', "fooo", 3),
|
| 55 |
+
('\n root::=foo|"bar"\n foo::="foo"', "barr", 3),
|
| 56 |
+
('\n root::= foo | bar\n foo::="foo"\n bar::="bar"', "1", 0),
|
| 57 |
+
('\n root::= foo | bar\n foo::="foo"\n bar::="bar"', "z", 0),
|
| 58 |
+
('\n root::= foo | bar\n foo::="foo"\n bar::="bar"', "f1", 1),
|
| 59 |
+
('\n root::= foo | bar\n foo::="foo"\n bar::="bar"', "b1", 1),
|
| 60 |
+
('\n root::= foo | bar\n foo::="foo"\n bar::="bar"', "fo1", 2),
|
| 61 |
+
('\n root::= foo | bar\n foo::="foo"\n bar::="bar"', "fooo", 3),
|
| 62 |
+
('\n root::= foo | bar\n foo::="foo"\n bar::="bar"', "barr", 3),
|
| 63 |
+
(
|
| 64 |
+
'\n root ::= f | b\n f ::= fo\n b ::= ba\n fo ::= foo\n ba ::= bar | baz\n foo ::= "foo"\n bar ::= "bar"\n baz ::= "baz"\n ',
|
| 65 |
+
"1",
|
| 66 |
+
0,
|
| 67 |
+
),
|
| 68 |
+
(
|
| 69 |
+
'\n root ::= f | b\n f ::= fo\n b ::= ba\n fo ::= foo\n ba ::= bar | baz\n foo ::= "foo"\n bar ::= "bar"\n baz ::= "baz"',
|
| 70 |
+
"z",
|
| 71 |
+
0,
|
| 72 |
+
),
|
| 73 |
+
(
|
| 74 |
+
'\n root ::= f | b\n f ::= fo\n b ::= ba\n fo ::= foo\n ba ::= bar | baz\n foo ::= "foo"\n bar ::= "bar"\n baz ::= "baz"',
|
| 75 |
+
"f1",
|
| 76 |
+
1,
|
| 77 |
+
),
|
| 78 |
+
(
|
| 79 |
+
'\n root ::= f | b\n f ::= fo\n b ::= ba\n fo ::= foo\n ba ::= bar | baz\n foo ::= "foo"\n bar ::= "bar"\n baz ::= "baz"',
|
| 80 |
+
"b1",
|
| 81 |
+
1,
|
| 82 |
+
),
|
| 83 |
+
(
|
| 84 |
+
'\n root ::= f | b\n f ::= fo\n b ::= ba\n fo ::= foo\n ba ::= bar | baz\n foo ::= "foo"\n bar ::= "bar"\n baz ::= "baz"',
|
| 85 |
+
"fo1",
|
| 86 |
+
2,
|
| 87 |
+
),
|
| 88 |
+
(
|
| 89 |
+
'\n root ::= f | b\n f ::= fo\n b ::= ba\n fo ::= foo\n ba ::= bar | baz\n foo ::= "foo"\n bar ::= "bar"\n baz ::= "baz"',
|
| 90 |
+
"fooo",
|
| 91 |
+
3,
|
| 92 |
+
),
|
| 93 |
+
(
|
| 94 |
+
'\n root ::= f | b\n f ::= fo\n b ::= ba\n fo ::= foo\n ba ::= bar | baz\n foo ::= "foo"\n bar ::= "bar"\n baz ::= "baz"',
|
| 95 |
+
"barr",
|
| 96 |
+
3,
|
| 97 |
+
),
|
| 98 |
+
(
|
| 99 |
+
'\n root ::= f | b\n f ::= fo\n b ::= ba\n fo ::= foo\n ba ::= bar | baz\n foo ::= "foo"\n bar ::= "bar"\n baz ::= "baz"',
|
| 100 |
+
"bazr",
|
| 101 |
+
3,
|
| 102 |
+
),
|
| 103 |
+
("root ::= [a-z]", "A", 0),
|
| 104 |
+
("root ::= [a-z]", "0", 0),
|
| 105 |
+
("root ::= [a-z]", "az", 1),
|
| 106 |
+
("root ::= [a-z]?", "A", 0),
|
| 107 |
+
("root ::= [a-z]?", "0", 0),
|
| 108 |
+
("root ::= [a-z]?", "az", 1),
|
| 109 |
+
("root ::= [a-z]+", "A", 0),
|
| 110 |
+
("root ::= [a-z]+", "0", 0),
|
| 111 |
+
("root ::= [a-z]+", "az0", 2),
|
| 112 |
+
("root ::= [a-z]*", "A", 0),
|
| 113 |
+
("root ::= [a-z]*", "0", 0),
|
| 114 |
+
("root ::= [a-z]*", "az0", 2),
|
| 115 |
+
("root ::= ( [^abcdefgh] | [b-z])*", "a", 0),
|
| 116 |
+
],
|
| 117 |
+
)
|
| 118 |
+
def it_reports_an_error_for_an_invalid_input(grammar, input, error_pos):
|
| 119 |
+
error = InputParseError(input, error_pos, "")
|
| 120 |
+
with pytest.raises(InputParseError) as raised:
|
| 121 |
+
graph = GBNF(grammar)
|
| 122 |
+
graph.add(input)
|
| 123 |
+
assert str(raised.value) == str(error)
|
v2-models-effort/runs/20261111-214430-spring-scene/ported_implementation/pyproject.toml
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[build-system]
|
| 2 |
+
requires = ["uv_build>=0.12.10,<0.13"]
|
| 3 |
+
build-backend = "uv_build"
|
| 4 |
+
|
| 5 |
+
[project]
|
| 6 |
+
name = "gbnf"
|
| 7 |
+
version = "0.1.41"
|
| 8 |
+
description = "A library for parsing GBNF grammars"
|
| 9 |
+
readme = "README.md"
|
| 10 |
+
license = "MIT"
|
| 11 |
+
authors = [{ name = "Ambient Labs" }]
|
| 12 |
+
keywords = ["gbnf", "grammar", "grammar-parser"]
|
| 13 |
+
classifiers = [
|
| 14 |
+
"Programming Language :: Python :: 3",
|
| 15 |
+
"Typing :: Typed",
|
| 16 |
+
]
|
| 17 |
+
requires-python = ">=3.13"
|
| 18 |
+
dependencies = []
|
| 19 |
+
|
| 20 |
+
[dependency-groups]
|
| 21 |
+
dev = [
|
| 22 |
+
"pytest>=9.1.1",
|
| 23 |
+
"pytest-describe>=3.2.0",
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
[tool.uv.build-backend]
|
| 27 |
+
# The package sits next to this file rather than under src/.
|
| 28 |
+
module-root = ""
|
| 29 |
+
# Tests are part of the source distribution, but not of the wheel.
|
| 30 |
+
source-include = ["integration_tests/**"]
|
| 31 |
+
wheel-exclude = ["*_test.py"]
|
| 32 |
+
|
| 33 |
+
[tool.pytest.ini_options]
|
| 34 |
+
# Unit tests are colocated with the modules they cover (gbnf/**/*_test.py);
|
| 35 |
+
# the generated integration tests live in integration_tests/.
|
| 36 |
+
testpaths = ["gbnf", "integration_tests"]
|
| 37 |
+
python_files = ["*_test.py"]
|
| 38 |
+
pythonpath = ["."]
|
v2-models-effort/runs/20261111-214430-spring-scene/proxy.log
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
NOTICE Nov 12 04:42:38.239 [8]: Initializing tinyproxy ...
|
| 2 |
+
NOTICE Nov 12 04:42:38.240 [8]: Reloading config file (/etc/tinyproxy/tinyproxy.conf)
|
| 3 |
+
INFO Nov 12 04:42:38.240 [8]: Added address [127.0.0.1] to listen addresses.
|
| 4 |
+
INFO Nov 12 04:42:38.240 [8]: Adding Port [443] to the list allowed by CONNECT
|
| 5 |
+
NOTICE Nov 12 04:42:38.240 [8]: Reloading config file finished
|
| 6 |
+
INFO Nov 12 04:42:38.240 [8]: listen_sock called with addr = '127.0.0.1'
|
| 7 |
+
INFO Nov 12 04:42:38.240 [8]: trying to listen on host[127.0.0.1], family[2], socktype[1], proto[6]
|
| 8 |
+
INFO Nov 12 04:42:38.240 [8]: listening on fd [3]
|
| 9 |
+
INFO Nov 12 04:42:38.240 [8]: Not running as root, so not changing UID/GID.
|
| 10 |
+
INFO Nov 12 04:42:38.240 [8]: Setting the various signals.
|
| 11 |
+
INFO Nov 12 04:42:38.240 [8]: Starting main loop. Accepting connections.
|
| 12 |
+
botbox-proxy: listening
|
| 13 |
+
CONNECT Nov 12 04:42:39.191 [8]: Connect (file descriptor 4): 127.0.0.1
|
| 14 |
+
CONNECT Nov 12 04:42:39.191 [8]: Request (file descriptor 4): CONNECT api.anthropic.com:443 HTTP/1.1
|
| 15 |
+
NOTICE Nov 12 04:42:39.192 [8]: Proxying refused on filtered url "api.anthropic.com:443"
|
v2-models-effort/runs/20261111-214430-spring-scene/result.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"duration_api_ms":7820500,"stop_reason":"end_turn","session_id":"adbc157d-c956-4966-b96a-a12bba8a4285","total_cost_usd":33.007608999999974,"usage":{"input_tokens":608,"cache_creation_input_tokens":1286585,"cache_read_input_tokens":30608610,"output_tokens":563164,"output_tokens_details":{"thinking_tokens":399118},"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":1286585,"ephemeral_5m_input_tokens":0},"inference_geo":"global","iterations":[],"speed":"standard","fallback_credit":null},"modelUsage":{"claude-fable-5-2":{"inputTokens":44752,"outputTokens":747939,"cacheReadInputTokens":32209905,"cacheCreationInputTokens":1521996,"webSearchRequests":0,"costUSD":33.007608999999974,"contextWindow":200000,"maxOutputTokens":32000,"thinkingTokens":406584,"canonicalModel":"claude-fable-5-2","provider":"firstParty","costBasis":"unknown"}},"permission_denials":[],"terminal_reason":"completed","fast_mode_state":"off","fast_mode_disabled_reason":"sdk_opt_in_required","subagent_stats":{"spawned":1,"requested":{"background":1,"foreground":0,"unset":0},"started_in_background":1,"max_depth":1,"spawned_by_subagents":0,"completed":0,"failed":0,"killed":{"parent":0,"user":0,"system":1},"refused":{"depth_limit":0,"concurrency_limit":0,"budget":0},"by_type":{"general-purpose":1}},"safety_stops":0,"is_error":false,"num_turns":369,"subtype":"success","api_error_status":null,"result":"The suite is green (976 passed) and `/target` has no stray files. An independent review of the port against the reference is still running in the background; I'll check its findings against the reference before giving the final report.","ttft_ms":1103,"type":"result","duration_ms":8699827,"uuid":"7cca7f0d-c171-4408-827c-9b9c343cc060","ttft_stream_ms":502,"time_to_request_ms":55,"first_content_frame_ms":502,"queued_turn_count":0,"result_index":0}
|
v2-models-effort/runs/20261111-214430-spring-scene/run.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"params": {
|
| 3 |
+
"source-language": "javascript",
|
| 4 |
+
"model": "claude-fable-5-2",
|
| 5 |
+
"effort": "max"
|
| 6 |
+
},
|
| 7 |
+
"command": "uv run --project packages/gbnf_experiment run_gbnf_experiment --include-unit-tests 1 --include-source-integration-tests 1 --include-target-integration-tests 0 --output /home/duncan/work/code/research/ports/experiments/v2-models-effort/runs/20261111-214430-spring-scene --source-language javascript --model claude-fable-5-2 --effort max --auth subscription --memory 24g",
|
| 8 |
+
"created": "2026-11-12T04:42:21Z",
|
| 9 |
+
"ended": "2026-11-12T07:17:40Z",
|
| 10 |
+
"exit_code": 0,
|
| 11 |
+
"error": null,
|
| 12 |
+
"ended_by": null,
|
| 13 |
+
"signal": null,
|
| 14 |
+
"git": {
|
| 15 |
+
"commit": "8422439f49db061ed5b56e9b883ef244807898f8",
|
| 16 |
+
"dirty": true
|
| 17 |
+
},
|
| 18 |
+
"labnotes_version": "0.2.39.dev138",
|
| 19 |
+
"labnotes_command": "labnotes experiments v2-models-effort run --concurrency 1 --model=claude-fable-5-2 -- --auth subscription --memory 24g",
|
| 20 |
+
"args": [
|
| 21 |
+
"--auth",
|
| 22 |
+
"subscription",
|
| 23 |
+
"--memory",
|
| 24 |
+
"24g"
|
| 25 |
+
],
|
| 26 |
+
"pid": 170227,
|
| 27 |
+
"pid_created": 1794458541.73
|
| 28 |
+
}
|
v2-models-effort/runs/20261111-214430-spring-scene/run.lock
ADDED
|
File without changes
|
v2-models-effort/runs/20261111-214430-spring-scene/stderr.log
ADDED
|
File without changes
|
v2-models-effort/runs/20261111-214430-spring-scene/stderr.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[claude-code:unrecognized_model] {"model":"claude-fable-5-2","query_source":"sdk"}
|
| 2 |
+
Background tasks still running 10m after the last turn (subagent "Adversarial review of port"); stopping them. Set CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS=0 to wait indefinitely.
|
v2-models-effort/runs/20261111-214430-spring-scene/stdout.log
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
*** auth: subscription ***
|
v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/adbc157d-c956-4966-b96a-a12bba8a4285.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/adbc157d-c956-4966-b96a-a12bba8a4285/subagents/agent-a2c07bb5517d717f5.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/adbc157d-c956-4966-b96a-a12bba8a4285/subagents/agent-a2c07bb5517d717f5.meta.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"agentType":"general-purpose","description":"Adversarial review of port","toolUseId":"toolu_01WJsrPc2RiUKYjiNqZySRRx","spawnDepth":1,"requestShape":"background","requestNonInteractive":true}
|
v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/memory/MEMORY.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
- [Write in small pieces](write-in-small-pieces.md) — after an output-limit hit, split the remaining work into smaller steps
|
| 2 |
+
- [Unicode escapes in tool parameters](unicode-escapes-in-tool-parameters.md) — backslash-u escapes typed into Write/Edit/Bash arrive decoded
|
| 3 |
+
- [gbnf Python port](gbnf-python-port.md) — state of the port in /target, how to run its tests, environment gotchas
|
v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/memory/gbnf-python-port.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: gbnf-python-port
|
| 3 |
+
description: State of the Python port of the JavaScript gbnf library in /target and how to run and check it
|
| 4 |
+
metadata:
|
| 5 |
+
node_type: memory
|
| 6 |
+
type: project
|
| 7 |
+
originSessionId: adbc157d-c956-4966-b96a-a12bba8a4285
|
| 8 |
+
modified: 2026-11-12T07:04:41.016Z
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
`/target` holds a Python port of the JavaScript `gbnf` 0.1.41 library (reference mounted read-only
|
| 12 |
+
at `/input/javascript`). As of 2026-11-12 the port is complete: all 203 unit tests and 773
|
| 13 |
+
generated integration tests of the reference are ported and pass (976 in total, same count per
|
| 14 |
+
file as vitest). The deliberate differences from the reference are listed in `/target/README.md`.
|
| 15 |
+
|
| 16 |
+
**Why:** The task was a faithful, idiomatic port including the test suites; behaviour was checked
|
| 17 |
+
against the reference by running both on the same generated grammars and inputs, not only by the
|
| 18 |
+
ported tests.
|
| 19 |
+
|
| 20 |
+
**How to apply:**
|
| 21 |
+
- Run the tests with the system pytest from `/target` (`pytest`, needs pytest-describe). There is
|
| 22 |
+
no network, so `uv run pytest` cannot resolve the dev dependencies; `uv build` works offline
|
| 23 |
+
because the project uses the `uv_build` backend.
|
| 24 |
+
- Do not start Python with the working directory inside `gbnf/grammar_graph` or
|
| 25 |
+
`gbnf/rules_builder`: their `types.py` shadows the standard library's `types` module.
|
| 26 |
+
- Only Python 3.14 is installed; `requires-python = ">=3.13"` was checked statically only.
|
| 27 |
+
- The reference can be run with vitest from a writable copy of `/input/javascript` when a
|
| 28 |
+
behaviour needs to be compared.
|
| 29 |
+
- See also [[write-in-small-pieces]] and [[unicode-escapes-in-tool-parameters]].
|
v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/memory/unicode-escapes-in-tool-parameters.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: unicode-escapes-in-tool-parameters
|
| 3 |
+
description: A backslash-u escape typed into a Write/Edit/Bash parameter arrives as the decoded character
|
| 4 |
+
metadata:
|
| 5 |
+
node_type: memory
|
| 6 |
+
type: project
|
| 7 |
+
originSessionId: adbc157d-c956-4966-b96a-a12bba8a4285
|
| 8 |
+
modified: 2026-11-12T07:04:35.593Z
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
In this environment a four-digit backslash-u escape typed into a Write, Edit or Bash parameter is
|
| 12 |
+
decoded before it reaches the file: the file gets the character itself, not the six-character
|
| 13 |
+
escape. The eight-digit capital-U form is left alone.
|
| 14 |
+
|
| 15 |
+
**Why:** It silently changed test data in the [[gbnf-python-port]], where grammars under test
|
| 16 |
+
contain such escapes as literal text.
|
| 17 |
+
|
| 18 |
+
**How to apply:** When a file must contain the escape literally, produce it with a script that
|
| 19 |
+
builds the backslash from `chr(92)` (or copies the text from the reference file) rather than typing
|
| 20 |
+
it. Afterwards list the non-ASCII characters of the written files and check that each is intended.
|
v2-models-effort/runs/20261111-214430-spring-scene/transcript/.claude/projects/-target/memory/write-in-small-pieces.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: write-in-small-pieces
|
| 3 |
+
description: After an output-token-limit hit the user wants remaining work split into smaller pieces
|
| 4 |
+
metadata:
|
| 5 |
+
node_type: memory
|
| 6 |
+
type: feedback
|
| 7 |
+
originSessionId: adbc157d-c956-4966-b96a-a12bba8a4285
|
| 8 |
+
modified: 2026-11-12T07:04:31.967Z
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
When a response is cut off by the output token limit, resume directly (no apology, no recap) and
|
| 12 |
+
break the remaining work into smaller pieces.
|
| 13 |
+
|
| 14 |
+
**Why:** While porting the `gbnf` library to Python (see [[gbnf-python-port]]), writing large files
|
| 15 |
+
or long generated test tables in a single tool call hit the output limit twice; the user replied
|
| 16 |
+
both times with "Break remaining work into smaller pieces."
|
| 17 |
+
|
| 18 |
+
**How to apply:** Write big files in several steps (a first Write, then Edits/appends), generate
|
| 19 |
+
long data tables with a script instead of typing them out, and keep each message short.
|
v2-models-effort/runs/20261111-214430-steep-field/credentials.log
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[2026-11-12 08:07:33.251][21][warning][main] [source/server/server.cc:1012] There is no configured limit to the number of allowed active downstream connections. Configure a limit in `envoy.resource_monitors.global_downstream_max_connections` resource monitor.
|
| 2 |
+
[2026-11-12T08:07:33.760Z] POST /v1/messages?beta=true 200 - 2998ms
|
| 3 |
+
[2026-11-12T08:07:36.781Z] POST /v1/messages?beta=true 200 - 2527ms
|
| 4 |
+
[2026-11-12T08:07:39.326Z] POST /v1/messages?beta=true 200 - 4253ms
|
| 5 |
+
[2026-11-12T08:07:43.598Z] POST /v1/messages?beta=true 200 - 3876ms
|
| 6 |
+
[2026-11-12T08:07:47.500Z] POST /v1/messages?beta=true 200 - 1265ms
|
| 7 |
+
[2026-11-12T08:07:48.769Z] POST /v1/messages/count_tokens?beta=true 200 - 97ms
|
| 8 |
+
[2026-11-12T08:07:48.876Z] POST /v1/messages?beta=true 200 - 4845ms
|
| 9 |
+
[2026-11-12T08:07:53.743Z] POST /v1/messages?beta=true 200 - 2668ms
|
| 10 |
+
[2026-11-12T08:07:56.424Z] POST /v1/messages?beta=true 200 - 31011ms
|
| 11 |
+
[2026-11-12T08:08:27.456Z] POST /v1/messages?beta=true 200 - 2514ms
|
| 12 |
+
[2026-11-12T08:08:29.990Z] POST /v1/messages?beta=true 200 - 54657ms
|
| 13 |
+
[2026-11-12T08:09:24.680Z] POST /v1/messages?beta=true 200 - 6910ms
|
| 14 |
+
[2026-11-12T08:09:32.877Z] POST /v1/messages?beta=true 200 - 4301ms
|
| 15 |
+
[2026-11-12T08:09:37.760Z] POST /v1/messages?beta=true 200 - 1482ms
|
| 16 |
+
[2026-11-12T08:09:39.254Z] POST /v1/messages?beta=true 200 - 18318ms
|
| 17 |
+
[2026-11-12T08:09:57.699Z] POST /v1/messages?beta=true 200 - 5525ms
|
| 18 |
+
[2026-11-12T08:10:03.240Z] POST /v1/messages?beta=true 200 - 1541ms
|
| 19 |
+
[2026-11-12T08:10:04.799Z] POST /v1/messages?beta=true 200 - 6209ms
|
| 20 |
+
[2026-11-12T08:10:11.033Z] POST /v1/messages?beta=true 200 - 1335ms
|
| 21 |
+
[2026-11-12T08:10:12.383Z] POST /v1/messages?beta=true 200 - 154958ms
|
| 22 |
+
[2026-11-12T08:12:47.486Z] POST /v1/messages?beta=true 200 - 145818ms
|
| 23 |
+
[2026-11-12T08:15:13.564Z] POST /v1/messages?beta=true 200 - 2246ms
|
| 24 |
+
[2026-11-12T08:15:15.827Z] POST /v1/messages?beta=true 200 - 298732ms
|
| 25 |
+
[2026-11-12T08:20:14.582Z] POST /v1/messages?beta=true 200 - 125971ms
|
| 26 |
+
[2026-11-12T08:22:20.561Z] POST /v1/messages/count_tokens?beta=true 200 - 118ms
|
| 27 |
+
[2026-11-12T08:22:20.703Z] POST /v1/messages?beta=true 200 - 2265ms
|
| 28 |
+
[2026-11-12T08:22:23.005Z] POST /v1/messages?beta=true 200 - 6606ms
|
| 29 |
+
[2026-11-12T08:22:29.635Z] POST /v1/messages?beta=true 200 - 28144ms
|
| 30 |
+
[2026-11-12T08:22:57.796Z] POST /v1/messages?beta=true 200 - 11419ms
|
| 31 |
+
[2026-11-12T08:23:09.230Z] POST /v1/messages?beta=true 200 - 38686ms
|
| 32 |
+
[2026-11-12T08:23:47.942Z] POST /v1/messages?beta=true 200 - 20342ms
|
| 33 |
+
[2026-11-12T08:24:08.676Z] POST /v1/messages?beta=true 200 - 2593ms
|
| 34 |
+
[2026-11-12T08:24:11.286Z] POST /v1/messages?beta=true 200 - 35443ms
|
| 35 |
+
[2026-11-12T08:24:46.740Z] POST /v1/messages?beta=true 200 - 19118ms
|
| 36 |
+
[2026-11-12T08:25:05.883Z] POST /v1/messages?beta=true 200 - 23017ms
|
| 37 |
+
[2026-11-12T08:25:28.924Z] POST /v1/messages?beta=true 200 - 33067ms
|
| 38 |
+
[2026-11-12T08:26:02.008Z] POST /v1/messages?beta=true 200 - 25812ms
|
| 39 |
+
[2026-11-12T08:26:27.890Z] POST /v1/messages?beta=true 200 - 12928ms
|
| 40 |
+
[2026-11-12T08:26:40.832Z] POST /v1/messages?beta=true 200 - 39554ms
|
| 41 |
+
[2026-11-12T08:27:20.403Z] POST /v1/messages?beta=true 200 - 38047ms
|
| 42 |
+
[2026-11-12T08:27:58.488Z] POST /v1/messages?beta=true 200 - 21147ms
|
| 43 |
+
[2026-11-12T08:28:19.656Z] POST /v1/messages?beta=true 200 - 27515ms
|
| 44 |
+
[2026-11-12T08:28:47.556Z] POST /v1/messages?beta=true 200 - 5010ms
|
| 45 |
+
[2026-11-12T08:28:53.360Z] POST /v1/messages?beta=true 200 - 3154ms
|
| 46 |
+
[2026-11-12T08:28:56.529Z] POST /v1/messages?beta=true 200 - 50964ms
|
| 47 |
+
[2026-11-12T08:29:47.509Z] POST /v1/messages?beta=true 200 - 15571ms
|
| 48 |
+
[2026-11-12T08:30:03.093Z] POST /v1/messages?beta=true 200 - 3545ms
|
| 49 |
+
[2026-11-12T08:30:06.656Z] POST /v1/messages?beta=true 200 - 11655ms
|
| 50 |
+
[2026-11-12T08:30:18.325Z] POST /v1/messages?beta=true 200 DC 353396ms
|
| 51 |
+
[2026-11-12T08:36:11.725Z] POST /v1/messages?beta=true 200 - 26687ms
|
| 52 |
+
[2026-11-12T08:36:38.443Z] POST /v1/messages?beta=true 200 - 13303ms
|
| 53 |
+
[2026-11-12T08:36:51.781Z] POST /v1/messages?beta=true 200 - 29263ms
|
| 54 |
+
[2026-11-12T08:37:21.069Z] POST /v1/messages?beta=true 200 - 100554ms
|
| 55 |
+
[2026-11-12T08:39:01.649Z] POST /v1/messages?beta=true 200 - 8513ms
|
| 56 |
+
[2026-11-12T08:39:10.181Z] POST /v1/messages?beta=true 200 - 44979ms
|
| 57 |
+
[2026-11-12T08:39:55.544Z] POST /v1/messages?beta=true 200 - 104222ms
|
| 58 |
+
[2026-11-12T08:41:39.776Z] POST /v1/messages/count_tokens?beta=true 200 - 113ms
|
| 59 |
+
[2026-11-12T08:41:39.915Z] POST /v1/messages?beta=true 200 - 4999ms
|
| 60 |
+
[2026-11-12T08:41:44.929Z] POST /v1/messages?beta=true 200 - 23347ms
|
| 61 |
+
[2026-11-12T08:42:08.296Z] POST /v1/messages?beta=true 200 - 2077ms
|
| 62 |
+
[2026-11-12T08:42:10.386Z] POST /v1/messages?beta=true 200 - 59570ms
|
| 63 |
+
[2026-11-12T08:43:10.338Z] POST /v1/messages?beta=true 200 - 3158ms
|
| 64 |
+
[2026-11-12T08:43:13.511Z] POST /v1/messages?beta=true 200 - 2689ms
|
| 65 |
+
[2026-11-12T08:43:16.213Z] POST /v1/messages?beta=true 200 - 4430ms
|
| 66 |
+
[2026-11-12T08:43:20.658Z] POST /v1/messages?beta=true 200 - 26152ms
|
| 67 |
+
[2026-11-12T08:43:47.199Z] POST /v1/messages?beta=true 200 - 5186ms
|
| 68 |
+
[2026-11-12T08:43:52.400Z] POST /v1/messages?beta=true 200 - 36876ms
|
| 69 |
+
[2026-11-12T08:44:29.704Z] POST /v1/messages?beta=true 200 - 4433ms
|
| 70 |
+
[2026-11-12T08:44:34.157Z] POST /v1/messages?beta=true 200 - 2728ms
|
| 71 |
+
[2026-11-12T08:44:36.906Z] POST /v1/messages?beta=true 200 - 4585ms
|
| 72 |
+
[2026-11-12T08:44:42.065Z] POST /v1/messages?beta=true 200 - 2382ms
|
| 73 |
+
[2026-11-12T08:44:44.467Z] POST /v1/messages?beta=true 200 - 2401ms
|
| 74 |
+
[2026-11-12T08:44:46.889Z] POST /v1/messages?beta=true 200 - 8993ms
|
| 75 |
+
[2026-11-12T08:44:55.902Z] POST /v1/messages?beta=true 200 - 12751ms
|
| 76 |
+
[2026-11-12T08:45:08.700Z] POST /v1/messages?beta=true 200 - 26850ms
|
| 77 |
+
[2026-11-12T08:45:35.570Z] POST /v1/messages?beta=true 200 - 14377ms
|
| 78 |
+
[2026-11-12T08:45:49.970Z] POST /v1/messages?beta=true 200 - 34278ms
|
| 79 |
+
[2026-11-12T08:46:24.764Z] POST /v1/messages?beta=true 200 - 3802ms
|
| 80 |
+
[2026-11-12T08:46:28.588Z] POST /v1/messages?beta=true 200 - 22760ms
|
| 81 |
+
[2026-11-12T08:46:51.532Z] POST /v1/messages?beta=true 200 - 2007ms
|
| 82 |
+
[2026-11-12T08:46:54.129Z] POST /v1/messages?beta=true 200 - 62453ms
|
| 83 |
+
[2026-11-12T08:47:58.563Z] POST /v1/messages?beta=true 200 - 16709ms
|
| 84 |
+
[2026-11-12T08:48:17.433Z] POST /v1/messages?beta=true 200 - 20947ms
|
| 85 |
+
[2026-11-12T08:48:38.402Z] POST /v1/messages?beta=true 200 - 8054ms
|
| 86 |
+
[2026-11-12T08:48:46.601Z] POST /v1/messages?beta=true 200 - 10707ms
|
| 87 |
+
[2026-11-12T08:48:59.282Z] POST /v1/messages?beta=true 200 - 10731ms
|
| 88 |
+
[2026-11-12T08:51:10.067Z] POST /v1/messages?beta=true 200 - 3973ms
|
| 89 |
+
[2026-11-12T08:51:14.066Z] POST /v1/messages?beta=true 200 - 12133ms
|
| 90 |
+
[2026-11-12T08:51:52.774Z] POST /v1/messages?beta=true 200 - 8696ms
|
| 91 |
+
[2026-11-12T08:53:01.238Z] POST /v1/messages?beta=true 200 - 6504ms
|
| 92 |
+
[2026-11-12T08:53:08.291Z] POST /v1/messages?beta=true 200 - 13009ms
|
| 93 |
+
[2026-11-12T08:53:21.782Z] POST /v1/messages?beta=true 200 - 10831ms
|
| 94 |
+
[2026-11-12T08:53:32.689Z] POST /v1/messages?beta=true 200 - 4089ms
|
| 95 |
+
[2026-11-12T08:53:36.793Z] POST /v1/messages?beta=true 200 - 2128ms
|
| 96 |
+
[2026-11-12T08:53:38.937Z] POST /v1/messages?beta=true 200 - 9144ms
|
| 97 |
+
[2026-11-12T08:53:48.113Z] POST /v1/messages?beta=true 200 - 83080ms
|
| 98 |
+
[2026-11-12T08:55:11.200Z] POST /v1/messages/count_tokens?beta=true 200 - 107ms
|
| 99 |
+
[2026-11-12T08:55:11.200Z] POST /v1/messages/count_tokens?beta=true 200 - 111ms
|
| 100 |
+
[2026-11-12T08:55:11.340Z] POST /v1/messages?beta=true 200 - 2489ms
|
| 101 |
+
[2026-11-12T08:55:13.839Z] POST /v1/messages?beta=true 200 - 3794ms
|
| 102 |
+
[2026-11-12T08:55:17.648Z] POST /v1/messages?beta=true 200 - 8302ms
|
| 103 |
+
[2026-11-12T08:55:25.963Z] POST /v1/messages?beta=true 200 - 33167ms
|
| 104 |
+
[2026-11-12T08:55:59.148Z] POST /v1/messages?beta=true 200 - 27211ms
|
| 105 |
+
[2026-11-12T08:56:26.371Z] POST /v1/messages?beta=true 200 - 71556ms
|
| 106 |
+
[2026-11-12T08:57:37.942Z] POST /v1/messages?beta=true 200 - 15250ms
|
| 107 |
+
[2026-11-12T08:57:53.200Z] POST /v1/messages?beta=true 200 - 20389ms
|
| 108 |
+
[2026-11-12T08:58:13.610Z] POST /v1/messages?beta=true 200 - 6837ms
|
| 109 |
+
[2026-11-12T08:58:20.464Z] POST /v1/messages?beta=true 200 - 2712ms
|
| 110 |
+
[2026-11-12T08:58:23.194Z] POST /v1/messages?beta=true 200 - 5660ms
|
| 111 |
+
[2026-11-12T08:58:28.870Z] POST /v1/messages?beta=true 200 - 6981ms
|
| 112 |
+
[2026-11-12T08:58:35.890Z] POST /v1/messages?beta=true 200 - 2743ms
|
| 113 |
+
[2026-11-12T08:58:38.664Z] POST /v1/messages?beta=true 200 - 8161ms
|
| 114 |
+
[2026-11-12T08:58:46.852Z] POST /v1/messages?beta=true 200 - 14027ms
|
| 115 |
+
[2026-11-12T08:59:00.897Z] POST /v1/messages?beta=true 200 - 7920ms
|
| 116 |
+
[2026-11-12T08:59:08.830Z] POST /v1/messages?beta=true 200 - 5614ms
|
| 117 |
+
[2026-11-12T08:59:15.277Z] POST /v1/messages?beta=true 200 - 6902ms
|
| 118 |
+
[2026-11-12T08:59:23.078Z] POST /v1/messages?beta=true 200 - 9108ms
|
| 119 |
+
[2026-11-12T08:59:32.213Z] POST /v1/messages?beta=true 200 - 11913ms
|
| 120 |
+
[2026-11-12T08:59:44.522Z] POST /v1/messages?beta=true 200 - 34768ms
|
| 121 |
+
[2026-11-12T09:00:19.322Z] POST /v1/messages?beta=true 200 - 2391ms
|
| 122 |
+
[2026-11-12T09:00:21.729Z] POST /v1/messages?beta=true 200 - 5425ms
|
| 123 |
+
[2026-11-12T09:00:19.312Z] POST /v1/messages?beta=true 200 - 15112ms
|
| 124 |
+
[2026-11-12T09:00:34.808Z] POST /v1/messages?beta=true 200 - 19836ms
|
| 125 |
+
[2026-11-12T09:00:54.667Z] POST /v1/messages?beta=true 200 - 3972ms
|
| 126 |
+
[2026-11-12T09:00:58.665Z] POST /v1/messages?beta=true 200 - 5967ms
|
| 127 |
+
[2026-11-12T09:01:04.647Z] POST /v1/messages?beta=true 200 - 5340ms
|
| 128 |
+
[2026-11-12T09:00:27.163Z] POST /v1/messages?beta=true 200 - 49128ms
|
| 129 |
+
[2026-11-12T09:01:16.304Z] POST /v1/messages?beta=true 200 - 4584ms
|
| 130 |
+
[2026-11-12T09:01:20.905Z] POST /v1/messages?beta=true 200 - 266228ms
|
| 131 |
+
[2026-11-12T09:05:47.140Z] POST /v1/messages?beta=true 200 - 272912ms
|
| 132 |
+
[2026-11-12T09:10:20.199Z] POST /v1/messages?beta=true 200 DC 50002ms
|
| 133 |
+
[2026-11-12 09:11:10.871][21][warning][main] [source/server/server.cc:981] caught ENVOY_SIGTERM
|
v2-models-effort/runs/20261111-214430-steep-field/git-diff.patch
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|